0

Create //pdf/loader

Moves loading-related logic to a new //pdf/loader directory.

Also removes the now-empty //pdf/ppapi_migration directory.

Bug: 1322928
Change-Id: I956d14b66466380281836e6df6cef737ca7db7dc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3707509
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: K. Moon <kmoon@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1015081}
This commit is contained in:
K. Moon
2022-06-16 20:34:48 +00:00
committed by Chromium LUCI CQ
parent bc1cc77d65
commit efbad4c96e
32 changed files with 149 additions and 119 deletions

@ -8,6 +8,6 @@ specific_include_rules = {
"+chrome/browser/ui/views/location_bar/zoom_bubble_view.h",
],
"pdf_find_request_manager_browsertest\.cc": [
"+pdf/document_loader_impl.h",
"+pdf/loader/document_loader_impl.h",
],
}

@ -29,7 +29,7 @@
#include "content/public/test/test_navigation_observer.h"
#include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/controllable_http_response.h"
#include "pdf/document_loader_impl.h"
#include "pdf/loader/document_loader_impl.h"
#include "pdf/pdf_features.h"
#include "third_party/blink/public/mojom/frame/find_in_page.mojom.h"

@ -2392,7 +2392,7 @@ if (!is_android) {
]
deps += [
"//pdf:features",
"//pdf:internal",
"//pdf/loader",
]
}
}

@ -59,25 +59,15 @@ if (enable_pdf) {
}
source_set("internal") {
visibility = [
":*",
# TODO(crbug.com/1158929): Eliminate chrome_find_request_manager_browsertest.cc's dependence
# on document_loader_impl.h.
"//chrome/test:browser_tests${exec_target_suffix}",
]
visibility = [ ":*" ]
sources = [
"accessibility.cc",
"accessibility.h",
"chunk_stream.h",
"document_attachment_info.cc",
"document_attachment_info.h",
"document_layout.cc",
"document_layout.h",
"document_loader.h",
"document_loader_impl.cc",
"document_loader_impl.h",
"document_metadata.cc",
"document_metadata.h",
"draw_utils/coordinates.cc",
@ -131,17 +121,12 @@ if (enable_pdf) {
"pdfium/pdfium_unsupported_features.h",
"preview_mode_client.cc",
"preview_mode_client.h",
"range_set.cc",
"range_set.h",
"ui/document_properties.cc",
"ui/document_properties.h",
"ui/file_name.cc",
"ui/file_name.h",
"ui/thumbnail.cc",
"ui/thumbnail.h",
"url_loader_wrapper.h",
"url_loader_wrapper_impl.cc",
"url_loader_wrapper_impl.h",
]
public_configs = [ ":pdfium_includes" ]
@ -159,13 +144,12 @@ if (enable_pdf) {
":buildflags",
":content_restriction",
":features",
":ppapi_migration",
"//base",
"//base:i18n",
"//build:chromeos_buildflags",
"//components/strings",
"//gin",
"//net",
"//pdf/loader",
"//printing",
"//third_party/blink/public:blink_headers",
"//third_party/blink/public/common:headers",
@ -204,7 +188,6 @@ if (enable_pdf) {
":content_restriction",
":internal",
":pdf",
":ppapi_migration",
"//third_party/blink/public/common:headers",
"//third_party/pdfium",
"//ui/base",
@ -242,25 +225,6 @@ if (enable_pdf) {
]
}
source_set("ppapi_migration") {
visibility = [ ":*" ]
sources = [
"ppapi_migration/result_codes.h",
"ppapi_migration/url_loader.cc",
"ppapi_migration/url_loader.h",
]
configs += [ ":strict" ]
deps = [
"//base",
"//net",
"//third_party/blink/public:blink",
"//url",
]
}
static_library("pdf_view_web_plugin") {
# The PDF viewer relies on plugin infrastructure, which is currently tied to
# PPAPI support. Fuchsia does not have plugins enabled and is in a state
@ -291,11 +255,12 @@ if (enable_pdf) {
":buildflags",
":content_restriction",
":internal",
":ppapi_migration",
"//base",
"//base:i18n",
"//cc/paint",
"//gin",
"//net",
"//pdf/loader",
"//printing",
"//services/network/public/mojom:url_loader_base",
"//skia",
@ -304,6 +269,7 @@ if (enable_pdf) {
"//ui/base/cursor",
"//ui/base/cursor/mojom:cursor_type",
"//ui/events/blink",
"//ui/gfx/range",
"//v8",
]
}
@ -326,9 +292,9 @@ if (enable_pdf) {
deps = [
":internal",
":ppapi_migration",
"//base",
"//cc:test_support",
"//pdf/loader",
"//testing/gmock",
"//testing/gtest",
"//third_party/blink/public/common:headers",
@ -355,9 +321,7 @@ if (enable_pdf) {
testonly = true
sources = [
"chunk_stream_unittest.cc",
"document_layout_unittest.cc",
"document_loader_impl_unittest.cc",
"draw_utils/coordinates_unittest.cc",
"file_extension_unittest.cc",
"page_orientation_unittest.cc",
@ -376,8 +340,6 @@ if (enable_pdf) {
"pdfium/pdfium_print_unittest.cc",
"pdfium/pdfium_test_base.cc",
"pdfium/pdfium_test_base.h",
"ppapi_migration/url_loader_unittest.cc",
"range_set_unittest.cc",
"test/run_all_unittests.cc",
"ui/document_properties_unittest.cc",
"ui/file_name_unittest.cc",
@ -396,7 +358,6 @@ if (enable_pdf) {
":pdf",
":pdf_test_utils",
":pdf_view_web_plugin",
":ppapi_migration",
"//base",
"//base:i18n",
"//base/test:test_support",
@ -404,6 +365,9 @@ if (enable_pdf) {
"//gin",
"//mojo/core/embedder",
"//mojo/public/cpp/bindings",
"//net",
"//pdf/loader",
"//pdf/loader:unit_tests",
"//printing",
"//skia",
"//testing/gmock",

80
pdf/loader/BUILD.gn Normal file

@ -0,0 +1,80 @@
# Copyright 2022 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//pdf/features.gni")
import("//testing/test.gni")
assert(enable_pdf)
source_set("loader") {
visibility = [
# TODO(crbug.com/1158929): Eliminate
# chrome_find_request_manager_browsertest.cc's dependence on
# document_loader_impl.h.
"//chrome/test:browser_tests${exec_target_suffix}",
"//pdf/*",
]
friend = [
":unit_tests",
"//pdf:pdf_test_utils",
]
sources = [
"chunk_stream.h",
"document_loader_impl.cc",
"range_set.cc",
"range_set.h",
"url_loader.cc",
"url_loader_wrapper.h",
"url_loader_wrapper_impl.cc",
]
configs += [ "//pdf:strict" ]
public = [
"document_loader.h",
"document_loader_impl.h",
"result_codes.h",
"url_loader.h",
"url_loader_wrapper_impl.h",
]
deps = [
"//base",
"//net",
"//pdf:features",
"//third_party/blink/public:blink",
"//ui/gfx/range",
"//url",
]
}
source_set("unit_tests") {
testonly = true
visibility = [ "//pdf:pdf_unittests${exec_target_suffix}" ]
sources = [
"chunk_stream_unittest.cc",
"document_loader_impl_unittest.cc",
"range_set_unittest.cc",
"url_loader_unittest.cc",
]
configs += [ "//pdf:strict" ]
deps = [
":loader",
"//base",
"//base/test:test_support",
"//net",
"//pdf:features",
"//testing/gmock",
"//testing/gtest",
"//third_party/blink/public:blink",
"//ui/gfx/range",
"//url",
]
}

@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef PDF_CHUNK_STREAM_H_
#define PDF_CHUNK_STREAM_H_
#ifndef PDF_LOADER_CHUNK_STREAM_H_
#define PDF_LOADER_CHUNK_STREAM_H_
#include <stddef.h>
#include <string.h>
@ -14,7 +14,7 @@
#include <utility>
#include <vector>
#include "pdf/range_set.h"
#include "pdf/loader/range_set.h"
namespace chrome_pdf {
@ -121,4 +121,4 @@ class ChunkStream {
} // namespace chrome_pdf
#endif // PDF_CHUNK_STREAM_H_
#endif // PDF_LOADER_CHUNK_STREAM_H_

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "pdf/chunk_stream.h"
#include "pdf/loader/chunk_stream.h"
#include <array>
#include <memory>

@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef PDF_DOCUMENT_LOADER_H_
#define PDF_DOCUMENT_LOADER_H_
#ifndef PDF_LOADER_DOCUMENT_LOADER_H_
#define PDF_LOADER_DOCUMENT_LOADER_H_
#include <stddef.h>
#include <stdint.h>
@ -57,4 +57,4 @@ class DocumentLoader {
} // namespace chrome_pdf
#endif // PDF_DOCUMENT_LOADER_H_
#endif // PDF_LOADER_DOCUMENT_LOADER_H_

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "pdf/document_loader_impl.h"
#include "pdf/loader/document_loader_impl.h"
#include <stddef.h>
#include <stdint.h>
@ -16,9 +16,9 @@
#include "base/feature_list.h"
#include "base/numerics/safe_math.h"
#include "base/strings/string_util.h"
#include "pdf/loader/result_codes.h"
#include "pdf/loader/url_loader_wrapper.h"
#include "pdf/pdf_features.h"
#include "pdf/ppapi_migration/result_codes.h"
#include "pdf/url_loader_wrapper.h"
#include "ui/gfx/range/range.h"
namespace chrome_pdf {

@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef PDF_DOCUMENT_LOADER_IMPL_H_
#define PDF_DOCUMENT_LOADER_IMPL_H_
#ifndef PDF_LOADER_DOCUMENT_LOADER_IMPL_H_
#define PDF_LOADER_DOCUMENT_LOADER_IMPL_H_
#include <stdint.h>
@ -12,8 +12,8 @@
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "pdf/chunk_stream.h"
#include "pdf/document_loader.h"
#include "pdf/loader/chunk_stream.h"
#include "pdf/loader/document_loader.h"
namespace chrome_pdf {
@ -99,4 +99,4 @@ class DocumentLoaderImpl : public DocumentLoader {
} // namespace chrome_pdf
#endif // PDF_DOCUMENT_LOADER_IMPL_H_
#endif // PDF_LOADER_DOCUMENT_LOADER_IMPL_H_

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "pdf/document_loader_impl.h"
#include "pdf/loader/document_loader_impl.h"
#include <algorithm>
#include <memory>
@ -14,8 +14,8 @@
#include "base/check.h"
#include "base/memory/raw_ptr.h"
#include "base/test/scoped_feature_list.h"
#include "pdf/loader/url_loader_wrapper.h"
#include "pdf/pdf_features.h"
#include "pdf/url_loader_wrapper.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/range/range.h"

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "pdf/range_set.h"
#include "pdf/loader/range_set.h"
#include <algorithm>
#include <sstream>

@ -4,8 +4,8 @@
// Defines a set of geometric ranges, and standard operations on it.
#ifndef PDF_RANGE_SET_H_
#define PDF_RANGE_SET_H_
#ifndef PDF_LOADER_RANGE_SET_H_
#define PDF_LOADER_RANGE_SET_H_
#include <ostream>
#include <set>
@ -74,4 +74,4 @@ class RangeSet {
std::ostream& operator<<(std::ostream& os,
const chrome_pdf::RangeSet& range_set);
#endif // PDF_RANGE_SET_H_
#endif // PDF_LOADER_RANGE_SET_H_

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "pdf/range_set.h"
#include "pdf/loader/range_set.h"
#include "testing/gtest/include/gtest/gtest.h"

@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef PDF_PPAPI_MIGRATION_RESULT_CODES_H_
#define PDF_PPAPI_MIGRATION_RESULT_CODES_H_
#ifndef PDF_LOADER_RESULT_CODES_H_
#define PDF_LOADER_RESULT_CODES_H_
namespace chrome_pdf {
@ -11,22 +11,13 @@ namespace chrome_pdf {
// this enum should live, whether it should become an enum class, and what
// values it should contain.
enum Result {
// Must match `PP_OK`.
kSuccess = 0,
// Must match `PP_ERROR_FAILED`.
kErrorFailed = -2,
// Must match `PP_ERROR_ABORTED`.
kErrorAborted = -3,
// Must match `PP_ERROR_BADARGUMENT`.
kErrorBadArgument = -4,
// Must match `PP_ERROR_NOACCESS`.
kErrorNoAccess = -7,
};
} // namespace chrome_pdf
#endif // PDF_PPAPI_MIGRATION_RESULT_CODES_H_
#endif // PDF_LOADER_RESULT_CODES_H_

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "pdf/ppapi_migration/url_loader.h"
#include "pdf/loader/url_loader.h"
#include <stddef.h>
#include <stdint.h>
@ -19,7 +19,7 @@
#include "net/base/net_errors.h"
#include "net/cookies/site_for_cookies.h"
#include "net/http/http_util.h"
#include "pdf/ppapi_migration/result_codes.h"
#include "pdf/loader/result_codes.h"
#include "third_party/blink/public/mojom/fetch/fetch_api_request.mojom-shared.h"
#include "third_party/blink/public/platform/web_data.h"
#include "third_party/blink/public/platform/web_http_body.h"

@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef PDF_PPAPI_MIGRATION_URL_LOADER_H_
#define PDF_PPAPI_MIGRATION_URL_LOADER_H_
#ifndef PDF_LOADER_URL_LOADER_H_
#define PDF_LOADER_URL_LOADER_H_
#include <stddef.h>
#include <stdint.h>
@ -227,4 +227,4 @@ class BlinkUrlLoader final : public UrlLoader,
} // namespace chrome_pdf
#endif // PDF_PPAPI_MIGRATION_URL_LOADER_H_
#endif // PDF_LOADER_URL_LOADER_H_

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "pdf/ppapi_migration/url_loader.h"
#include "pdf/loader/url_loader.h"
#include <stddef.h>
@ -22,7 +22,7 @@
#include "base/test/mock_callback.h"
#include "net/base/net_errors.h"
#include "net/cookies/site_for_cookies.h"
#include "pdf/ppapi_migration/result_codes.h"
#include "pdf/loader/result_codes.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/mojom/fetch/fetch_api_request.mojom-shared.h"

@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef PDF_URL_LOADER_WRAPPER_H_
#define PDF_URL_LOADER_WRAPPER_H_
#ifndef PDF_LOADER_URL_LOADER_WRAPPER_H_
#define PDF_LOADER_URL_LOADER_WRAPPER_H_
#include <stdint.h>
@ -62,4 +62,4 @@ class URLLoaderWrapper {
} // namespace chrome_pdf
#endif // PDF_URL_LOADER_WRAPPER_H_
#endif // PDF_LOADER_URL_LOADER_WRAPPER_H_

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "pdf/url_loader_wrapper_impl.h"
#include "pdf/loader/url_loader_wrapper_impl.h"
#include <stddef.h>
#include <stdint.h>
@ -21,7 +21,7 @@
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "net/http/http_util.h"
#include "pdf/ppapi_migration/url_loader.h"
#include "pdf/loader/url_loader.h"
#include "ui/gfx/range/range.h"
namespace chrome_pdf {

@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef PDF_URL_LOADER_WRAPPER_IMPL_H_
#define PDF_URL_LOADER_WRAPPER_IMPL_H_
#ifndef PDF_LOADER_URL_LOADER_WRAPPER_IMPL_H_
#define PDF_LOADER_URL_LOADER_WRAPPER_IMPL_H_
#include <stdint.h>
@ -14,7 +14,7 @@
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/timer/timer.h"
#include "pdf/url_loader_wrapper.h"
#include "pdf/loader/url_loader_wrapper.h"
#include "ui/gfx/range/range.h"
namespace chrome_pdf {
@ -76,4 +76,4 @@ class URLLoaderWrapperImpl : public URLLoaderWrapper {
} // namespace chrome_pdf
#endif // PDF_URL_LOADER_WRAPPER_IMPL_H_
#endif // PDF_LOADER_URL_LOADER_WRAPPER_IMPL_H_

@ -47,6 +47,8 @@
#include "pdf/buildflags.h"
#include "pdf/content_restriction.h"
#include "pdf/document_layout.h"
#include "pdf/loader/result_codes.h"
#include "pdf/loader/url_loader.h"
#include "pdf/metrics_handler.h"
#include "pdf/mojom/pdf.mojom.h"
#include "pdf/paint_ready_rect.h"
@ -56,8 +58,6 @@
#include "pdf/pdf_init.h"
#include "pdf/pdfium/pdfium_engine.h"
#include "pdf/post_message_receiver.h"
#include "pdf/ppapi_migration/result_codes.h"
#include "pdf/ppapi_migration/url_loader.h"
#include "pdf/ui/document_properties.h"
#include "pdf/ui/file_name.h"
#include "printing/metafile_skia.h"

@ -22,13 +22,13 @@
#include "cc/paint/paint_image.h"
#include "mojo/public/cpp/bindings/associated_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "pdf/loader/url_loader.h"
#include "pdf/mojom/pdf.mojom.h"
#include "pdf/pdf_accessibility_action_handler.h"
#include "pdf/pdf_engine.h"
#include "pdf/pdf_view_plugin_base.h"
#include "pdf/pdfium/pdfium_form_filler.h"
#include "pdf/post_message_receiver.h"
#include "pdf/ppapi_migration/url_loader.h"
#include "pdf/preview_mode_client.h"
#include "pdf/v8_value_converter.h"
#include "third_party/blink/public/platform/web_string.h"

@ -8,7 +8,7 @@
#include "base/check.h"
#include "base/memory/raw_ptr.h"
#include "pdf/document_loader.h"
#include "pdf/loader/document_loader.h"
namespace chrome_pdf {

@ -37,9 +37,11 @@
#include "gin/public/isolate_holder.h"
#include "gin/public/v8_platform.h"
#include "pdf/accessibility_structs.h"
#include "pdf/document_loader_impl.h"
#include "pdf/draw_utils/coordinates.h"
#include "pdf/draw_utils/shadow.h"
#include "pdf/loader/document_loader_impl.h"
#include "pdf/loader/url_loader.h"
#include "pdf/loader/url_loader_wrapper_impl.h"
#include "pdf/pdf_features.h"
#include "pdf/pdf_transform.h"
#include "pdf/pdf_utils/dates.h"
@ -48,8 +50,6 @@
#include "pdf/pdfium/pdfium_mem_buffer_file_write.h"
#include "pdf/pdfium/pdfium_permissions.h"
#include "pdf/pdfium/pdfium_unsupported_features.h"
#include "pdf/ppapi_migration/url_loader.h"
#include "pdf/url_loader_wrapper_impl.h"
#include "printing/mojom/print.mojom-shared.h"
#include "printing/units.h"
#include "third_party/blink/public/common/input/web_input_event.h"

@ -22,8 +22,8 @@
#include "base/values.h"
#include "pdf/document_attachment_info.h"
#include "pdf/document_layout.h"
#include "pdf/document_loader.h"
#include "pdf/document_metadata.h"
#include "pdf/loader/document_loader.h"
#include "pdf/pdf_engine.h"
#include "pdf/pdfium/pdfium_form_filler.h"
#include "pdf/pdfium/pdfium_page.h"

@ -13,9 +13,9 @@
#include "base/check_op.h"
#include "base/memory/scoped_refptr.h"
#include "build/build_config.h"
#include "pdf/loader/url_loader.h"
#include "pdf/pdfium/pdfium_engine.h"
#include "pdf/pdfium/pdfium_form_filler.h"
#include "pdf/ppapi_migration/url_loader.h"
#include "pdf/test/test_client.h"
#include "pdf/test/test_document_loader.h"
#include "testing/gtest/include/gtest/gtest.h"

@ -1,5 +0,0 @@
# PPAPI migration utilities
This directory contains utilities for bridging from legacy APIs during the PDF
viewer's [migration from Pepper](https://crbug.com/702993). The utilities should
be designed for easy removal once the migration is complete.

@ -14,7 +14,7 @@
#include "base/notreached.h"
#include "base/time/time.h"
#include "pdf/document_layout.h"
#include "pdf/ppapi_migration/url_loader.h"
#include "pdf/loader/url_loader.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/base/cursor/mojom/cursor_type.mojom-shared.h"

@ -8,7 +8,7 @@
#include "base/time/time.h"
#include "pdf/document_layout.h"
#include "pdf/ppapi_migration/url_loader.h"
#include "pdf/loader/url_loader.h"
#include "third_party/skia/include/core/SkColor.h"
namespace chrome_pdf {

@ -11,8 +11,8 @@
#include "base/files/file_util.h"
#include "base/notreached.h"
#include "base/path_service.h"
#include "pdf/range_set.h"
#include "pdf/url_loader_wrapper.h"
#include "pdf/loader/range_set.h"
#include "pdf/loader/url_loader_wrapper.h"
#include "ui/gfx/range/range.h"
namespace chrome_pdf {

@ -12,8 +12,8 @@
#include "base/files/file_path.h"
#include "base/memory/raw_ptr.h"
#include "pdf/document_loader.h"
#include "pdf/range_set.h"
#include "pdf/loader/document_loader.h"
#include "pdf/loader/range_set.h"
namespace chrome_pdf {