| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "blimp/engine/app/blimp_content_browser_client.h" | 5 #include "blimp/engine/app/blimp_content_browser_client.h" |
| 6 #include "blimp/engine/app/blimp_browser_main_parts.h" | 6 #include "blimp/engine/app/blimp_browser_main_parts.h" |
| 7 #include "blimp/engine/app/settings_manager.h" | 7 #include "blimp/engine/app/settings_manager.h" |
| 8 #include "blimp/engine/mojo/blob_channel_service.h" | 8 #include "blimp/engine/mojo/blob_channel_service.h" |
| 9 #include "content/public/common/service_registry.h" | 9 #include "content/public/common/service_registry.h" |
| 10 | 10 |
| 11 namespace blimp { | 11 namespace blimp { |
| 12 namespace engine { | 12 namespace engine { |
| 13 | 13 |
| 14 namespace { |
| 15 // A provider of services needed by Geolocation. |
| 16 class BlimpGeolocationServiceOverrides |
| 17 : public content::GeolocationProvider::ServiceOverrides { |
| 18 public: |
| 19 bool UseNetworkLocationProviders() override { return false; } |
| 20 |
| 21 content::LocationProvider* OverrideSystemLocationProvider() { |
| 22 if (!location_provider_) |
| 23 location_provider_ = base::WrapUnique(new BlimpLocationProvider()); |
| 24 return location_provider_.get(); |
| 25 } |
| 26 }; |
| 27 |
| 28 } // anonymous namespace |
| 29 |
| 14 BlimpContentBrowserClient::BlimpContentBrowserClient() {} | 30 BlimpContentBrowserClient::BlimpContentBrowserClient() {} |
| 15 | 31 |
| 16 BlimpContentBrowserClient::~BlimpContentBrowserClient() {} | 32 BlimpContentBrowserClient::~BlimpContentBrowserClient() {} |
| 17 | 33 |
| 18 content::BrowserMainParts* BlimpContentBrowserClient::CreateBrowserMainParts( | 34 content::BrowserMainParts* BlimpContentBrowserClient::CreateBrowserMainParts( |
| 19 const content::MainFunctionParams& parameters) { | 35 const content::MainFunctionParams& parameters) { |
| 20 blimp_browser_main_parts_ = new BlimpBrowserMainParts(parameters); | 36 blimp_browser_main_parts_ = new BlimpBrowserMainParts(parameters); |
| 21 // BrowserMainLoop takes ownership of the returned BrowserMainParts. | 37 // BrowserMainLoop takes ownership of the returned BrowserMainParts. |
| 22 return blimp_browser_main_parts_; | 38 return blimp_browser_main_parts_; |
| 23 } | 39 } |
| 24 | 40 |
| 25 void BlimpContentBrowserClient::OverrideWebkitPrefs( | 41 void BlimpContentBrowserClient::OverrideWebkitPrefs( |
| 26 content::RenderViewHost* render_view_host, | 42 content::RenderViewHost* render_view_host, |
| 27 content::WebPreferences* prefs) { | 43 content::WebPreferences* prefs) { |
| 28 if (!blimp_browser_main_parts_) | 44 if (!blimp_browser_main_parts_) |
| 29 return; | 45 return; |
| 30 | 46 |
| 31 if (!blimp_browser_main_parts_->GetSettingsManager()) | 47 if (!blimp_browser_main_parts_->GetSettingsManager()) |
| 32 return; | 48 return; |
| 33 | 49 |
| 34 blimp_browser_main_parts_->GetSettingsManager()->UpdateWebkitPreferences( | 50 blimp_browser_main_parts_->GetSettingsManager()->UpdateWebkitPreferences( |
| 35 prefs); | 51 prefs); |
| 36 } | 52 } |
| 37 | 53 |
| 38 BlimpBrowserContext* BlimpContentBrowserClient::GetBrowserContext() { | 54 BlimpBrowserContext* BlimpContentBrowserClient::GetBrowserContext() { |
| 39 return blimp_browser_main_parts_->GetBrowserContext(); | 55 return blimp_browser_main_parts_->GetBrowserContext(); |
| 40 } | 56 } |
| 41 | 57 |
| 42 content::LocationProvider* | 58 content::GeolocationProvider::ServiceOverrides* |
| 43 BlimpContentBrowserClient::OverrideSystemLocationProvider() { | 59 ChromeContentBrowserClient::GetGeolocationServiceOverrides() { |
| 44 if (!location_provider_) { | 60 return new BlimpGeolocationServiceOverrides(); |
| 45 location_provider_ = base::WrapUnique(new BlimpLocationProvider()); | |
| 46 } | |
| 47 return location_provider_.get(); | |
| 48 } | |
| 49 | |
| 50 bool BlimpContentBrowserClient::UseNetworkLocationProviders() { | |
| 51 return false; | |
| 52 } | 61 } |
| 53 | 62 |
| 54 void BlimpContentBrowserClient::RegisterRenderProcessMojoServices( | 63 void BlimpContentBrowserClient::RegisterRenderProcessMojoServices( |
| 55 content::ServiceRegistry* registry, | 64 content::ServiceRegistry* registry, |
| 56 content::RenderProcessHost* render_process_host) { | 65 content::RenderProcessHost* render_process_host) { |
| 57 registry->AddService<mojom::BlobChannel>( | 66 registry->AddService<mojom::BlobChannel>( |
| 58 base::Bind(&BlobChannelService::Create, | 67 base::Bind(&BlobChannelService::Create, |
| 59 blimp_browser_main_parts_->GetBlobChannelSender())); | 68 blimp_browser_main_parts_->GetBlobChannelSender())); |
| 60 } | 69 } |
| 61 | 70 |
| 62 } // namespace engine | 71 } // namespace engine |
| 63 } // namespace blimp | 72 } // namespace blimp |
| OLD | NEW |