Inlines PdfViewWebPlugin::CreateUrlLoaderInternal() into the call sites,
as this method does very little now.
Also gets rid of UrlLoader::GrantUniversalAccess(), which the PDF viewer
always uses for all requests.
Bug: 1322928
Change-Id: I34c49fb2f83debeb52515819c21d1e188f0f452d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3710222
Auto-Submit: K. Moon <kmoon@chromium.org>
Reviewed-by: Nigi <nigi@chromium.org>
Commit-Queue: Nigi <nigi@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1015447}
Migrates UpdateGeometryOnPluginRectChanged() from PdfViewPluginBase to
PdfViewWebPlugin, inlining into PdfViewWebPlugin::OnViewportChanged().
Also migrates first_paint_ and PrepareForFirstPaint(), as these are
simpler to migrate simultaneously with
UpdateGeometryOnPluginRectChanged().
Bug: 1302059
Change-Id: I4655f5569f79c2f29e40737633685752a595e8ca
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3708313
Reviewed-by: Nigi <nigi@chromium.org>
Commit-Queue: K. Moon <kmoon@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1014800}
Migrates HandleViewportMessage() from PdfViewPluginBase to
PdfViewWebPlugin.
Also migrates stop_scrolling_, HandleStopScrollingMessage(), and
UpdateScroll(), as these are simpler to migrate simultaneously with
HandleViewportMessage().
Bug: 1302059
Change-Id: I542ae895838e515009cda99a6d9b2d18521c3ebd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3708002
Reviewed-by: Nigi <nigi@chromium.org>
Commit-Queue: K. Moon <kmoon@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1014798}
Migrates Print Preview loading logic from PdfViewPluginBase to
PdfViewWebPlugin. This logic is tightly coupled, so it makes sense to
migrate it as a unit.
Reorders and inlines some of the methods to reflect control flow better.
Also migrates PdfViewPluginBase::url_, since all uses are now in
PdfViewWebPlugin.
Bug: 1302059
Change-Id: I9a377b3c5b2242d59f7e0bc9df91849117cc4827
Cq-Do-Not-Cancel-Tryjobs: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3708337
Commit-Queue: K. Moon <kmoon@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1014796}
A named destination in a PDF file sometimes can contain an out-of-range
page number, which will trigger out-of-bounds accesses in
PDFiumEngine::GetNamedDestination().
This CL makes PDFiumEngine::GetNamedDestination() treat an invalid page
number as an error and return an empty result. Also adds a unit test
for this function to test getting both valid and invalid page
destinations.
Bug: 1333374
Change-Id: I8a62274146430c6f4bf170f652d4b158d907924b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3696844
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Nigi <nigi@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1012771}
Migrates all of the remaining PdfViewPluginBase tests.
Drops the existing PdfViewWebPluginMouseEventsTest.HandleInputEvent and
PdfViewWebPluginTest.SetCaretPositionIgnoresOrigin tests, as they're
redundant with the migrated tests.
Fixed: 1323307
Change-Id: I74129c23250659a894baec600f91fcfa4767c80b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3698751
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: K. Moon <kmoon@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1012756}
Adds a ParseMessage() wrapper around base::test::ParseJson() that
returns a base::Value::Dict instead of a base::Value. This makes it
easier to construct test messages in a readable way.
Bug: 1323307
Change-Id: I3c8a3be545616103e5b305f9fbd1eee8b31e6634
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3698903
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: K. Moon <kmoon@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1012672}
Migrates tests exercising PdfViewPluginBase's UpdateScroll() method.
Also cleans up more dead code in pdf_view_plugin_base_unittest.cc.
Bug: 1323307
Change-Id: Id7e318c581282e02b4dd16dcaddabb31306df32c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3696528
Commit-Queue: K. Moon <kmoon@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1012644}
Migrates PdfViewPluginBase tests that exercise printing.
Also replaces the ad hoc TestPDFiumEngine::SetPermissions() API with a
gMock-based equivalent.
Bug: 1323307
Change-Id: I6fe7cd54a5bc208990fccdbef16a6e5cdf7aa879
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3696484
Commit-Queue: K. Moon <kmoon@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1012236}
Moves accessibility-related PostTask() calls from PdfViewWebPlugin to
PdfAccessibilityTree. This makes it easier to test the calls to
PdfAccessibilityDataHandler by making them synchronous.
Note that the accessibility operations are asynchronous in order to fix
crbug.com/1274376, but this essentially is an implementation detail of
PdfAccessibilityTree (which triggers layout), rather than being
fundamental to all PdfAccessibilityDataHandler implementations.
Bug: 1323307
Change-Id: Ibcfc0ab2a1b44f55430f0c31f420b77069ec3b29
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3692602
Commit-Queue: K. Moon <kmoon@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1011669}
Migrates tests exercising the basic functionality of PdfViewPluginBase's
DocumentLoadComplete() method.
Adds a mock for TestPDFiumEngine::OnDocumentCanceled(), to avoid
inheriting the default implementation from PDFiumEngine. This simplifies
testing loading.
Also renames the *.DocumentLoadCompletePostMessages tests to
*.OnDocumentLoadComplete, as these mainly test PdfViewWebPlugin's
OnDocumentLoadComplete() method, rather than DocumentLoadComplete()
itself.
Bug: 1323307
Change-Id: I4c91cd9562499f5096eeeeb8a3d6d884d2b0c8d4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3688326
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: K. Moon <kmoon@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1011487}
Migrates tests exercising PdfViewPluginBase::HandleSaveMessage().
Also splits TestPDFiumEngine::kSaveData into two separate constants to
distinguish between initially loaded data, and modified data to save.
Bug: 1323307
Change-Id: I6627f233eee94c56456cbbc77edeb09f28787bc0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3664682
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: K. Moon <kmoon@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1007224}
Simplifies usage of pdf::mojom::PdfService:
1. Don't handle unbound remotes; unit tests pass in a (fake) bound
remote as of r1005941.
2. Use mojo::AssociatedRemote like a smart pointer; don't use get().
3. Rename "pdf_service_remote" to "pdf_service"; the type of endpoint
usually is clear from context.
Bug: 1302059
Change-Id: Id27820c585b9fa26dc0259404d0a0f4f2ea8b2be
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3658347
Commit-Queue: K. Moon <kmoon@chromium.org>
Reviewed-by: Nigi <nigi@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1006593}
Migrates GetBackgroundColor() from PdfViewPluginBase to
PdfViewWebPlugin.
Also makes PDFEngine::Client::GetBackgroundColor() const.
Bug: 1323307
Change-Id: I7a9a707f2a3593804ff2fb2584c7895a0f4ed0ef
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3656546
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: K. Moon <kmoon@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1006585}
Migrates PdfViewPluginBase::LoadUrl() to PdfViewWebPlugin. A callback
replaces the `is_print_preview` parameter; resetting
`last_progress_sent_` is now handled by the caller.
Bug: 1322928
Change-Id: Id05012c07c89458ac6398ed3c18339bf5fbc67a2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3645902
Commit-Queue: K. Moon <kmoon@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1005465}
Injects PDFiumEngine from PdfViewWebPlugin::Client, in order to simplify
creating custom engines when testing PdfViewWebPlugin. The previous
approach of passing the engine to InitializeForTesting() doesn't support
the creation of additional engines, which Print Preview requires.
Also simplifies FakePdfViewWebPluginClient to use gMock consistently,
instead of implementing a handful of manual mocks.
Bug: 1323307
Change-Id: I9bc120f20b8f327d41e8bc983939db03793fd8e7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3653003
Reviewed-by: Nigi <nigi@chromium.org>
Commit-Queue: K. Moon <kmoon@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1004955}
Various small improvements to the PdfViewWebPlugin unit tests:
1. Adds expectations on the URL load started by Initialize().
2. Adds an expectation on WebHttpBody::ElementCount(), to detect excess
elements.
3. Improves CompleteURL() emulation by using an explicit document URL.
This better matches the actual behavior, which resolves against the
base URL of the embedding document, not PdfViewWebPlugin::GetURL().
4. Uses a valid document base URL; GURL does not accept "dummy.pdf".
5. More consistently converts blink::WebString to std::string, for
better failure messages.
Bug: 1323307
Change-Id: I4da7ba86c19ef5c131417bcf2039dceabf1e91c4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3649746
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: K. Moon <kmoon@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1003962}
Migrates PdfViewPluginBaseSubmitFormTest to work with PdfViewWebPlugin
instead of PdfViewPluginBase.
The InitializeWithEmptyUrl test replaces the EmptyDocumentUrl test, as
it's not possible to initialize a PdfViewWebPlugin with an empty
document URL.
Bug: 1323307
Change-Id: If4f0e1ba31a0575867540b370b5ef5c212c26af3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3647676
Commit-Queue: K. Moon <kmoon@chromium.org>
Reviewed-by: Nigi <nigi@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1003538}