Commit 9dc67ba7 authored by Miyoung Shin's avatar Miyoung Shin Committed by Commit Bot

Convert DistillerJavaScriptService client to use BrowserInterfaceBroker

This change converts DistillerJavaScriptService mojom interface
client in components to use BrowserInterfaceBroker.
DomDistillerService instead of DomDistillerViewerSource owns
DistillerUIHandle instance and a static helper function is used
to register its binder.

Bug: 936482
Change-Id: Iebc814be8118a10a756a05c9bb0115ec9add9805
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1892631Reviewed-by: default avatarWei-Yin Chen (陳威尹) <wychen@chromium.org>
Reviewed-by: default avatarSylvain Defresne <sdefresne@chromium.org>
Reviewed-by: default avatarTommy Nyquist <nyquist@chromium.org>
Reviewed-by: default avatarOksana Zhuravlova <oksamyt@chromium.org>
Reviewed-by: default avatarSam McNally <sammc@chromium.org>
Commit-Queue: Miyoung Shin <myid.shin@igalia.com>
Cr-Commit-Position: refs/heads/master@{#713815}
parent 4abc8a5c
...@@ -421,7 +421,6 @@ source_set("chrome_content_browser_overlay_manifest") { ...@@ -421,7 +421,6 @@ source_set("chrome_content_browser_overlay_manifest") {
"//components/autofill/content/common/mojom", "//components/autofill/content/common/mojom",
"//components/contextual_search/content/common/mojom", "//components/contextual_search/content/common/mojom",
"//components/data_reduction_proxy/core/common:interfaces", "//components/data_reduction_proxy/core/common:interfaces",
"//components/dom_distiller/content/common/mojom",
"//components/metrics/public/mojom:call_stack_mojo_bindings", "//components/metrics/public/mojom:call_stack_mojo_bindings",
"//components/page_load_metrics/common:page_load_metrics_mojom", "//components/page_load_metrics/common:page_load_metrics_mojom",
"//components/rappor/public/mojom", "//components/rappor/public/mojom",
......
...@@ -56,7 +56,6 @@ specific_include_rules = { ...@@ -56,7 +56,6 @@ specific_include_rules = {
"+components/chromeos_camera/common", "+components/chromeos_camera/common",
"+components/contextual_search/content/common", "+components/contextual_search/content/common",
"+components/data_reduction_proxy/core/common", "+components/data_reduction_proxy/core/common",
"+components/dom_distiller/content/common",
"+components/metrics/public", "+components/metrics/public",
"+components/rappor/public", "+components/rappor/public",
"+components/translate/content/common", "+components/translate/content/common",
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#include "components/autofill/content/common/mojom/autofill_driver.mojom.h" #include "components/autofill/content/common/mojom/autofill_driver.mojom.h"
#include "components/contextual_search/content/common/mojom/contextual_search_js_api_service.mojom.h" #include "components/contextual_search/content/common/mojom/contextual_search_js_api_service.mojom.h"
#include "components/data_reduction_proxy/core/common/data_reduction_proxy.mojom.h" #include "components/data_reduction_proxy/core/common/data_reduction_proxy.mojom.h"
#include "components/dom_distiller/content/common/mojom/distiller_javascript_service.mojom.h"
#include "components/metrics/public/mojom/call_stack_profile_collector.mojom.h" #include "components/metrics/public/mojom/call_stack_profile_collector.mojom.h"
#include "components/page_load_metrics/common/page_load_metrics.mojom.h" #include "components/page_load_metrics/common/page_load_metrics.mojom.h"
#include "components/rappor/public/mojom/rappor_recorder.mojom.h" #include "components/rappor/public/mojom/rappor_recorder.mojom.h"
...@@ -157,7 +156,6 @@ const service_manager::Manifest& GetChromeContentBrowserOverlayManifest() { ...@@ -157,7 +156,6 @@ const service_manager::Manifest& GetChromeContentBrowserOverlayManifest() {
cros::mojom::CameraAppDeviceProvider, cros::mojom::CameraAppDeviceProvider,
#endif #endif
contextual_search::mojom::ContextualSearchJsApiService, contextual_search::mojom::ContextualSearchJsApiService,
dom_distiller::mojom::DistillerJavaScriptService,
#if BUILDFLAG(ENABLE_EXTENSIONS) #if BUILDFLAG(ENABLE_EXTENSIONS)
extensions::KeepAlive, extensions::KeepAlive,
extensions::mime_handler::BeforeUnloadControl, extensions::mime_handler::BeforeUnloadControl,
......
...@@ -1981,6 +1981,7 @@ jumbo_static_library("browser") { ...@@ -1981,6 +1981,7 @@ jumbo_static_library("browser") {
"//components/data_use_measurement/core:ascriber", "//components/data_use_measurement/core:ascriber",
"//components/device_event_log", "//components/device_event_log",
"//components/dom_distiller/content/browser", "//components/dom_distiller/content/browser",
"//components/dom_distiller/content/common/mojom",
"//components/domain_reliability", "//components/domain_reliability",
"//components/download/content/factory", "//components/download/content/factory",
"//components/download/database", "//components/download/database",
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "chrome/android/chrome_jni_headers/DomDistillerUIUtils_jni.h" #include "chrome/android/chrome_jni_headers/DomDistillerUIUtils_jni.h"
#include "chrome/browser/ui/android/view_android_helper.h" #include "chrome/browser/ui/android/view_android_helper.h"
#include "components/dom_distiller/core/url_utils.h" #include "components/dom_distiller/core/url_utils.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "ui/android/window_android.h" #include "ui/android/window_android.h"
#include "url/gurl.h" #include "url/gurl.h"
...@@ -18,10 +19,12 @@ namespace dom_distiller { ...@@ -18,10 +19,12 @@ namespace dom_distiller {
namespace android { namespace android {
// static void DistillerUIHandleAndroid::OpenSettings() {
void DistillerUIHandleAndroid::OpenSettings(
content::WebContents* web_contents) {
JNIEnv* env = base::android::AttachCurrentThread(); JNIEnv* env = base::android::AttachCurrentThread();
DCHECK(render_frame_host_);
content::WebContents* web_contents =
content::WebContents::FromRenderFrameHost(render_frame_host_);
Java_DomDistillerUIUtils_openSettings(env, Java_DomDistillerUIUtils_openSettings(env,
web_contents->GetJavaWebContents()); web_contents->GetJavaWebContents());
} }
......
...@@ -6,8 +6,11 @@ ...@@ -6,8 +6,11 @@
#define CHROME_BROWSER_ANDROID_DOM_DISTILLER_DISTILLER_UI_HANDLE_ANDROID_H_ #define CHROME_BROWSER_ANDROID_DOM_DISTILLER_DISTILLER_UI_HANDLE_ANDROID_H_
#include "base/macros.h" #include "base/macros.h"
#include "components/dom_distiller/content/browser/distiller_ui_handle.h" #include "components/dom_distiller/core/distiller_ui_handle.h"
#include "content/public/browser/web_contents.h"
namespace content {
class RenderFrameHost;
}
namespace dom_distiller { namespace dom_distiller {
...@@ -18,9 +21,13 @@ class DistillerUIHandleAndroid : public DistillerUIHandle { ...@@ -18,9 +21,13 @@ class DistillerUIHandleAndroid : public DistillerUIHandle {
DistillerUIHandleAndroid() {} DistillerUIHandleAndroid() {}
~DistillerUIHandleAndroid() override {} ~DistillerUIHandleAndroid() override {}
void OpenSettings(content::WebContents* web_contents) override; void set_render_frame_host(content::RenderFrameHost* host) {
render_frame_host_ = host;
}
void OpenSettings() override;
private: private:
content::RenderFrameHost* render_frame_host_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(DistillerUIHandleAndroid); DISALLOW_COPY_AND_ASSIGN(DistillerUIHandleAndroid);
}; };
......
...@@ -11,13 +11,17 @@ ...@@ -11,13 +11,17 @@
#include "chrome/browser/accessibility/accessibility_labels_service.h" #include "chrome/browser/accessibility/accessibility_labels_service.h"
#include "chrome/browser/accessibility/accessibility_labels_service_factory.h" #include "chrome/browser/accessibility/accessibility_labels_service_factory.h"
#include "chrome/browser/content_settings/content_settings_manager_impl.h" #include "chrome/browser/content_settings/content_settings_manager_impl.h"
#include "chrome/browser/dom_distiller/dom_distiller_service_factory.h"
#include "chrome/browser/navigation_predictor/navigation_predictor.h" #include "chrome/browser/navigation_predictor/navigation_predictor.h"
#include "chrome/browser/prerender/prerender_contents.h" #include "chrome/browser/prerender/prerender_contents.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ssl/insecure_sensitive_input_driver_factory.h" #include "chrome/browser/ssl/insecure_sensitive_input_driver_factory.h"
#include "chrome/common/prerender.mojom.h" #include "chrome/common/prerender.mojom.h"
#include "components/dom_distiller/content/browser/distillability_driver.h" #include "components/dom_distiller/content/browser/distillability_driver.h"
#include "components/dom_distiller/content/browser/distiller_javascript_service_impl.h"
#include "components/dom_distiller/content/common/mojom/distillability_service.mojom.h" #include "components/dom_distiller/content/common/mojom/distillability_service.mojom.h"
#include "components/dom_distiller/content/common/mojom/distiller_javascript_service.mojom.h"
#include "components/dom_distiller/core/dom_distiller_service.h"
#include "content/public/browser/browser_context.h" #include "content/public/browser/browser_context.h"
#include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h" #include "content/public/browser/render_process_host.h"
...@@ -37,6 +41,7 @@ ...@@ -37,6 +41,7 @@
#endif // BUILDFLAG(ENABLE_UNHANDLED_TAP) #endif // BUILDFLAG(ENABLE_UNHANDLED_TAP)
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
#include "chrome/browser/android/dom_distiller/distiller_ui_handle_android.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "services/service_manager/public/cpp/interface_provider.h" #include "services/service_manager/public/cpp/interface_provider.h"
#include "third_party/blink/public/mojom/installedapp/installed_app_provider.mojom.h" #include "third_party/blink/public/mojom/installedapp/installed_app_provider.mojom.h"
...@@ -97,6 +102,23 @@ void BindDistillabilityService( ...@@ -97,6 +102,23 @@ void BindDistillabilityService(
driver->CreateDistillabilityService(std::move(receiver)); driver->CreateDistillabilityService(std::move(receiver));
} }
void BindDistillerJavaScriptService(
content::RenderFrameHost* const frame_host,
mojo::PendingReceiver<dom_distiller::mojom::DistillerJavaScriptService>
receiver) {
dom_distiller::DomDistillerService* dom_distiller_service =
dom_distiller::DomDistillerServiceFactory::GetForBrowserContext(
content::WebContents::FromRenderFrameHost(frame_host)
->GetBrowserContext());
auto* distiller_ui_handle = dom_distiller_service->GetDistillerUIHandle();
#if defined(OS_ANDROID)
static_cast<dom_distiller::android::DistillerUIHandleAndroid*>(
distiller_ui_handle)
->set_render_frame_host(frame_host);
#endif
CreateDistillerJavaScriptService(distiller_ui_handle, std::move(receiver));
}
void BindPrerenderCanceler( void BindPrerenderCanceler(
content::RenderFrameHost* frame_host, content::RenderFrameHost* frame_host,
mojo::PendingReceiver<mojom::PrerenderCanceler> receiver) { mojo::PendingReceiver<mojom::PrerenderCanceler> receiver) {
...@@ -157,6 +179,9 @@ void PopulateChromeFrameBinders( ...@@ -157,6 +179,9 @@ void PopulateChromeFrameBinders(
map->Add<dom_distiller::mojom::DistillabilityService>( map->Add<dom_distiller::mojom::DistillabilityService>(
base::BindRepeating(&BindDistillabilityService)); base::BindRepeating(&BindDistillabilityService));
map->Add<dom_distiller::mojom::DistillerJavaScriptService>(
base::BindRepeating(&BindDistillerJavaScriptService));
map->Add<mojom::PrerenderCanceler>( map->Add<mojom::PrerenderCanceler>(
base::BindRepeating(&BindPrerenderCanceler)); base::BindRepeating(&BindPrerenderCanceler));
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "base/sequenced_task_runner.h" #include "base/sequenced_task_runner.h"
#include "base/task/post_task.h" #include "base/task/post_task.h"
#include "build/build_config.h"
#include "chrome/browser/profiles/incognito_helpers.h" #include "chrome/browser/profiles/incognito_helpers.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "components/dom_distiller/content/browser/distiller_page_web_contents.h" #include "components/dom_distiller/content/browser/distiller_page_web_contents.h"
...@@ -18,15 +19,21 @@ ...@@ -18,15 +19,21 @@
#include "content/public/browser/storage_partition.h" #include "content/public/browser/storage_partition.h"
#include "services/network/public/cpp/shared_url_loader_factory.h" #include "services/network/public/cpp/shared_url_loader_factory.h"
#if defined(OS_ANDROID)
#include "chrome/browser/android/dom_distiller/distiller_ui_handle_android.h"
#endif // defined(OS_ANDROID)
namespace dom_distiller { namespace dom_distiller {
DomDistillerContextKeyedService::DomDistillerContextKeyedService( DomDistillerContextKeyedService::DomDistillerContextKeyedService(
std::unique_ptr<DistillerFactory> distiller_factory, std::unique_ptr<DistillerFactory> distiller_factory,
std::unique_ptr<DistillerPageFactory> distiller_page_factory, std::unique_ptr<DistillerPageFactory> distiller_page_factory,
std::unique_ptr<DistilledPagePrefs> distilled_page_prefs) std::unique_ptr<DistilledPagePrefs> distilled_page_prefs,
std::unique_ptr<DistillerUIHandle> distiller_ui_handle)
: DomDistillerService(std::move(distiller_factory), : DomDistillerService(std::move(distiller_factory),
std::move(distiller_page_factory), std::move(distiller_page_factory),
std::move(distilled_page_prefs)) {} std::move(distilled_page_prefs),
std::move(distiller_ui_handle)) {}
// static // static
DomDistillerServiceFactory* DomDistillerServiceFactory::GetInstance() { DomDistillerServiceFactory* DomDistillerServiceFactory::GetInstance() {
...@@ -80,11 +87,17 @@ KeyedService* DomDistillerServiceFactory::BuildServiceInstanceFor( ...@@ -80,11 +87,17 @@ KeyedService* DomDistillerServiceFactory::BuildServiceInstanceFor(
std::move(distiller_url_fetcher_factory), options)); std::move(distiller_url_fetcher_factory), options));
std::unique_ptr<DistilledPagePrefs> distilled_page_prefs( std::unique_ptr<DistilledPagePrefs> distilled_page_prefs(
new DistilledPagePrefs(profile->GetPrefs())); new DistilledPagePrefs(profile->GetPrefs()));
std::unique_ptr<DistillerUIHandle> distiller_ui_handle;
#if defined(OS_ANDROID)
distiller_ui_handle =
std::make_unique<dom_distiller::android::DistillerUIHandleAndroid>();
#endif // defined(OS_ANDROID)
DomDistillerContextKeyedService* service = DomDistillerContextKeyedService* service =
new DomDistillerContextKeyedService(std::move(distiller_factory), new DomDistillerContextKeyedService(
std::move(distiller_page_factory), std::move(distiller_factory), std::move(distiller_page_factory),
std::move(distilled_page_prefs)); std::move(distilled_page_prefs), std::move(distiller_ui_handle));
return service; return service;
} }
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/singleton.h" #include "base/memory/singleton.h"
#include "components/dom_distiller/core/distilled_page_prefs.h" #include "components/dom_distiller/core/distilled_page_prefs.h"
#include "components/dom_distiller/core/distiller_ui_handle.h"
#include "components/dom_distiller/core/dom_distiller_service.h" #include "components/dom_distiller/core/dom_distiller_service.h"
#include "components/keyed_service/content/browser_context_keyed_service_factory.h" #include "components/keyed_service/content/browser_context_keyed_service_factory.h"
#include "components/keyed_service/core/keyed_service.h" #include "components/keyed_service/core/keyed_service.h"
...@@ -26,7 +27,8 @@ class DomDistillerContextKeyedService : public KeyedService, ...@@ -26,7 +27,8 @@ class DomDistillerContextKeyedService : public KeyedService,
DomDistillerContextKeyedService( DomDistillerContextKeyedService(
std::unique_ptr<DistillerFactory> distiller_factory, std::unique_ptr<DistillerFactory> distiller_factory,
std::unique_ptr<DistillerPageFactory> distiller_page_factory, std::unique_ptr<DistillerPageFactory> distiller_page_factory,
std::unique_ptr<DistilledPagePrefs> distilled_page_prefs); std::unique_ptr<DistilledPagePrefs> distilled_page_prefs,
std::unique_ptr<DistillerUIHandle> distiller_ui_handle);
~DomDistillerContextKeyedService() override {} ~DomDistillerContextKeyedService() override {}
private: private:
......
...@@ -118,7 +118,8 @@ class DomDistillerViewerSourceBrowserTest : public InProcessBrowserTest { ...@@ -118,7 +118,8 @@ class DomDistillerViewerSourceBrowserTest : public InProcessBrowserTest {
auto service = std::make_unique<DomDistillerContextKeyedService>( auto service = std::make_unique<DomDistillerContextKeyedService>(
std::move(distiller_factory), std::move(distiller_page_factory), std::move(distiller_factory), std::move(distiller_page_factory),
std::make_unique<DistilledPagePrefs>( std::make_unique<DistilledPagePrefs>(
Profile::FromBrowserContext(context)->GetPrefs())); Profile::FromBrowserContext(context)->GetPrefs()),
/* distiller_ui_handle */ nullptr);
if (expect_distillation_) { if (expect_distillation_) {
// There will only be destillation of an article if the database contains // There will only be destillation of an article if the database contains
// the article. // the article.
......
...@@ -55,6 +55,10 @@ DistilledPagePrefs* LazyDomDistillerService::GetDistilledPagePrefs() { ...@@ -55,6 +55,10 @@ DistilledPagePrefs* LazyDomDistillerService::GetDistilledPagePrefs() {
return GetImpl()->GetDistilledPagePrefs(); return GetImpl()->GetDistilledPagePrefs();
} }
DistillerUIHandle* LazyDomDistillerService::GetDistillerUIHandle() {
return GetImpl()->GetDistillerUIHandle();
}
LazyDomDistillerService::LazyDomDistillerService(Profile* profile) LazyDomDistillerService::LazyDomDistillerService(Profile* profile)
: profile_(profile) {} : profile_(profile) {}
......
...@@ -37,6 +37,7 @@ class LazyDomDistillerService : public DomDistillerServiceInterface, ...@@ -37,6 +37,7 @@ class LazyDomDistillerService : public DomDistillerServiceInterface,
std::unique_ptr<DistillerPage> CreateDefaultDistillerPageWithHandle( std::unique_ptr<DistillerPage> CreateDefaultDistillerPageWithHandle(
std::unique_ptr<SourcePageHandle> handle) override; std::unique_ptr<SourcePageHandle> handle) override;
DistilledPagePrefs* GetDistilledPagePrefs() override; DistilledPagePrefs* GetDistilledPagePrefs() override;
DistillerUIHandle* GetDistillerUIHandle() override;
private: private:
explicit LazyDomDistillerService(Profile* profile); explicit LazyDomDistillerService(Profile* profile);
......
...@@ -13,15 +13,10 @@ ...@@ -13,15 +13,10 @@
#include "chrome/common/chrome_isolated_world_ids.h" #include "chrome/common/chrome_isolated_world_ids.h"
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
#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/dom_distiller_viewer_source.h" #include "components/dom_distiller/content/browser/dom_distiller_viewer_source.h"
#include "components/dom_distiller/core/dom_distiller_features.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)
#include "chrome/browser/android/dom_distiller/distiller_ui_handle_android.h"
#endif // defined(OS_ANDROID)
namespace dom_distiller { namespace dom_distiller {
void RegisterViewerSource(Profile* profile) { void RegisterViewerSource(Profile* profile) {
...@@ -30,20 +25,14 @@ void RegisterViewerSource(Profile* profile) { ...@@ -30,20 +25,14 @@ void RegisterViewerSource(Profile* profile) {
LazyDomDistillerService* lazy_service = LazyDomDistillerService* lazy_service =
LazyDomDistillerService::Create(profile); LazyDomDistillerService::Create(profile);
std::unique_ptr<DistillerUIHandle> ui_handle;
#if defined(OS_ANDROID)
ui_handle =
std::make_unique<dom_distiller::android::DistillerUIHandleAndroid>();
#endif // defined(OS_ANDROID)
// Set the JavaScript world ID. // Set the JavaScript world ID.
if (!DistillerJavaScriptWorldIdIsSet()) if (!DistillerJavaScriptWorldIdIsSet())
SetDistillerJavaScriptWorldId(ISOLATED_WORLD_ID_CHROME_INTERNAL); SetDistillerJavaScriptWorldId(ISOLATED_WORLD_ID_CHROME_INTERNAL);
content::URLDataSource::Add( content::URLDataSource::Add(
profile, std::make_unique<DomDistillerViewerSource>( profile, std::make_unique<DomDistillerViewerSource>(lazy_service,
lazy_service, kDomDistillerScheme, std::move(ui_handle))); kDomDistillerScheme));
} }
} // namespace dom_distiller } // namespace dom_distiller
...@@ -16,7 +16,6 @@ static_library("browser") { ...@@ -16,7 +16,6 @@ static_library("browser") {
"distiller_javascript_utils.h", "distiller_javascript_utils.h",
"distiller_page_web_contents.cc", "distiller_page_web_contents.cc",
"distiller_page_web_contents.h", "distiller_page_web_contents.h",
"distiller_ui_handle.h",
"dom_distiller_viewer_source.cc", "dom_distiller_viewer_source.cc",
"dom_distiller_viewer_source.h", "dom_distiller_viewer_source.h",
"web_contents_main_frame_observer.cc", "web_contents_main_frame_observer.cc",
......
...@@ -4,21 +4,13 @@ ...@@ -4,21 +4,13 @@
#include "components/dom_distiller/content/browser/distiller_javascript_service_impl.h" #include "components/dom_distiller/content/browser/distiller_javascript_service_impl.h"
#include <memory>
#include <utility>
#include "base/metrics/user_metrics.h"
#include "components/dom_distiller/content/browser/distiller_ui_handle.h"
#include "components/dom_distiller/core/feedback_reporter.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h" #include "mojo/public/cpp/bindings/self_owned_receiver.h"
namespace dom_distiller { namespace dom_distiller {
DistillerJavaScriptServiceImpl::DistillerJavaScriptServiceImpl( DistillerJavaScriptServiceImpl::DistillerJavaScriptServiceImpl(
content::RenderFrameHost* render_frame_host,
DistillerUIHandle* distiller_ui_handle) DistillerUIHandle* distiller_ui_handle)
: render_frame_host_(render_frame_host), : distiller_ui_handle_(distiller_ui_handle) {}
distiller_ui_handle_(distiller_ui_handle) {}
DistillerJavaScriptServiceImpl::~DistillerJavaScriptServiceImpl() {} DistillerJavaScriptServiceImpl::~DistillerJavaScriptServiceImpl() {}
...@@ -26,18 +18,16 @@ void DistillerJavaScriptServiceImpl::HandleDistillerOpenSettingsCall() { ...@@ -26,18 +18,16 @@ void DistillerJavaScriptServiceImpl::HandleDistillerOpenSettingsCall() {
if (!distiller_ui_handle_) { if (!distiller_ui_handle_) {
return; return;
} }
content::WebContents* contents =
content::WebContents::FromRenderFrameHost(render_frame_host_); distiller_ui_handle_->OpenSettings();
distiller_ui_handle_->OpenSettings(contents);
} }
void CreateDistillerJavaScriptService( void CreateDistillerJavaScriptService(
DistillerUIHandle* distiller_ui_handle, DistillerUIHandle* distiller_ui_handle,
mojo::PendingReceiver<mojom::DistillerJavaScriptService> receiver, mojo::PendingReceiver<mojom::DistillerJavaScriptService> receiver) {
content::RenderFrameHost* render_frame_host) { mojo::MakeSelfOwnedReceiver(
mojo::MakeSelfOwnedReceiver(std::make_unique<DistillerJavaScriptServiceImpl>( std::make_unique<DistillerJavaScriptServiceImpl>(distiller_ui_handle),
render_frame_host, distiller_ui_handle), std::move(receiver));
std::move(receiver));
} }
} // namespace dom_distiller } // namespace dom_distiller
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
#define COMPONENTS_DOM_DISTILLER_CONTENT_BROWSER_DISTILLER_JAVASCRIPT_SERVICE_IMPL_H_ #define COMPONENTS_DOM_DISTILLER_CONTENT_BROWSER_DISTILLER_JAVASCRIPT_SERVICE_IMPL_H_
#include "base/macros.h" #include "base/macros.h"
#include "components/dom_distiller/content/browser/distiller_ui_handle.h"
#include "components/dom_distiller/content/common/mojom/distiller_javascript_service.mojom.h" #include "components/dom_distiller/content/common/mojom/distiller_javascript_service.mojom.h"
#include "components/dom_distiller/core/distiller_ui_handle.h"
#include "mojo/public/cpp/bindings/pending_receiver.h" #include "mojo/public/cpp/bindings/pending_receiver.h"
namespace dom_distiller { namespace dom_distiller {
...@@ -16,8 +16,7 @@ namespace dom_distiller { ...@@ -16,8 +16,7 @@ namespace dom_distiller {
class DistillerJavaScriptServiceImpl class DistillerJavaScriptServiceImpl
: public mojom::DistillerJavaScriptService { : public mojom::DistillerJavaScriptService {
public: public:
DistillerJavaScriptServiceImpl(content::RenderFrameHost* render_frame_host, DistillerJavaScriptServiceImpl(DistillerUIHandle* distiller_ui_handle);
DistillerUIHandle* distiller_ui_handle);
~DistillerJavaScriptServiceImpl() override; ~DistillerJavaScriptServiceImpl() override;
// Mojo mojom::DistillerJavaScriptService implementation. // Mojo mojom::DistillerJavaScriptService implementation.
...@@ -26,7 +25,6 @@ class DistillerJavaScriptServiceImpl ...@@ -26,7 +25,6 @@ class DistillerJavaScriptServiceImpl
void HandleDistillerOpenSettingsCall() override; void HandleDistillerOpenSettingsCall() override;
private: private:
content::RenderFrameHost* render_frame_host_;
DistillerUIHandle* distiller_ui_handle_; DistillerUIHandle* distiller_ui_handle_;
DISALLOW_COPY_AND_ASSIGN(DistillerJavaScriptServiceImpl); DISALLOW_COPY_AND_ASSIGN(DistillerJavaScriptServiceImpl);
...@@ -35,8 +33,7 @@ class DistillerJavaScriptServiceImpl ...@@ -35,8 +33,7 @@ class DistillerJavaScriptServiceImpl
// static // static
void CreateDistillerJavaScriptService( void CreateDistillerJavaScriptService(
DistillerUIHandle* distiller_ui_handle, DistillerUIHandle* distiller_ui_handle,
mojo::PendingReceiver<mojom::DistillerJavaScriptService> receiver, mojo::PendingReceiver<mojom::DistillerJavaScriptService> receiver);
content::RenderFrameHost* render_frame_host);
} // namespace dom_distiller } // namespace dom_distiller
......
...@@ -18,9 +18,7 @@ ...@@ -18,9 +18,7 @@
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "components/dom_distiller/content/browser/distiller_javascript_service_impl.h"
#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/common/mojom/distiller_page_notifier_service.mojom.h" #include "components/dom_distiller/content/common/mojom/distiller_page_notifier_service.mojom.h"
#include "components/dom_distiller/core/distilled_page_prefs.h" #include "components/dom_distiller/core/distilled_page_prefs.h"
#include "components/dom_distiller/core/dom_distiller_request_view_base.h" #include "components/dom_distiller/core/dom_distiller_request_view_base.h"
...@@ -41,7 +39,6 @@ ...@@ -41,7 +39,6 @@
#include "mojo/public/cpp/bindings/remote.h" #include "mojo/public/cpp/bindings/remote.h"
#include "net/base/url_util.h" #include "net/base/url_util.h"
#include "net/url_request/url_request.h" #include "net/url_request/url_request.h"
#include "services/service_manager/public/cpp/binder_registry.h"
#include "services/service_manager/public/cpp/interface_provider.h" #include "services/service_manager/public/cpp/interface_provider.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
...@@ -56,8 +53,7 @@ class DomDistillerViewerSource::RequestViewerHandle ...@@ -56,8 +53,7 @@ class DomDistillerViewerSource::RequestViewerHandle
public: public:
RequestViewerHandle(content::WebContents* web_contents, RequestViewerHandle(content::WebContents* web_contents,
const GURL& expected_url, const GURL& expected_url,
DistilledPagePrefs* distilled_page_prefs, DistilledPagePrefs* distilled_page_prefs);
DistillerUIHandle* ui_handle);
~RequestViewerHandle() override; ~RequestViewerHandle() override;
// content::WebContentsObserver implementation: // content::WebContentsObserver implementation:
...@@ -66,10 +62,6 @@ class DomDistillerViewerSource::RequestViewerHandle ...@@ -66,10 +62,6 @@ class DomDistillerViewerSource::RequestViewerHandle
void RenderProcessGone(base::TerminationStatus status) override; void RenderProcessGone(base::TerminationStatus status) override;
void WebContentsDestroyed() override; void WebContentsDestroyed() override;
void DOMContentLoaded(content::RenderFrameHost* render_frame_host) override; void DOMContentLoaded(content::RenderFrameHost* render_frame_host) override;
void OnInterfaceRequestFromFrame(
content::RenderFrameHost* render_frame_host,
const std::string& interface_name,
mojo::ScopedMessagePipeHandle* interface_pipe) override;
private: private:
// Sends JavaScript to the attached Viewer, buffering data if the viewer isn't // Sends JavaScript to the attached Viewer, buffering data if the viewer isn't
...@@ -91,30 +83,17 @@ class DomDistillerViewerSource::RequestViewerHandle ...@@ -91,30 +83,17 @@ class DomDistillerViewerSource::RequestViewerHandle
// Temporary store of pending JavaScript if the page isn't ready to receive // Temporary store of pending JavaScript if the page isn't ready to receive
// data from distillation. // data from distillation.
std::string buffer_; std::string buffer_;
// An object for accessing chrome-specific UI controls including external
// feedback and opening the distiller settings. Guaranteed to outlive this
// object.
DistillerUIHandle* distiller_ui_handle_;
service_manager::BinderRegistryWithArgs<content::RenderFrameHost*>
frame_interfaces_;
}; };
DomDistillerViewerSource::RequestViewerHandle::RequestViewerHandle( DomDistillerViewerSource::RequestViewerHandle::RequestViewerHandle(
content::WebContents* web_contents, content::WebContents* web_contents,
const GURL& expected_url, const GURL& expected_url,
DistilledPagePrefs* distilled_page_prefs, DistilledPagePrefs* distilled_page_prefs)
DistillerUIHandle* ui_handle)
: DomDistillerRequestViewBase(distilled_page_prefs), : DomDistillerRequestViewBase(distilled_page_prefs),
expected_url_(expected_url), expected_url_(expected_url),
waiting_for_page_ready_(true), waiting_for_page_ready_(true) {
distiller_ui_handle_(ui_handle) {
content::WebContentsObserver::Observe(web_contents); content::WebContentsObserver::Observe(web_contents);
distilled_page_prefs_->AddObserver(this); distilled_page_prefs_->AddObserver(this);
frame_interfaces_.AddInterface(
base::Bind(&CreateDistillerJavaScriptService, distiller_ui_handle_));
} }
DomDistillerViewerSource::RequestViewerHandle::~RequestViewerHandle() { DomDistillerViewerSource::RequestViewerHandle::~RequestViewerHandle() {
...@@ -213,21 +192,10 @@ void DomDistillerViewerSource::RequestViewerHandle::DOMContentLoaded( ...@@ -213,21 +192,10 @@ void DomDistillerViewerSource::RequestViewerHandle::DOMContentLoaded(
// No need to Cancel() here. // No need to Cancel() here.
} }
void DomDistillerViewerSource::RequestViewerHandle::OnInterfaceRequestFromFrame(
content::RenderFrameHost* render_frame_host,
const std::string& interface_name,
mojo::ScopedMessagePipeHandle* interface_pipe) {
frame_interfaces_.TryBindInterface(interface_name, interface_pipe,
render_frame_host);
}
DomDistillerViewerSource::DomDistillerViewerSource( DomDistillerViewerSource::DomDistillerViewerSource(
DomDistillerServiceInterface* dom_distiller_service, DomDistillerServiceInterface* dom_distiller_service,
const std::string& scheme, const std::string& scheme)
std::unique_ptr<DistillerUIHandle> ui_handle) : scheme_(scheme), dom_distiller_service_(dom_distiller_service) {}
: scheme_(scheme),
dom_distiller_service_(dom_distiller_service),
distiller_ui_handle_(std::move(ui_handle)) {}
DomDistillerViewerSource::~DomDistillerViewerSource() {} DomDistillerViewerSource::~DomDistillerViewerSource() {}
...@@ -277,8 +245,7 @@ void DomDistillerViewerSource::StartDataRequest( ...@@ -277,8 +245,7 @@ void DomDistillerViewerSource::StartDataRequest(
} }
RequestViewerHandle* request_viewer_handle = RequestViewerHandle* request_viewer_handle =
new RequestViewerHandle(web_contents, request_url, new RequestViewerHandle(web_contents, request_url,
dom_distiller_service_->GetDistilledPagePrefs(), dom_distiller_service_->GetDistilledPagePrefs());
distiller_ui_handle_.get());
std::unique_ptr<ViewerHandle> viewer_handle = viewer::CreateViewRequest( std::unique_ptr<ViewerHandle> viewer_handle = viewer::CreateViewRequest(
dom_distiller_service_, request_url, request_viewer_handle, dom_distiller_service_, request_url, request_viewer_handle,
web_contents->GetContainerBounds().size()); web_contents->GetContainerBounds().size());
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/macros.h" #include "base/macros.h"
#include "components/dom_distiller/content/browser/distiller_ui_handle.h"
#include "content/public/browser/url_data_source.h" #include "content/public/browser/url_data_source.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
...@@ -23,8 +22,7 @@ class DomDistillerViewerSourceTest; ...@@ -23,8 +22,7 @@ class DomDistillerViewerSourceTest;
class DomDistillerViewerSource : public content::URLDataSource { class DomDistillerViewerSource : public content::URLDataSource {
public: public:
DomDistillerViewerSource(DomDistillerServiceInterface* dom_distiller_service, DomDistillerViewerSource(DomDistillerServiceInterface* dom_distiller_service,
const std::string& scheme, const std::string& scheme);
std::unique_ptr<DistillerUIHandle> ui_handle);
~DomDistillerViewerSource() override; ~DomDistillerViewerSource() override;
class RequestViewerHandle; class RequestViewerHandle;
...@@ -52,10 +50,6 @@ class DomDistillerViewerSource : public content::URLDataSource { ...@@ -52,10 +50,6 @@ class DomDistillerViewerSource : public content::URLDataSource {
// the list of articles. // the list of articles.
DomDistillerServiceInterface* dom_distiller_service_; DomDistillerServiceInterface* dom_distiller_service_;
// An object for accessing chrome-specific UI controls including external
// feedback and opening the distiller settings.
std::unique_ptr<DistillerUIHandle> distiller_ui_handle_;
DISALLOW_COPY_AND_ASSIGN(DomDistillerViewerSource); DISALLOW_COPY_AND_ASSIGN(DomDistillerViewerSource);
}; };
......
...@@ -14,7 +14,7 @@ const char kTestScheme[] = "myscheme"; ...@@ -14,7 +14,7 @@ const char kTestScheme[] = "myscheme";
class DomDistillerViewerSourceTest : public testing::Test { class DomDistillerViewerSourceTest : public testing::Test {
public: public:
void SetUp() override { void SetUp() override {
source_.reset(new DomDistillerViewerSource(nullptr, kTestScheme, nullptr)); source_.reset(new DomDistillerViewerSource(nullptr, kTestScheme));
} }
protected: protected:
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#include "content/public/renderer/render_frame.h" #include "content/public/renderer/render_frame.h"
#include "gin/arguments.h" #include "gin/arguments.h"
#include "gin/function_template.h" #include "gin/function_template.h"
#include "services/service_manager/public/cpp/interface_provider.h" #include "third_party/blink/public/common/browser_interface_broker_proxy.h"
#include "third_party/blink/public/web/blink.h" #include "third_party/blink/public/web/blink.h"
#include "v8/include/v8.h" #include "v8/include/v8.h"
...@@ -66,7 +66,7 @@ void DistillerNativeJavaScript::BindFunctionToObject( ...@@ -66,7 +66,7 @@ void DistillerNativeJavaScript::BindFunctionToObject(
void DistillerNativeJavaScript::EnsureServiceConnected() { void DistillerNativeJavaScript::EnsureServiceConnected() {
if (!distiller_js_service_) { if (!distiller_js_service_) {
render_frame_->GetRemoteInterfaces()->GetInterface( render_frame_->GetBrowserInterfaceBroker()->GetInterface(
distiller_js_service_.BindNewPipeAndPassReceiver()); distiller_js_service_.BindNewPipeAndPassReceiver());
} }
} }
......
...@@ -20,6 +20,7 @@ static_library("core") { ...@@ -20,6 +20,7 @@ static_library("core") {
"distiller.h", "distiller.h",
"distiller_page.cc", "distiller_page.cc",
"distiller_page.h", "distiller_page.h",
"distiller_ui_handle.h",
"distiller_url_fetcher.cc", "distiller_url_fetcher.cc",
"distiller_url_fetcher.h", "distiller_url_fetcher.h",
"dom_distiller_constants.cc", "dom_distiller_constants.cc",
......
...@@ -2,11 +2,10 @@ ...@@ -2,11 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef COMPONENTS_DOM_DISTILLER_CONTENT_BROWSER_DISTILLER_UI_HANDLE_H_ #ifndef COMPONENTS_DOM_DISTILLER_CORE_DISTILLER_UI_HANDLE_H_
#define COMPONENTS_DOM_DISTILLER_CONTENT_BROWSER_DISTILLER_UI_HANDLE_H_ #define COMPONENTS_DOM_DISTILLER_CORE_DISTILLER_UI_HANDLE_H_
#include "base/macros.h" #include "base/macros.h"
#include "content/public/browser/web_contents.h"
#include "url/gurl.h" #include "url/gurl.h"
namespace dom_distiller { namespace dom_distiller {
...@@ -19,7 +18,7 @@ class DistillerUIHandle { ...@@ -19,7 +18,7 @@ class DistillerUIHandle {
virtual ~DistillerUIHandle() {} virtual ~DistillerUIHandle() {}
// Open the UI settings for dom distiller. // Open the UI settings for dom distiller.
virtual void OpenSettings(content::WebContents* web_contents) = 0; virtual void OpenSettings() = 0;
private: private:
DISALLOW_COPY_AND_ASSIGN(DistillerUIHandle); DISALLOW_COPY_AND_ASSIGN(DistillerUIHandle);
...@@ -27,4 +26,4 @@ class DistillerUIHandle { ...@@ -27,4 +26,4 @@ class DistillerUIHandle {
} // namespace dom_distiller } // namespace dom_distiller
#endif // COMPONENTS_DOM_DISTILLER_CONTENT_BROWSER_DISTILLER_UI_HANDLE_H_ #endif // COMPONENTS_DOM_DISTILLER_CORE_DISTILLER_UI_HANDLE_H_
...@@ -35,11 +35,13 @@ ArticleEntry CreateSkeletonEntryForUrl(const GURL& url) { ...@@ -35,11 +35,13 @@ ArticleEntry CreateSkeletonEntryForUrl(const GURL& url) {
DomDistillerService::DomDistillerService( DomDistillerService::DomDistillerService(
std::unique_ptr<DistillerFactory> distiller_factory, std::unique_ptr<DistillerFactory> distiller_factory,
std::unique_ptr<DistillerPageFactory> distiller_page_factory, std::unique_ptr<DistillerPageFactory> distiller_page_factory,
std::unique_ptr<DistilledPagePrefs> distilled_page_prefs) std::unique_ptr<DistilledPagePrefs> distilled_page_prefs,
std::unique_ptr<DistillerUIHandle> distiller_ui_handle)
: content_store_(new InMemoryContentStore(kDefaultMaxNumCachedEntries)), : content_store_(new InMemoryContentStore(kDefaultMaxNumCachedEntries)),
distiller_factory_(std::move(distiller_factory)), distiller_factory_(std::move(distiller_factory)),
distiller_page_factory_(std::move(distiller_page_factory)), distiller_page_factory_(std::move(distiller_page_factory)),
distilled_page_prefs_(std::move(distilled_page_prefs)) {} distilled_page_prefs_(std::move(distilled_page_prefs)),
distiller_ui_handle_(std::move(distiller_ui_handle)) {}
DomDistillerService::~DomDistillerService() {} DomDistillerService::~DomDistillerService() {}
...@@ -123,4 +125,8 @@ DistilledPagePrefs* DomDistillerService::GetDistilledPagePrefs() { ...@@ -123,4 +125,8 @@ DistilledPagePrefs* DomDistillerService::GetDistilledPagePrefs() {
return distilled_page_prefs_.get(); return distilled_page_prefs_.get();
} }
DistillerUIHandle* DomDistillerService::GetDistillerUIHandle() {
return distiller_ui_handle_.get();
}
} // namespace dom_distiller } // namespace dom_distiller
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "components/dom_distiller/core/article_entry.h" #include "components/dom_distiller/core/article_entry.h"
#include "components/dom_distiller/core/distilled_page_prefs.h" #include "components/dom_distiller/core/distilled_page_prefs.h"
#include "components/dom_distiller/core/distiller_page.h" #include "components/dom_distiller/core/distiller_page.h"
#include "components/dom_distiller/core/distiller_ui_handle.h"
class GURL; class GURL;
...@@ -53,6 +54,10 @@ class DomDistillerServiceInterface { ...@@ -53,6 +54,10 @@ class DomDistillerServiceInterface {
// DomDistillerService. // DomDistillerService.
virtual DistilledPagePrefs* GetDistilledPagePrefs() = 0; virtual DistilledPagePrefs* GetDistilledPagePrefs() = 0;
// Returns the DistillerUIHandle owned by the instance of
// DomDistillerService.
virtual DistillerUIHandle* GetDistillerUIHandle() = 0;
protected: protected:
DomDistillerServiceInterface() {} DomDistillerServiceInterface() {}
...@@ -66,7 +71,8 @@ class DomDistillerService : public DomDistillerServiceInterface { ...@@ -66,7 +71,8 @@ class DomDistillerService : public DomDistillerServiceInterface {
DomDistillerService( DomDistillerService(
std::unique_ptr<DistillerFactory> distiller_factory, std::unique_ptr<DistillerFactory> distiller_factory,
std::unique_ptr<DistillerPageFactory> distiller_page_factory, std::unique_ptr<DistillerPageFactory> distiller_page_factory,
std::unique_ptr<DistilledPagePrefs> distilled_page_prefs); std::unique_ptr<DistilledPagePrefs> distilled_page_prefs,
std::unique_ptr<DistillerUIHandle> distiller_ui_handle);
~DomDistillerService() override; ~DomDistillerService() override;
// DomDistillerServiceInterface implementation. // DomDistillerServiceInterface implementation.
...@@ -79,6 +85,7 @@ class DomDistillerService : public DomDistillerServiceInterface { ...@@ -79,6 +85,7 @@ class DomDistillerService : public DomDistillerServiceInterface {
std::unique_ptr<DistillerPage> CreateDefaultDistillerPageWithHandle( std::unique_ptr<DistillerPage> CreateDefaultDistillerPageWithHandle(
std::unique_ptr<SourcePageHandle> handle) override; std::unique_ptr<SourcePageHandle> handle) override;
DistilledPagePrefs* GetDistilledPagePrefs() override; DistilledPagePrefs* GetDistilledPagePrefs() override;
DistillerUIHandle* GetDistillerUIHandle() override;
private: private:
void CancelTask(TaskTracker* task); void CancelTask(TaskTracker* task);
...@@ -99,6 +106,10 @@ class DomDistillerService : public DomDistillerServiceInterface { ...@@ -99,6 +106,10 @@ class DomDistillerService : public DomDistillerServiceInterface {
std::unique_ptr<DistillerPageFactory> distiller_page_factory_; std::unique_ptr<DistillerPageFactory> distiller_page_factory_;
std::unique_ptr<DistilledPagePrefs> distilled_page_prefs_; std::unique_ptr<DistilledPagePrefs> distilled_page_prefs_;
// An object for accessing chrome-specific UI controls including external
// feedback and opening the distiller settings.
std::unique_ptr<DistillerUIHandle> distiller_ui_handle_;
typedef std::vector<std::unique_ptr<TaskTracker>> TaskList; typedef std::vector<std::unique_ptr<TaskTracker>> TaskList;
TaskList tasks_; TaskList tasks_;
......
...@@ -68,7 +68,8 @@ class DomDistillerServiceTest : public testing::Test { ...@@ -68,7 +68,8 @@ class DomDistillerServiceTest : public testing::Test {
service_.reset(new DomDistillerService( service_.reset(new DomDistillerService(
std::unique_ptr<DistillerFactory>(distiller_factory_), std::unique_ptr<DistillerFactory>(distiller_factory_),
std::unique_ptr<DistillerPageFactory>(distiller_page_factory_), std::unique_ptr<DistillerPageFactory>(distiller_page_factory_),
std::unique_ptr<DistilledPagePrefs>())); /* distilled_page_prefs */ nullptr,
/* distiller_ui_handle */ nullptr));
} }
void TearDown() override { void TearDown() override {
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "components/dom_distiller/core/viewer.h" #include "components/dom_distiller/core/viewer.h"
#include "components/dom_distiller/core/distilled_page_prefs.h" #include "components/dom_distiller/core/distilled_page_prefs.h"
#include "components/dom_distiller/core/distiller_ui_handle.h"
#include "components/dom_distiller/core/dom_distiller_service.h" #include "components/dom_distiller/core/dom_distiller_service.h"
#include "components/dom_distiller/core/task_tracker.h" #include "components/dom_distiller/core/task_tracker.h"
#include "components/dom_distiller/core/url_constants.h" #include "components/dom_distiller/core/url_constants.h"
...@@ -57,6 +58,7 @@ class TestDomDistillerService : public DomDistillerServiceInterface { ...@@ -57,6 +58,7 @@ class TestDomDistillerService : public DomDistillerServiceInterface {
return std::unique_ptr<DistillerPage>(); return std::unique_ptr<DistillerPage>();
} }
DistilledPagePrefs* GetDistilledPagePrefs() override; DistilledPagePrefs* GetDistilledPagePrefs() override;
DistillerUIHandle* GetDistillerUIHandle() override;
}; };
class DomDistillerViewerTest : public testing::Test { class DomDistillerViewerTest : public testing::Test {
...@@ -113,6 +115,10 @@ DistilledPagePrefs* TestDomDistillerService::GetDistilledPagePrefs() { ...@@ -113,6 +115,10 @@ DistilledPagePrefs* TestDomDistillerService::GetDistilledPagePrefs() {
return nullptr; return nullptr;
} }
DistillerUIHandle* TestDomDistillerService::GetDistillerUIHandle() {
return nullptr;
}
TEST_F(DomDistillerViewerTest, TestGetDistilledPageThemeJsOutput) { TEST_F(DomDistillerViewerTest, TestGetDistilledPageThemeJsOutput) {
std::string kDarkJs = "useTheme('dark');"; std::string kDarkJs = "useTheme('dark');";
std::string kSepiaJs = "useTheme('sepia');"; std::string kSepiaJs = "useTheme('sepia');";
......
...@@ -164,7 +164,8 @@ std::unique_ptr<DomDistillerService> CreateDomDistillerService( ...@@ -164,7 +164,8 @@ std::unique_ptr<DomDistillerService> CreateDomDistillerService(
return std::make_unique<DomDistillerService>( return std::make_unique<DomDistillerService>(
std::move(distiller_factory), std::move(distiller_page_factory), std::move(distiller_factory), std::move(distiller_page_factory),
std::make_unique<DistilledPagePrefs>(pref_service)); std::make_unique<DistilledPagePrefs>(pref_service),
/* distiller_ui_handle */ nullptr);
} }
void AddComponentsTestResources() { void AddComponentsTestResources() {
......
...@@ -33,10 +33,12 @@ class DomDistillerKeyedService : public KeyedService, ...@@ -33,10 +33,12 @@ class DomDistillerKeyedService : public KeyedService,
std::unique_ptr<dom_distiller::DistillerFactory> distiller_factory, std::unique_ptr<dom_distiller::DistillerFactory> distiller_factory,
std::unique_ptr<dom_distiller::DistillerPageFactory> std::unique_ptr<dom_distiller::DistillerPageFactory>
distiller_page_factory, distiller_page_factory,
std::unique_ptr<dom_distiller::DistilledPagePrefs> distilled_page_prefs) std::unique_ptr<dom_distiller::DistilledPagePrefs> distilled_page_prefs,
std::unique_ptr<dom_distiller::DistillerUIHandle> distiller_ui_handle)
: DomDistillerService(std::move(distiller_factory), : DomDistillerService(std::move(distiller_factory),
std::move(distiller_page_factory), std::move(distiller_page_factory),
std::move(distilled_page_prefs)) {} std::move(distilled_page_prefs),
std::move(distiller_ui_handle)) {}
~DomDistillerKeyedService() override {} ~DomDistillerKeyedService() override {}
...@@ -88,7 +90,8 @@ DomDistillerServiceFactory::BuildServiceInstanceFor( ...@@ -88,7 +90,8 @@ DomDistillerServiceFactory::BuildServiceInstanceFor(
return std::make_unique<DomDistillerKeyedService>( return std::make_unique<DomDistillerKeyedService>(
std::move(distiller_factory), std::move(distiller_page_factory), std::move(distiller_factory), std::move(distiller_page_factory),
std::move(distilled_page_prefs)); std::move(distilled_page_prefs),
/* distiller_ui_handle */ nullptr);
} }
web::BrowserState* DomDistillerServiceFactory::GetBrowserStateToUse( web::BrowserState* DomDistillerServiceFactory::GetBrowserStateToUse(
......
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