Commit 80ef5237 authored by mcasas's avatar mcasas Committed by Commit bot

Geolocation: move creation of the GeolocationDelegate to the embedders

This CL nukes ContentBrowserClient::CreateGeolocationDelegate()
and their overrides, and transfers each embedder's callsite to the
appropriate correspondent BrowserMainParts. These embedders are
namely: android_webview,  blimp, cast, chrome and content_shell.

Continuation of https://crrev.com/2127973002/.

BUG=612334

Review-Url: https://codereview.chromium.org/2174613002
Cr-Commit-Position: refs/heads/master@{#407291}
parent f2e8191e
...@@ -20,7 +20,10 @@ ...@@ -20,7 +20,10 @@
#include "base/i18n/rtl.h" #include "base/i18n/rtl.h"
#include "base/path_service.h" #include "base/path_service.h"
#include "components/crash/content/browser/crash_micro_dump_manager_android.h" #include "components/crash/content/browser/crash_micro_dump_manager_android.h"
#include "content/public/browser/access_token_store.h"
#include "content/public/browser/android/synchronous_compositor.h" #include "content/public/browser/android/synchronous_compositor.h"
#include "content/public/browser/geolocation_delegate.h"
#include "content/public/browser/geolocation_provider.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"
#include "content/public/common/content_client.h" #include "content/public/common/content_client.h"
...@@ -36,6 +39,42 @@ ...@@ -36,6 +39,42 @@
#include "ui/gl/gl_surface.h" #include "ui/gl/gl_surface.h"
namespace android_webview { namespace android_webview {
namespace {
class AwAccessTokenStore : public content::AccessTokenStore {
public:
AwAccessTokenStore() { }
// content::AccessTokenStore implementation
void LoadAccessTokens(const LoadAccessTokensCallback& request) override {
AccessTokenStore::AccessTokenMap access_token_map;
// AccessTokenMap and net::URLRequestContextGetter not used on Android,
// but Run needs to be called to finish the geolocation setup.
request.Run(access_token_map, NULL);
}
void SaveAccessToken(const GURL& server_url,
const base::string16& access_token) override {}
private:
~AwAccessTokenStore() override {}
DISALLOW_COPY_AND_ASSIGN(AwAccessTokenStore);
};
// A provider of Geolocation services to override AccessTokenStore.
class AwGeolocationDelegate : public content::GeolocationDelegate {
public:
AwGeolocationDelegate() = default;
scoped_refptr<content::AccessTokenStore> CreateAccessTokenStore() final {
return new AwAccessTokenStore();
}
private:
DISALLOW_COPY_AND_ASSIGN(AwGeolocationDelegate);
};
} // anonymous namespace
AwBrowserMainParts::AwBrowserMainParts(AwBrowserContext* browser_context) AwBrowserMainParts::AwBrowserMainParts(AwBrowserContext* browser_context)
: browser_context_(browser_context) { : browser_context_(browser_context) {
...@@ -88,6 +127,9 @@ int AwBrowserMainParts::PreCreateThreads() { ...@@ -88,6 +127,9 @@ int AwBrowserMainParts::PreCreateThreads() {
void AwBrowserMainParts::PreMainMessageLoopRun() { void AwBrowserMainParts::PreMainMessageLoopRun() {
browser_context_->PreMainMessageLoopRun(); browser_context_->PreMainMessageLoopRun();
content::GeolocationProvider::SetGeolocationDelegate(
new AwGeolocationDelegate());
AwDevToolsDiscoveryProvider::Install(); AwDevToolsDiscoveryProvider::Install();
content::RenderFrameHost::AllowInjectingJavaScriptForAndroidWebView(); content::RenderFrameHost::AllowInjectingJavaScriptForAndroidWebView();
......
...@@ -33,12 +33,10 @@ ...@@ -33,12 +33,10 @@
#include "components/cdm/browser/cdm_message_filter_android.h" #include "components/cdm/browser/cdm_message_filter_android.h"
#include "components/crash/content/browser/crash_micro_dump_manager_android.h" #include "components/crash/content/browser/crash_micro_dump_manager_android.h"
#include "components/navigation_interception/intercept_navigation_delegate.h" #include "components/navigation_interception/intercept_navigation_delegate.h"
#include "content/public/browser/access_token_store.h"
#include "content/public/browser/browser_message_filter.h" #include "content/public/browser/browser_message_filter.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/child_process_security_policy.h" #include "content/public/browser/child_process_security_policy.h"
#include "content/public/browser/client_certificate_delegate.h" #include "content/public/browser/client_certificate_delegate.h"
#include "content/public/browser/geolocation_delegate.h"
#include "content/public/browser/navigation_handle.h" #include "content/public/browser/navigation_handle.h"
#include "content/public/browser/navigation_throttle.h" #include "content/public/browser/navigation_throttle.h"
#include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_frame_host.h"
...@@ -142,39 +140,6 @@ void AwContentsMessageFilter::OnSubFrameCreated(int parent_render_frame_id, ...@@ -142,39 +140,6 @@ void AwContentsMessageFilter::OnSubFrameCreated(int parent_render_frame_id,
process_id_, parent_render_frame_id, child_render_frame_id); process_id_, parent_render_frame_id, child_render_frame_id);
} }
class AwAccessTokenStore : public content::AccessTokenStore {
public:
AwAccessTokenStore() { }
// content::AccessTokenStore implementation
void LoadAccessTokens(const LoadAccessTokensCallback& request) override {
AccessTokenStore::AccessTokenMap access_token_map;
// AccessTokenMap and net::URLRequestContextGetter not used on Android,
// but Run needs to be called to finish the geolocation setup.
request.Run(access_token_map, NULL);
}
void SaveAccessToken(const GURL& server_url,
const base::string16& access_token) override {}
private:
~AwAccessTokenStore() override {}
DISALLOW_COPY_AND_ASSIGN(AwAccessTokenStore);
};
// A provider of Geolocation services to override AccessTokenStore.
class AwGeolocationDelegate : public content::GeolocationDelegate {
public:
AwGeolocationDelegate() = default;
scoped_refptr<content::AccessTokenStore> CreateAccessTokenStore() final {
return new AwAccessTokenStore();
}
private:
DISALLOW_COPY_AND_ASSIGN(AwGeolocationDelegate);
};
AwLocaleManager* g_locale_manager = NULL; AwLocaleManager* g_locale_manager = NULL;
} // anonymous namespace } // anonymous namespace
...@@ -443,11 +408,6 @@ net::NetLog* AwContentBrowserClient::GetNetLog() { ...@@ -443,11 +408,6 @@ net::NetLog* AwContentBrowserClient::GetNetLog() {
return browser_context_->GetAwURLRequestContext()->GetNetLog(); return browser_context_->GetAwURLRequestContext()->GetNetLog();
} }
content::GeolocationDelegate*
AwContentBrowserClient::CreateGeolocationDelegate() {
return new AwGeolocationDelegate();
}
bool AwContentBrowserClient::IsFastShutdownPossible() { bool AwContentBrowserClient::IsFastShutdownPossible() {
if (base::CommandLine::ForCurrentProcess()->HasSwitch( if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kSingleProcess)) { switches::kSingleProcess)) {
......
...@@ -108,7 +108,6 @@ class AwContentBrowserClient : public content::ContentBrowserClient { ...@@ -108,7 +108,6 @@ class AwContentBrowserClient : public content::ContentBrowserClient {
bool* no_javascript_access) override; bool* no_javascript_access) override;
void ResourceDispatcherHostCreated() override; void ResourceDispatcherHostCreated() override;
net::NetLog* GetNetLog() override; net::NetLog* GetNetLog() override;
content::GeolocationDelegate* CreateGeolocationDelegate() override;
bool IsFastShutdownPossible() override; bool IsFastShutdownPossible() override;
void ClearCache(content::RenderFrameHost* rfh) override; void ClearCache(content::RenderFrameHost* rfh) override;
void ClearCookies(content::RenderFrameHost* rfh) override; void ClearCookies(content::RenderFrameHost* rfh) override;
......
...@@ -5,14 +5,18 @@ ...@@ -5,14 +5,18 @@
#include "blimp/engine/app/blimp_browser_main_parts.h" #include "blimp/engine/app/blimp_browser_main_parts.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/memory/ptr_util.h"
#include "base/threading/thread_restrictions.h" #include "base/threading/thread_restrictions.h"
#include "blimp/common/proto/blimp_message.pb.h" #include "blimp/common/proto/blimp_message.pb.h"
#include "blimp/engine/app/blimp_engine_config.h" #include "blimp/engine/app/blimp_engine_config.h"
#include "blimp/engine/app/settings_manager.h" #include "blimp/engine/app/settings_manager.h"
#include "blimp/engine/common/blimp_browser_context.h" #include "blimp/engine/common/blimp_browser_context.h"
#include "blimp/engine/feature/geolocation/blimp_location_provider.h"
#include "blimp/engine/session/blimp_engine_session.h" #include "blimp/engine/session/blimp_engine_session.h"
#include "blimp/net/blimp_connection.h" #include "blimp/net/blimp_connection.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/geolocation_delegate.h"
#include "content/public/browser/geolocation_provider.h"
#include "content/public/common/main_function_params.h" #include "content/public/common/main_function_params.h"
#include "net/base/net_module.h" #include "net/base/net_module.h"
#include "net/log/net_log.h" #include "net/log/net_log.h"
...@@ -20,6 +24,25 @@ ...@@ -20,6 +24,25 @@
namespace blimp { namespace blimp {
namespace engine { namespace engine {
namespace {
// A provider of services needed by Geolocation.
class BlimpGeolocationDelegate : public content::GeolocationDelegate {
public:
BlimpGeolocationDelegate() = default;
bool UseNetworkLocationProviders() final { return false; }
std::unique_ptr<content::LocationProvider> OverrideSystemLocationProvider()
final {
return base::WrapUnique(new BlimpLocationProvider());
}
private:
DISALLOW_COPY_AND_ASSIGN(BlimpGeolocationDelegate);
};
} // anonymous namespace
BlimpBrowserMainParts::BlimpBrowserMainParts( BlimpBrowserMainParts::BlimpBrowserMainParts(
const content::MainFunctionParams& parameters) {} const content::MainFunctionParams& parameters) {}
...@@ -42,6 +65,8 @@ void BlimpBrowserMainParts::PreMainMessageLoopRun() { ...@@ -42,6 +65,8 @@ void BlimpBrowserMainParts::PreMainMessageLoopRun() {
settings_manager_.reset(new SettingsManager); settings_manager_.reset(new SettingsManager);
std::unique_ptr<BlimpBrowserContext> browser_context( std::unique_ptr<BlimpBrowserContext> browser_context(
new BlimpBrowserContext(false, net_log_.get())); new BlimpBrowserContext(false, net_log_.get()));
content::GeolocationProvider::SetGeolocationDelegate(
new BlimpGeolocationDelegate());
engine_session_.reset( engine_session_.reset(
new BlimpEngineSession(std::move(browser_context), net_log_.get(), new BlimpEngineSession(std::move(browser_context), net_log_.get(),
engine_config_.get(), settings_manager_.get())); engine_config_.get(), settings_manager_.get()));
......
...@@ -5,33 +5,12 @@ ...@@ -5,33 +5,12 @@
#include "blimp/engine/app/blimp_content_browser_client.h" #include "blimp/engine/app/blimp_content_browser_client.h"
#include "blimp/engine/app/blimp_browser_main_parts.h" #include "blimp/engine/app/blimp_browser_main_parts.h"
#include "blimp/engine/app/settings_manager.h" #include "blimp/engine/app/settings_manager.h"
#include "blimp/engine/feature/geolocation/blimp_location_provider.h"
#include "blimp/engine/mojo/blob_channel_service.h" #include "blimp/engine/mojo/blob_channel_service.h"
#include "content/public/browser/geolocation_delegate.h"
#include "services/shell/public/cpp/interface_registry.h" #include "services/shell/public/cpp/interface_registry.h"
namespace blimp { namespace blimp {
namespace engine { namespace engine {
namespace {
// A provider of services needed by Geolocation.
class BlimpGeolocationDelegate : public content::GeolocationDelegate {
public:
BlimpGeolocationDelegate() = default;
bool UseNetworkLocationProviders() final { return false; }
std::unique_ptr<content::LocationProvider> OverrideSystemLocationProvider()
final {
return base::WrapUnique(new BlimpLocationProvider());
}
private:
DISALLOW_COPY_AND_ASSIGN(BlimpGeolocationDelegate);
};
} // anonymous namespace
BlimpContentBrowserClient::BlimpContentBrowserClient() {} BlimpContentBrowserClient::BlimpContentBrowserClient() {}
BlimpContentBrowserClient::~BlimpContentBrowserClient() {} BlimpContentBrowserClient::~BlimpContentBrowserClient() {}
...@@ -60,11 +39,6 @@ BlimpBrowserContext* BlimpContentBrowserClient::GetBrowserContext() { ...@@ -60,11 +39,6 @@ BlimpBrowserContext* BlimpContentBrowserClient::GetBrowserContext() {
return blimp_browser_main_parts_->GetBrowserContext(); return blimp_browser_main_parts_->GetBrowserContext();
} }
content::GeolocationDelegate*
BlimpContentBrowserClient::CreateGeolocationDelegate() {
return new BlimpGeolocationDelegate();
}
void BlimpContentBrowserClient::ExposeInterfacesToRenderer( void BlimpContentBrowserClient::ExposeInterfacesToRenderer(
shell::InterfaceRegistry* registry, shell::InterfaceRegistry* registry,
content::RenderProcessHost* render_process_host) { content::RenderProcessHost* render_process_host) {
......
...@@ -36,8 +36,6 @@ class BlimpContentBrowserClient : public content::ContentBrowserClient { ...@@ -36,8 +36,6 @@ class BlimpContentBrowserClient : public content::ContentBrowserClient {
shell::InterfaceRegistry* registry, shell::InterfaceRegistry* registry,
content::RenderProcessHost* render_process_host) override; content::RenderProcessHost* render_process_host) override;
content::GeolocationDelegate* CreateGeolocationDelegate() override;
BlimpBrowserContext* GetBrowserContext(); BlimpBrowserContext* GetBrowserContext();
private: private:
......
...@@ -59,6 +59,7 @@ ...@@ -59,6 +59,7 @@
#include "chrome/browser/component_updater/widevine_cdm_component_installer.h" #include "chrome/browser/component_updater/widevine_cdm_component_installer.h"
#include "chrome/browser/defaults.h" #include "chrome/browser/defaults.h"
#include "chrome/browser/first_run/first_run.h" #include "chrome/browser/first_run/first_run.h"
#include "chrome/browser/geolocation/chrome_access_token_store.h"
#include "chrome/browser/gpu/gl_string_manager.h" #include "chrome/browser/gpu/gl_string_manager.h"
#include "chrome/browser/gpu/three_d_api_observer.h" #include "chrome/browser/gpu/three_d_api_observer.h"
#include "chrome/browser/media/media_capture_devices_dispatcher.h" #include "chrome/browser/media/media_capture_devices_dispatcher.h"
...@@ -140,6 +141,8 @@ ...@@ -140,6 +141,8 @@
#include "components/variations/variations_switches.h" #include "components/variations/variations_switches.h"
#include "components/version_info/version_info.h" #include "components/version_info/version_info.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/geolocation_delegate.h"
#include "content/public/browser/geolocation_provider.h"
#include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h" #include "content/public/browser/notification_registrar.h"
#include "content/public/browser/notification_service.h" #include "content/public/browser/notification_service.h"
...@@ -270,6 +273,19 @@ using content::BrowserThread; ...@@ -270,6 +273,19 @@ using content::BrowserThread;
namespace { namespace {
// A provider of Geolocation services to override AccessTokenStore.
class ChromeGeolocationDelegate : public content::GeolocationDelegate {
public:
ChromeGeolocationDelegate() = default;
scoped_refptr<content::AccessTokenStore> CreateAccessTokenStore() final {
return new ChromeAccessTokenStore();
}
private:
DISALLOW_COPY_AND_ASSIGN(ChromeGeolocationDelegate);
};
// This function provides some ways to test crash and assertion handling // This function provides some ways to test crash and assertion handling
// behavior of the program. // behavior of the program.
void HandleTestParameters(const base::CommandLine& command_line) { void HandleTestParameters(const base::CommandLine& command_line) {
...@@ -1201,6 +1217,9 @@ int ChromeBrowserMainParts::PreCreateThreadsImpl() { ...@@ -1201,6 +1217,9 @@ int ChromeBrowserMainParts::PreCreateThreadsImpl() {
// ChromeOS needs ResourceBundle::InitSharedInstance to be called before this. // ChromeOS needs ResourceBundle::InitSharedInstance to be called before this.
browser_process_->PreCreateThreads(); browser_process_->PreCreateThreads();
content::GeolocationProvider::SetGeolocationDelegate(
new ChromeGeolocationDelegate());
return content::RESULT_CODE_NORMAL_EXIT; return content::RESULT_CODE_NORMAL_EXIT;
} }
......
...@@ -48,7 +48,6 @@ ...@@ -48,7 +48,6 @@
#include "chrome/browser/download/download_prefs.h" #include "chrome/browser/download/download_prefs.h"
#include "chrome/browser/engagement/site_engagement_eviction_policy.h" #include "chrome/browser/engagement/site_engagement_eviction_policy.h"
#include "chrome/browser/font_family_cache.h" #include "chrome/browser/font_family_cache.h"
#include "chrome/browser/geolocation/chrome_access_token_store.h"
#include "chrome/browser/media/media_capture_devices_dispatcher.h" #include "chrome/browser/media/media_capture_devices_dispatcher.h"
#include "chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.h" #include "chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.h"
#include "chrome/browser/nacl_host/nacl_browser_delegate_impl.h" #include "chrome/browser/nacl_host/nacl_browser_delegate_impl.h"
...@@ -146,7 +145,6 @@ ...@@ -146,7 +145,6 @@
#include "content/public/browser/child_process_data.h" #include "content/public/browser/child_process_data.h"
#include "content/public/browser/child_process_security_policy.h" #include "content/public/browser/child_process_security_policy.h"
#include "content/public/browser/client_certificate_delegate.h" #include "content/public/browser/client_certificate_delegate.h"
#include "content/public/browser/geolocation_delegate.h"
#include "content/public/browser/navigation_handle.h" #include "content/public/browser/navigation_handle.h"
#include "content/public/browser/navigation_throttle.h" #include "content/public/browser/navigation_throttle.h"
#include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_frame_host.h"
...@@ -333,7 +331,6 @@ ...@@ -333,7 +331,6 @@
using base::FileDescriptor; using base::FileDescriptor;
using blink::WebWindowFeatures; using blink::WebWindowFeatures;
using content::AccessTokenStore;
using content::BrowserThread; using content::BrowserThread;
using content::BrowserURLHandler; using content::BrowserURLHandler;
using content::ChildProcessSecurityPolicy; using content::ChildProcessSecurityPolicy;
...@@ -639,19 +636,6 @@ class SafeBrowsingSSLCertReporter : public SSLCertReporter { ...@@ -639,19 +636,6 @@ class SafeBrowsingSSLCertReporter : public SSLCertReporter {
safe_browsing_ui_manager_; safe_browsing_ui_manager_;
}; };
// A provider of Geolocation services to override AccessTokenStore.
class ChromeGeolocationDelegate : public content::GeolocationDelegate {
public:
ChromeGeolocationDelegate() = default;
scoped_refptr<AccessTokenStore> CreateAccessTokenStore() final {
return new ChromeAccessTokenStore();
}
private:
DISALLOW_COPY_AND_ASSIGN(ChromeGeolocationDelegate);
};
#if BUILDFLAG(ANDROID_JAVA_UI) #if BUILDFLAG(ANDROID_JAVA_UI)
void HandleSingleTabModeBlockOnUIThread(const BlockedWindowParams& params) { void HandleSingleTabModeBlockOnUIThread(const BlockedWindowParams& params) {
WebContents* web_contents = tab_util::GetWebContentsByFrameID( WebContents* web_contents = tab_util::GetWebContentsByFrameID(
...@@ -2313,11 +2297,6 @@ net::NetLog* ChromeContentBrowserClient::GetNetLog() { ...@@ -2313,11 +2297,6 @@ net::NetLog* ChromeContentBrowserClient::GetNetLog() {
return g_browser_process->net_log(); return g_browser_process->net_log();
} }
content::GeolocationDelegate*
ChromeContentBrowserClient::CreateGeolocationDelegate() {
return new ChromeGeolocationDelegate();
}
bool ChromeContentBrowserClient::IsFastShutdownPossible() { bool ChromeContentBrowserClient::IsFastShutdownPossible() {
return true; return true;
} }
......
...@@ -211,8 +211,6 @@ class ChromeContentBrowserClient : public content::ContentBrowserClient { ...@@ -211,8 +211,6 @@ class ChromeContentBrowserClient : public content::ContentBrowserClient {
CreateSpeechRecognitionManagerDelegate() override; CreateSpeechRecognitionManagerDelegate() override;
net::NetLog* GetNetLog() override; net::NetLog* GetNetLog() override;
content::GeolocationDelegate* CreateGeolocationDelegate() override;
bool IsFastShutdownPossible() override; bool IsFastShutdownPossible() override;
void OverrideWebkitPrefs(content::RenderViewHost* rvh, void OverrideWebkitPrefs(content::RenderViewHost* rvh,
content::WebPreferences* prefs) override; content::WebPreferences* prefs) override;
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include "chromecast/browser/cast_memory_pressure_monitor.h" #include "chromecast/browser/cast_memory_pressure_monitor.h"
#include "chromecast/browser/cast_net_log.h" #include "chromecast/browser/cast_net_log.h"
#include "chromecast/browser/devtools/remote_debugging_server.h" #include "chromecast/browser/devtools/remote_debugging_server.h"
#include "chromecast/browser/geolocation/cast_access_token_store.h"
#include "chromecast/browser/metrics/cast_metrics_prefs.h" #include "chromecast/browser/metrics/cast_metrics_prefs.h"
#include "chromecast/browser/metrics/cast_metrics_service_client.h" #include "chromecast/browser/metrics/cast_metrics_service_client.h"
#include "chromecast/browser/pref_service_helper.h" #include "chromecast/browser/pref_service_helper.h"
...@@ -49,6 +50,8 @@ ...@@ -49,6 +50,8 @@
#include "components/prefs/pref_registry_simple.h" #include "components/prefs/pref_registry_simple.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/child_process_security_policy.h" #include "content/public/browser/child_process_security_policy.h"
#include "content/public/browser/geolocation_delegate.h"
#include "content/public/browser/geolocation_provider.h"
#include "content/public/browser/gpu_data_manager.h" #include "content/public/browser/gpu_data_manager.h"
#include "content/public/browser/storage_partition.h" #include "content/public/browser/storage_partition.h"
#include "content/public/common/content_switches.h" #include "content/public/common/content_switches.h"
...@@ -184,6 +187,22 @@ namespace shell { ...@@ -184,6 +187,22 @@ namespace shell {
namespace { namespace {
// A provider of services for Geolocation.
class CastGeolocationDelegate : public content::GeolocationDelegate {
public:
explicit CastGeolocationDelegate(CastBrowserContext* context)
: context_(context) {}
scoped_refptr<content::AccessTokenStore> CreateAccessTokenStore() override {
return new CastAccessTokenStore(context_);
}
private:
CastBrowserContext* context_;
DISALLOW_COPY_AND_ASSIGN(CastGeolocationDelegate);
};
struct DefaultCommandLineSwitch { struct DefaultCommandLineSwitch {
const char* const switch_name; const char* const switch_name;
const char* const switch_value; const char* const switch_value;
...@@ -451,6 +470,9 @@ void CastBrowserMainParts::PreMainMessageLoopRun() { ...@@ -451,6 +470,9 @@ void CastBrowserMainParts::PreMainMessageLoopRun() {
#endif #endif
::media::InitializeMediaLibrary(); ::media::InitializeMediaLibrary();
content::GeolocationProvider::SetGeolocationDelegate(
new CastGeolocationDelegate(cast_browser_process_->browser_context()));
// Initializing metrics service and network delegates must happen after cast // Initializing metrics service and network delegates must happen after cast
// service is intialized because CastMetricsServiceClient and // service is intialized because CastMetricsServiceClient and
// CastNetworkDelegate may use components initialized by cast service. // CastNetworkDelegate may use components initialized by cast service.
......
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
#include "chromecast/browser/cast_network_delegate.h" #include "chromecast/browser/cast_network_delegate.h"
#include "chromecast/browser/cast_quota_permission_context.h" #include "chromecast/browser/cast_quota_permission_context.h"
#include "chromecast/browser/cast_resource_dispatcher_host_delegate.h" #include "chromecast/browser/cast_resource_dispatcher_host_delegate.h"
#include "chromecast/browser/geolocation/cast_access_token_store.h"
#include "chromecast/browser/media/cma_message_filter_host.h" #include "chromecast/browser/media/cma_message_filter_host.h"
#include "chromecast/browser/service/cast_service_simple.h" #include "chromecast/browser/service/cast_service_simple.h"
#include "chromecast/browser/url_request_context_factory.h" #include "chromecast/browser/url_request_context_factory.h"
...@@ -42,7 +41,6 @@ ...@@ -42,7 +41,6 @@
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/certificate_request_result_type.h" #include "content/public/browser/certificate_request_result_type.h"
#include "content/public/browser/client_certificate_delegate.h" #include "content/public/browser/client_certificate_delegate.h"
#include "content/public/browser/geolocation_delegate.h"
#include "content/public/browser/render_process_host.h" #include "content/public/browser/render_process_host.h"
#include "content/public/browser/resource_dispatcher_host.h" #include "content/public/browser/resource_dispatcher_host.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
...@@ -89,22 +87,6 @@ static std::unique_ptr<::shell::Service> CreateMojoMediaApplication( ...@@ -89,22 +87,6 @@ static std::unique_ptr<::shell::Service> CreateMojoMediaApplication(
} }
#endif // defined(ENABLE_MOJO_MEDIA_IN_BROWSER_PROCESS) #endif // defined(ENABLE_MOJO_MEDIA_IN_BROWSER_PROCESS)
// A provider of services for Geolocation.
class CastGeolocationDelegate : public content::GeolocationDelegate {
public:
explicit CastGeolocationDelegate(CastBrowserContext* context)
: context_(context) {}
scoped_refptr<content::AccessTokenStore> CreateAccessTokenStore() override {
return new CastAccessTokenStore(context_);
}
private:
CastBrowserContext* context_;
DISALLOW_COPY_AND_ASSIGN(CastGeolocationDelegate);
};
} // namespace } // namespace
CastContentBrowserClient::CastContentBrowserClient() CastContentBrowserClient::CastContentBrowserClient()
...@@ -303,12 +285,6 @@ void CastContentBrowserClient::AppendExtraCommandLineSwitches( ...@@ -303,12 +285,6 @@ void CastContentBrowserClient::AppendExtraCommandLineSwitches(
AppendExtraCommandLineSwitches(command_line); AppendExtraCommandLineSwitches(command_line);
} }
content::GeolocationDelegate*
CastContentBrowserClient::CreateGeolocationDelegate() {
return new CastGeolocationDelegate(
CastBrowserProcess::GetInstance()->browser_context());
}
void CastContentBrowserClient::OverrideWebkitPrefs( void CastContentBrowserClient::OverrideWebkitPrefs(
content::RenderViewHost* render_view_host, content::RenderViewHost* render_view_host,
content::WebPreferences* prefs) { content::WebPreferences* prefs) {
......
...@@ -104,7 +104,6 @@ class CastContentBrowserClient : public content::ContentBrowserClient { ...@@ -104,7 +104,6 @@ class CastContentBrowserClient : public content::ContentBrowserClient {
bool IsHandledURL(const GURL& url) override; bool IsHandledURL(const GURL& url) override;
void AppendExtraCommandLineSwitches(base::CommandLine* command_line, void AppendExtraCommandLineSwitches(base::CommandLine* command_line,
int child_process_id) override; int child_process_id) override;
content::GeolocationDelegate* CreateGeolocationDelegate() override;
void OverrideWebkitPrefs(content::RenderViewHost* render_view_host, void OverrideWebkitPrefs(content::RenderViewHost* render_view_host,
content::WebPreferences* prefs) override; content::WebPreferences* prefs) override;
void ResourceDispatcherHostCreated() override; void ResourceDispatcherHostCreated() override;
......
...@@ -683,9 +683,6 @@ void BrowserMainLoop::PostMainMessageLoopStart() { ...@@ -683,9 +683,6 @@ void BrowserMainLoop::PostMainMessageLoopStart() {
DOMStorageArea::EnableAggressiveCommitDelay(); DOMStorageArea::EnableAggressiveCommitDelay();
} }
GeolocationProvider::SetGeolocationDelegate(
GetContentClient()->browser()->CreateGeolocationDelegate());
// Enable memory-infra dump providers. // Enable memory-infra dump providers.
InitSkiaEventTracer(); InitSkiaEventTracer();
tracing::ProcessMetricsMemoryDumpProvider::RegisterForProcess( tracing::ProcessMetricsMemoryDumpProvider::RegisterForProcess(
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include "base/guid.h" #include "base/guid.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "content/public/browser/client_certificate_delegate.h" #include "content/public/browser/client_certificate_delegate.h"
#include "content/public/browser/geolocation_delegate.h"
#include "content/public/browser/vpn_service_proxy.h" #include "content/public/browser/vpn_service_proxy.h"
#include "content/public/common/sandbox_type.h" #include "content/public/common/sandbox_type.h"
#include "media/base/cdm_factory.h" #include "media/base/cdm_factory.h"
...@@ -308,11 +307,6 @@ net::NetLog* ContentBrowserClient::GetNetLog() { ...@@ -308,11 +307,6 @@ net::NetLog* ContentBrowserClient::GetNetLog() {
return nullptr; return nullptr;
} }
GeolocationDelegate* ContentBrowserClient::CreateGeolocationDelegate() {
// We don't need to override anything, the default implementation is good.
return nullptr;
}
bool ContentBrowserClient::IsFastShutdownPossible() { bool ContentBrowserClient::IsFastShutdownPossible() {
return true; return true;
} }
......
...@@ -107,7 +107,6 @@ class BrowserURLHandler; ...@@ -107,7 +107,6 @@ class BrowserURLHandler;
class ClientCertificateDelegate; class ClientCertificateDelegate;
class DevToolsManagerDelegate; class DevToolsManagerDelegate;
class ExternalVideoSurfaceContainer; class ExternalVideoSurfaceContainer;
class GeolocationDelegate;
class LocationProvider; class LocationProvider;
class MediaObserver; class MediaObserver;
class NavigationHandle; class NavigationHandle;
...@@ -535,10 +534,6 @@ class CONTENT_EXPORT ContentBrowserClient { ...@@ -535,10 +534,6 @@ class CONTENT_EXPORT ContentBrowserClient {
// Getters for common objects. // Getters for common objects.
virtual net::NetLog* GetNetLog(); virtual net::NetLog* GetNetLog();
// Allows the embedder to provide a Delegate for Geolocation to override some
// functionality of the API (e.g. AccessTokenStore, LocationProvider).
virtual GeolocationDelegate* CreateGeolocationDelegate();
// Returns true if fast shutdown is possible. // Returns true if fast shutdown is possible.
virtual bool IsFastShutdownPossible(); virtual bool IsFastShutdownPossible();
......
...@@ -15,11 +15,14 @@ ...@@ -15,11 +15,14 @@
#include "build/build_config.h" #include "build/build_config.h"
#include "components/devtools_http_handler/devtools_http_handler.h" #include "components/devtools_http_handler/devtools_http_handler.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/geolocation_delegate.h"
#include "content/public/browser/geolocation_provider.h"
#include "content/public/browser/storage_partition.h" #include "content/public/browser/storage_partition.h"
#include "content/public/common/content_switches.h" #include "content/public/common/content_switches.h"
#include "content/public/common/main_function_params.h" #include "content/public/common/main_function_params.h"
#include "content/public/common/url_constants.h" #include "content/public/common/url_constants.h"
#include "content/shell/browser/shell.h" #include "content/shell/browser/shell.h"
#include "content/shell/browser/shell_access_token_store.h"
#include "content/shell/browser/shell_browser_context.h" #include "content/shell/browser/shell_browser_context.h"
#include "content/shell/browser/shell_devtools_manager_delegate.h" #include "content/shell/browser/shell_devtools_manager_delegate.h"
#include "content/shell/browser/shell_net_log.h" #include "content/shell/browser/shell_net_log.h"
...@@ -55,6 +58,21 @@ namespace content { ...@@ -55,6 +58,21 @@ namespace content {
namespace { namespace {
// A provider of services for Geolocation.
class ShellGeolocationDelegate : public content::GeolocationDelegate {
public:
explicit ShellGeolocationDelegate(ShellBrowserContext* context)
: context_(context) {}
scoped_refptr<content::AccessTokenStore> CreateAccessTokenStore() final {
return new ShellAccessTokenStore(context_);
}
private:
ShellBrowserContext* context_;
DISALLOW_COPY_AND_ASSIGN(ShellGeolocationDelegate);
};
GURL GetStartupURL() { GURL GetStartupURL() {
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
if (command_line->HasSwitch(switches::kContentBrowserTest)) if (command_line->HasSwitch(switches::kContentBrowserTest))
...@@ -165,6 +183,8 @@ int ShellBrowserMainParts::PreCreateThreads() { ...@@ -165,6 +183,8 @@ int ShellBrowserMainParts::PreCreateThreads() {
void ShellBrowserMainParts::PreMainMessageLoopRun() { void ShellBrowserMainParts::PreMainMessageLoopRun() {
net_log_.reset(new ShellNetLog("content_shell")); net_log_.reset(new ShellNetLog("content_shell"));
InitializeBrowserContexts(); InitializeBrowserContexts();
content::GeolocationProvider::SetGeolocationDelegate(
new ShellGeolocationDelegate(browser_context()));
Shell::Initialize(); Shell::Initialize();
net::NetModule::SetResourceProvider(PlatformResourceProvider); net::NetModule::SetResourceProvider(PlatformResourceProvider);
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "content/public/browser/client_certificate_delegate.h" #include "content/public/browser/client_certificate_delegate.h"
#include "content/public/browser/geolocation_delegate.h"
#include "content/public/browser/page_navigator.h" #include "content/public/browser/page_navigator.h"
#include "content/public/browser/render_process_host.h" #include "content/public/browser/render_process_host.h"
#include "content/public/browser/resource_dispatcher_host.h" #include "content/public/browser/resource_dispatcher_host.h"
...@@ -27,7 +26,6 @@ ...@@ -27,7 +26,6 @@
#include "content/public/common/web_preferences.h" #include "content/public/common/web_preferences.h"
#include "content/public/test/test_mojo_app.h" #include "content/public/test/test_mojo_app.h"
#include "content/shell/browser/shell.h" #include "content/shell/browser/shell.h"
#include "content/shell/browser/shell_access_token_store.h"
#include "content/shell/browser/shell_browser_context.h" #include "content/shell/browser/shell_browser_context.h"
#include "content/shell/browser/shell_browser_main_parts.h" #include "content/shell/browser/shell_browser_main_parts.h"
#include "content/shell/browser/shell_devtools_manager_delegate.h" #include "content/shell/browser/shell_devtools_manager_delegate.h"
...@@ -119,20 +117,6 @@ int GetCrashSignalFD(const base::CommandLine& command_line) { ...@@ -119,20 +117,6 @@ int GetCrashSignalFD(const base::CommandLine& command_line) {
} }
#endif // defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) #endif // defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID)
// A provider of services for Geolocation.
class ShellGeolocationDelegate : public content::GeolocationDelegate {
public:
ShellGeolocationDelegate() {}
scoped_refptr<AccessTokenStore> CreateAccessTokenStore() final {
return new ShellAccessTokenStore(
ShellContentBrowserClient::Get()->browser_context());
}
private:
DISALLOW_COPY_AND_ASSIGN(ShellGeolocationDelegate);
};
} // namespace } // namespace
ShellContentBrowserClient* ShellContentBrowserClient::Get() { ShellContentBrowserClient* ShellContentBrowserClient::Get() {
...@@ -364,8 +348,4 @@ ShellBrowserContext* ...@@ -364,8 +348,4 @@ ShellBrowserContext*
return shell_browser_main_parts_->off_the_record_browser_context(); return shell_browser_main_parts_->off_the_record_browser_context();
} }
GeolocationDelegate* ShellContentBrowserClient::CreateGeolocationDelegate() {
return new ShellGeolocationDelegate();
}
} // namespace content } // namespace content
...@@ -43,7 +43,6 @@ class ShellContentBrowserClient : public ContentBrowserClient { ...@@ -43,7 +43,6 @@ class ShellContentBrowserClient : public ContentBrowserClient {
void AppendExtraCommandLineSwitches(base::CommandLine* command_line, void AppendExtraCommandLineSwitches(base::CommandLine* command_line,
int child_process_id) override; int child_process_id) override;
void ResourceDispatcherHostCreated() override; void ResourceDispatcherHostCreated() override;
GeolocationDelegate* CreateGeolocationDelegate() override;
std::string GetDefaultDownloadName() override; std::string GetDefaultDownloadName() override;
WebContentsViewDelegate* GetWebContentsViewDelegate( WebContentsViewDelegate* GetWebContentsViewDelegate(
WebContents* web_contents) override; WebContents* web_contents) override;
......
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