Commit 7b6ccf5d authored by Aran Gilman's avatar Aran Gilman Committed by Commit Bot

Replace direct DOM Distiller command line checks with wrapper methods.

Bug: 982354
Change-Id: I2dd337472ee4c65b5cd39a0dfc3a166b84e3dd7a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1774308
Commit-Queue: Aran Gilman <gilmanmh@google.com>
Reviewed-by: default avatarWei-Yin Chen (陳威尹) <wychen@chromium.org>
Reviewed-by: default avatarElly Fong-Jones <ellyjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#693900}
parent 03847e79
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
#include "components/dom_distiller/content/browser/distiller_javascript_utils.h" #include "components/dom_distiller/content/browser/distiller_javascript_utils.h"
#include "components/dom_distiller/content/browser/distiller_ui_handle.h" #include "components/dom_distiller/content/browser/distiller_ui_handle.h"
#include "components/dom_distiller/content/browser/dom_distiller_viewer_source.h" #include "components/dom_distiller/content/browser/dom_distiller_viewer_source.h"
#include "components/dom_distiller/core/dom_distiller_switches.h" #include "components/dom_distiller/core/dom_distiller_features.h"
#include "components/dom_distiller/core/url_constants.h" #include "components/dom_distiller/core/url_constants.h"
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
...@@ -26,9 +26,7 @@ ...@@ -26,9 +26,7 @@
namespace dom_distiller { namespace dom_distiller {
void RegisterViewerSource(Profile* profile) { void RegisterViewerSource(Profile* profile) {
bool enabled_distiller = base::CommandLine::ForCurrentProcess()->HasSwitch( if (!dom_distiller::IsDomDistillerEnabled())
switches::kEnableDomDistiller);
if (!enabled_distiller)
return; return;
DomDistillerServiceFactory* dom_distiller_service_factory = DomDistillerServiceFactory* dom_distiller_service_factory =
......
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h" #include "chrome/common/url_constants.h"
#include "components/bookmarks/common/bookmark_pref_names.h" #include "components/bookmarks/common/bookmark_pref_names.h"
#include "components/dom_distiller/core/dom_distiller_switches.h" #include "components/dom_distiller/core/dom_distiller_features.h"
#include "components/feature_engagement/buildflags.h" #include "components/feature_engagement/buildflags.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
#include "components/sessions/core/tab_restore_service.h" #include "components/sessions/core/tab_restore_service.h"
...@@ -1016,9 +1016,8 @@ void BrowserCommandController::InitCommandState() { ...@@ -1016,9 +1016,8 @@ void BrowserCommandController::InitCommandState() {
command_updater_.UpdateCommandEnabled(IDC_UPGRADE_DIALOG, true); command_updater_.UpdateCommandEnabled(IDC_UPGRADE_DIALOG, true);
// Distill current page. // Distill current page.
command_updater_.UpdateCommandEnabled( command_updater_.UpdateCommandEnabled(IDC_DISTILL_PAGE,
IDC_DISTILL_PAGE, base::CommandLine::ForCurrentProcess()->HasSwitch( dom_distiller::IsDomDistillerEnabled());
switches::kEnableDomDistiller));
command_updater_.UpdateCommandEnabled(IDC_WINDOW_MUTE_SITE, normal_window); command_updater_.UpdateCommandEnabled(IDC_WINDOW_MUTE_SITE, normal_window);
command_updater_.UpdateCommandEnabled(IDC_WINDOW_PIN_TAB, normal_window); command_updater_.UpdateCommandEnabled(IDC_WINDOW_PIN_TAB, normal_window);
......
...@@ -84,7 +84,7 @@ ...@@ -84,7 +84,7 @@
#include "components/autofill/content/browser/content_autofill_driver_factory.h" #include "components/autofill/content/browser/content_autofill_driver_factory.h"
#include "components/autofill/core/browser/autofill_manager.h" #include "components/autofill/core/browser/autofill_manager.h"
#include "components/dom_distiller/content/browser/web_contents_main_frame_observer.h" #include "components/dom_distiller/content/browser/web_contents_main_frame_observer.h"
#include "components/dom_distiller/core/dom_distiller_switches.h" #include "components/dom_distiller/core/dom_distiller_features.h"
#include "components/download/content/factory/navigation_monitor_factory.h" #include "components/download/content/factory/navigation_monitor_factory.h"
#include "components/download/content/public/download_navigation_observer.h" #include "components/download/content/public/download_navigation_observer.h"
#include "components/history/content/browser/web_contents_top_sites_observer.h" #include "components/history/content/browser/web_contents_top_sites_observer.h"
...@@ -353,9 +353,7 @@ void TabHelpers::AttachTabHelpers(WebContents* web_contents) { ...@@ -353,9 +353,7 @@ void TabHelpers::AttachTabHelpers(WebContents* web_contents) {
printing::InitializePrinting(web_contents); printing::InitializePrinting(web_contents);
#endif #endif
bool enabled_distiller = base::CommandLine::ForCurrentProcess()->HasSwitch( if (dom_distiller::IsDomDistillerEnabled()) {
switches::kEnableDomDistiller);
if (enabled_distiller) {
dom_distiller::WebContentsMainFrameObserver::CreateForWebContents( dom_distiller::WebContentsMainFrameObserver::CreateForWebContents(
web_contents); web_contents);
} }
......
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
#include "chrome/grit/generated_resources.h" #include "chrome/grit/generated_resources.h"
#include "chrome/grit/theme_resources.h" #include "chrome/grit/theme_resources.h"
#include "components/bookmarks/common/bookmark_pref_names.h" #include "components/bookmarks/common/bookmark_pref_names.h"
#include "components/dom_distiller/core/dom_distiller_switches.h" #include "components/dom_distiller/core/dom_distiller_features.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
#include "components/signin/public/base/signin_metrics.h" #include "components/signin/public/base/signin_metrics.h"
#include "components/strings/grit/components_strings.h" #include "components/strings/grit/components_strings.h"
...@@ -795,10 +795,8 @@ void AppMenuModel::Build() { ...@@ -795,10 +795,8 @@ void AppMenuModel::Build() {
AddItem(IDC_INSTALL_PWA, *install_pwa_item_name); AddItem(IDC_INSTALL_PWA, *install_pwa_item_name);
} }
if (base::CommandLine::ForCurrentProcess()->HasSwitch( if (dom_distiller::IsDomDistillerEnabled())
switches::kEnableDomDistiller)) {
AddItemWithStringId(IDC_DISTILL_PAGE, IDS_DISTILL_PAGE); AddItemWithStringId(IDC_DISTILL_PAGE, IDS_DISTILL_PAGE);
}
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
// Always show this option if we're in tablet mode on Chrome OS. // Always show this option if we're in tablet mode on Chrome OS.
......
...@@ -724,7 +724,7 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui, ...@@ -724,7 +724,7 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
return &NewWebUI<security_interstitials::ConnectionHelpUI>; return &NewWebUI<security_interstitials::ConnectionHelpUI>;
} }
if (dom_distiller::IsEnableDomDistillerSet() && if (dom_distiller::IsDomDistillerEnabled() &&
url.host_piece() == dom_distiller::kChromeUIDomDistillerHost) { url.host_piece() == dom_distiller::kChromeUIDomDistillerHost) {
return &NewWebUI<dom_distiller::DomDistillerUi>; return &NewWebUI<dom_distiller::DomDistillerUi>;
} }
......
...@@ -76,6 +76,7 @@ ...@@ -76,6 +76,7 @@
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_headers.h" #include "components/data_reduction_proxy/core/common/data_reduction_proxy_headers.h"
#include "components/dom_distiller/content/renderer/distillability_agent.h" #include "components/dom_distiller/content/renderer/distillability_agent.h"
#include "components/dom_distiller/content/renderer/distiller_js_render_frame_observer.h" #include "components/dom_distiller/content/renderer/distiller_js_render_frame_observer.h"
#include "components/dom_distiller/core/dom_distiller_features.h"
#include "components/dom_distiller/core/dom_distiller_switches.h" #include "components/dom_distiller/core/dom_distiller_switches.h"
#include "components/dom_distiller/core/url_constants.h" #include "components/dom_distiller/core/url_constants.h"
#include "components/error_page/common/error.h" #include "components/error_page/common/error.h"
...@@ -516,8 +517,7 @@ void ChromeContentRendererClient::RenderFrameCreated( ...@@ -516,8 +517,7 @@ void ChromeContentRendererClient::RenderFrameCreated(
new dom_distiller::DistillerJsRenderFrameObserver( new dom_distiller::DistillerJsRenderFrameObserver(
render_frame, ISOLATED_WORLD_ID_CHROME_INTERNAL, registry); render_frame, ISOLATED_WORLD_ID_CHROME_INTERNAL, registry);
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); if (dom_distiller::ShouldStartDistillabilityService()) {
if (command_line->HasSwitch(switches::kEnableDistillabilityService)) {
// Create DistillabilityAgent to send distillability updates to // Create DistillabilityAgent to send distillability updates to
// DistillabilityDriver in the browser process. // DistillabilityDriver in the browser process.
new dom_distiller::DistillabilityAgent(render_frame, DCHECK_IS_ON()); new dom_distiller::DistillabilityAgent(render_frame, DCHECK_IS_ON());
...@@ -573,6 +573,7 @@ void ChromeContentRendererClient::RenderFrameCreated( ...@@ -573,6 +573,7 @@ void ChromeContentRendererClient::RenderFrameCreated(
} }
#if !defined(OS_ANDROID) #if !defined(OS_ANDROID)
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
if (command_line->HasSwitch(switches::kInstantProcess) && if (command_line->HasSwitch(switches::kInstantProcess) &&
render_frame->IsMainFrame()) { render_frame->IsMainFrame()) {
new SearchBox(render_frame); new SearchBox(render_frame);
......
...@@ -11,9 +11,14 @@ ...@@ -11,9 +11,14 @@
namespace dom_distiller { namespace dom_distiller {
bool IsEnableDomDistillerSet() { bool IsDomDistillerEnabled() {
return base::CommandLine::ForCurrentProcess()->HasSwitch( return base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableDomDistiller); switches::kEnableDomDistiller);
} }
bool ShouldStartDistillabilityService() {
return base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableDistillabilityService);
}
} // namespace dom_distiller } // namespace dom_distiller
...@@ -8,7 +8,9 @@ ...@@ -8,7 +8,9 @@
namespace dom_distiller { namespace dom_distiller {
// Returns true when flag enable-dom-distiller is set or enabled from Finch. // Returns true when flag enable-dom-distiller is set or enabled from Finch.
bool IsEnableDomDistillerSet(); bool IsDomDistillerEnabled();
bool ShouldStartDistillabilityService();
} // namespace dom_distiller } // namespace dom_distiller
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment