diff options
Diffstat (limited to 'chromium/components/dom_distiller')
11 files changed, 34 insertions, 26 deletions
diff --git a/chromium/components/dom_distiller/content/browser/distillability_driver.cc b/chromium/components/dom_distiller/content/browser/distillability_driver.cc index 824e39e0779..c8d11c4bab0 100644 --- a/chromium/components/dom_distiller/content/browser/distillability_driver.cc +++ b/chromium/components/dom_distiller/content/browser/distillability_driver.cc @@ -65,7 +65,7 @@ void DistillabilityDriver::SetIsSecureCallback( void DistillabilityDriver::OnDistillability( const DistillabilityResult& result) { -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) if (result.is_distillable) { if (!is_secure_check_ || !is_secure_check_.Run(&GetWebContents())) { DistillabilityResult not_distillable; @@ -78,7 +78,7 @@ void DistillabilityDriver::OnDistillability( return; } } -#endif // !defined(OS_ANDROID) +#endif // !BUILDFLAG(IS_ANDROID) latest_result_ = result; for (auto& observer : observers_) observer.OnResult(result); diff --git a/chromium/components/dom_distiller/content/browser/distillable_page_utils_browsertest.cc b/chromium/components/dom_distiller/content/browser/distillable_page_utils_browsertest.cc index 98738393cea..f685f2a9535 100644 --- a/chromium/components/dom_distiller/content/browser/distillable_page_utils_browsertest.cc +++ b/chromium/components/dom_distiller/content/browser/distillable_page_utils_browsertest.cc @@ -58,14 +58,14 @@ class DomDistillerDistillablePageUtilsTest : public content::ContentBrowserTest, void AddComponentsResources() { base::FilePath pak_file; base::FilePath pak_dir; -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) CHECK(base::PathService::Get(base::DIR_ANDROID_APP_DATA, &pak_dir)); pak_dir = pak_dir.Append(FILE_PATH_LITERAL("paks")); -#elif defined(OS_MAC) +#elif BUILDFLAG(IS_MAC) base::PathService::Get(base::DIR_MODULE, &pak_dir); #else base::PathService::Get(base::DIR_ASSETS, &pak_dir); -#endif // OS_ANDROID +#endif // BUILDFLAG(IS_ANDROID) pak_file = pak_dir.Append(FILE_PATH_LITERAL("components_tests_resources.pak")); ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath( diff --git a/chromium/components/dom_distiller/content/browser/distiller_page_web_contents_browsertest.cc b/chromium/components/dom_distiller/content/browser/distiller_page_web_contents_browsertest.cc index 71e440350ad..55cefa188ce 100644 --- a/chromium/components/dom_distiller/content/browser/distiller_page_web_contents_browsertest.cc +++ b/chromium/components/dom_distiller/content/browser/distiller_page_web_contents_browsertest.cc @@ -153,7 +153,7 @@ class TestDistillerPageWebContents : public DistillerPageWebContents { bool new_web_contents_created_; }; -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #define MAYBE_BasicDistillationWorks DISABLED_BasicDistillationWorks #else #define MAYBE_BasicDistillationWorks BasicDistillationWorks @@ -179,7 +179,7 @@ IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, EXPECT_EQ("", distiller_result_->pagination_info().prev_page()); } -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #define MAYBE_HandlesRelativeLinks DISABLED_HandlesRelativeLinks #else #define MAYBE_HandlesRelativeLinks HandlesRelativeLinks @@ -203,7 +203,7 @@ IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, HasSubstr("href=\"http://www.google.com/absolutelink.html\"")); } -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #define MAYBE_HandlesRelativeImages DISABLED_HandlesRelativeImages #else #define MAYBE_HandlesRelativeImages HandlesRelativeImages @@ -227,7 +227,7 @@ IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, HasSubstr("src=\"http://www.google.com/absoluteimage.png\"")); } -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #define MAYBE_HandlesRelativeVideos DISABLED_HandlesRelativeVideos #else #define MAYBE_HandlesRelativeVideos HandlesRelativeVideos @@ -256,7 +256,7 @@ IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, HasSubstr("src=\"http://www.google.com/absolute_track_fr.vtt\"")); } -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #define MAYBE_VisibilityDetection DISABLED_VisibilityDetection #else #define MAYBE_VisibilityDetection VisibilityDetection @@ -289,7 +289,7 @@ IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, } } -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #define MAYBE_UsingCurrentWebContentsWrongUrl \ DISABLED_UsingCurrentWebContentsWrongUrl #else @@ -304,7 +304,7 @@ IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, wait_for_document_loaded); } -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #define MAYBE_UsingCurrentWebContentsNotFinishedLoadingYet \ DISABLED_UsingCurrentWebContentsNotFinishedLoadingYet #else @@ -320,7 +320,7 @@ IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, wait_for_document_loaded); } -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #define MAYBE_UsingCurrentWebContentsReadyForDistillation \ DISABLED_UsingCurrentWebContentsReadyForDistillation #else @@ -368,7 +368,7 @@ void DistillerPageWebContentsTest::RunUseCurrentWebContentsTest( EXPECT_EQ("Test Page Title", distiller_result_->title()); } -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #define MAYBE_PageDestroyedBeforeFinishDistillation \ DISABLED_PageDestroyedBeforeFinishDistillation #else @@ -409,7 +409,7 @@ IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, run_loop.Run(); } -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #define MAYBE_MarkupInfo DISABLED_MarkupInfo #else #define MAYBE_MarkupInfo MarkupInfo diff --git a/chromium/components/dom_distiller/content/browser/dom_distiller_viewer_source.cc b/chromium/components/dom_distiller/content/browser/dom_distiller_viewer_source.cc index a0eef087081..adb03f9078f 100644 --- a/chromium/components/dom_distiller/content/browser/dom_distiller_viewer_source.cc +++ b/chromium/components/dom_distiller/content/browser/dom_distiller_viewer_source.cc @@ -212,13 +212,13 @@ void DomDistillerViewerSource::StartDataRequest( content::WebContents* web_contents = wc_getter.Run(); if (!web_contents) return; -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) // Don't allow loading of mixed content on Reader Mode pages. blink::web_pref::WebPreferences prefs = web_contents->GetOrCreateWebPreferences(); prefs.strict_mixed_content_checking = true; web_contents->SetWebPreferences(prefs); -#endif // !defined(OS_ANDROID) +#endif // !BUILDFLAG(IS_ANDROID) if (kViewerCssPath == path) { std::string css = viewer::GetCss(); std::move(callback).Run(base::RefCountedString::TakeString(&css)); diff --git a/chromium/components/dom_distiller/core/distiller.cc b/chromium/components/dom_distiller/core/distiller.cc index b1b4d04d4fe..2070115cf78 100644 --- a/chromium/components/dom_distiller/core/distiller.cc +++ b/chromium/components/dom_distiller/core/distiller.cc @@ -67,7 +67,7 @@ DistillerImpl::~DistillerImpl() { bool DistillerImpl::DoesFetchImages() { // Only iOS makes use of the fetched image data. -#if defined(OS_IOS) +#if BUILDFLAG(IS_IOS) return true; #else return false; diff --git a/chromium/components/dom_distiller/core/dom_distiller_service.cc b/chromium/components/dom_distiller/core/dom_distiller_service.cc index dba0f171a03..6b49b23a1ee 100644 --- a/chromium/components/dom_distiller/core/dom_distiller_service.cc +++ b/chromium/components/dom_distiller/core/dom_distiller_service.cc @@ -137,4 +137,8 @@ base::WeakPtr<DomDistillerService> DomDistillerService::GetWeakPtr() { return weak_ptr_factory_.GetWeakPtr(); } +bool DomDistillerService::HasTaskTrackerForTesting(const GURL& url) const { + return GetTaskTrackerForUrl(url); +} + } // namespace dom_distiller diff --git a/chromium/components/dom_distiller/core/dom_distiller_service.h b/chromium/components/dom_distiller/core/dom_distiller_service.h index e0efe9e464e..cdb5c8ecc28 100644 --- a/chromium/components/dom_distiller/core/dom_distiller_service.h +++ b/chromium/components/dom_distiller/core/dom_distiller_service.h @@ -87,6 +87,8 @@ class DomDistillerService : public DomDistillerServiceInterface { DistillerUIHandle* GetDistillerUIHandle() override; base::WeakPtr<DomDistillerService> GetWeakPtr(); + bool HasTaskTrackerForTesting(const GURL& url) const; + private: void CancelTask(TaskTracker* task); diff --git a/chromium/components/dom_distiller/core/experiments.cc b/chromium/components/dom_distiller/core/experiments.cc index 98cbc86b814..657332b0db7 100644 --- a/chromium/components/dom_distiller/core/experiments.cc +++ b/chromium/components/dom_distiller/core/experiments.cc @@ -6,6 +6,7 @@ #include "base/command_line.h" #include "base/metrics/field_trial.h" +#include "base/notreached.h" #include "base/strings/string_util.h" #include "components/dom_distiller/core/dom_distiller_switches.h" diff --git a/chromium/components/dom_distiller/core/page_features_unittest.cc b/chromium/components/dom_distiller/core/page_features_unittest.cc index cfd5718f055..a4378fe70de 100644 --- a/chromium/components/dom_distiller/core/page_features_unittest.cc +++ b/chromium/components/dom_distiller/core/page_features_unittest.cc @@ -42,13 +42,14 @@ absl::optional<SiteDerivedFeatures> ParseSiteDerivedFeatures( // For every feature name at index 2*N, their value is at 2*N+1. In particular // the size must be an even number. - size_t size = derived_features_json->GetList().size(); + size_t size = derived_features_json->GetListDeprecated().size(); if (size % 2 != 0) return absl::nullopt; std::vector<double> derived_features; for (size_t i = 1; i < size; i += 2) { - const base::Value& feature_value = derived_features_json->GetList()[i]; + const base::Value& feature_value = + derived_features_json->GetListDeprecated()[i]; // If the value is a bool, convert it to 1.0 or 0.0. double numerical_feature_value; if (feature_value.is_double() || feature_value.is_int()) @@ -85,7 +86,7 @@ std::vector<base::Value> ReadJsonListToValues(const std::string& file_name) { if (!parsed_content->is_list()) return {}; - return std::move(*parsed_content).TakeList(); + return std::move(*parsed_content).TakeListDeprecated(); } // This test uses input data of core features and the output of the training diff --git a/chromium/components/dom_distiller/core/viewer.cc b/chromium/components/dom_distiller/core/viewer.cc index c6ccd76af19..dda3f4ba8ad 100644 --- a/chromium/components/dom_distiller/core/viewer.cc +++ b/chromium/components/dom_distiller/core/viewer.cc @@ -56,7 +56,7 @@ const char kSansSerifCssClass[] = "sans-serif"; const char kMonospaceCssClass[] = "monospace"; std::string GetPlatformSpecificCss() { -#if defined(OS_ANDROID) || defined(OS_IOS) +#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_IOS) return ""; #else // Desktop return ui::ResourceBundle::GetSharedInstance().LoadDataResourceString( @@ -160,7 +160,7 @@ std::string ReplaceHtmlTemplateValues(const mojom::Theme theme, std::ostringstream csp; std::ostringstream css; std::ostringstream svg; -#if defined(OS_IOS) +#if BUILDFLAG(IS_IOS) // On iOS the content is inlined as there is no API to detect those requests // and return the local data once a page is loaded. css << "<style>" << viewer::GetCss() << "</style>"; @@ -185,7 +185,7 @@ std::string ReplaceHtmlTemplateValues(const mojom::Theme theme, #else css << "<link rel=\"stylesheet\" href=\"/" << kViewerCssPath << "\">"; svg << "<img src=\"/" << kViewerLoadingImagePath << "\">"; -#endif // defined(OS_IOS) +#endif // BUILDFLAG(IS_IOS) substitutions.push_back(csp.str()); // $1 substitutions.push_back(css.str()); // $2 @@ -230,7 +230,7 @@ const std::string GetErrorPageJs() { } const std::string GetSetTitleJs(std::string title) { -#if defined(OS_ANDROID) || defined(OS_IOS) +#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_IOS) base::Value suffixValue(""); #else // Desktop std::string suffix( diff --git a/chromium/components/dom_distiller/ios/distiller_page_ios.mm b/chromium/components/dom_distiller/ios/distiller_page_ios.mm index e2ecf270b70..cb6701b9da7 100644 --- a/chromium/components/dom_distiller/ios/distiller_page_ios.mm +++ b/chromium/components/dom_distiller/ios/distiller_page_ios.mm @@ -86,7 +86,7 @@ base::Value ConvertedResultFromScriptResult(const base::Value* value, } else if (value->is_list()) { std::vector<base::Value> list; - for (const base::Value& list_item : value->GetList()) { + for (const base::Value& list_item : value->GetListDeprecated()) { base::Value converted_item = ConvertedResultFromScriptResult(&list_item, max_depth - 1); if (converted_item.type() == base::Value::Type::NONE) { |