| 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/feature/geolocation/blimp_location_provider.h" | |
| 9 #include "blimp/engine/mojo/blob_channel_service.h" | 8 #include "blimp/engine/mojo/blob_channel_service.h" |
| 10 #include "content/public/browser/geolocation_delegate.h" | |
| 11 #include "services/shell/public/cpp/interface_registry.h" | 9 #include "services/shell/public/cpp/interface_registry.h" |
| 12 | 10 |
| 13 namespace blimp { | 11 namespace blimp { |
| 14 namespace engine { | 12 namespace engine { |
| 15 | 13 |
| 16 namespace { | |
| 17 // A provider of services needed by Geolocation. | |
| 18 class BlimpGeolocationDelegate : public content::GeolocationDelegate { | |
| 19 public: | |
| 20 BlimpGeolocationDelegate() = default; | |
| 21 | |
| 22 bool UseNetworkLocationProviders() final { return false; } | |
| 23 | |
| 24 std::unique_ptr<content::LocationProvider> OverrideSystemLocationProvider() | |
| 25 final { | |
| 26 return base::WrapUnique(new BlimpLocationProvider()); | |
| 27 } | |
| 28 | |
| 29 private: | |
| 30 DISALLOW_COPY_AND_ASSIGN(BlimpGeolocationDelegate); | |
| 31 }; | |
| 32 | |
| 33 } // anonymous namespace | |
| 34 | |
| 35 BlimpContentBrowserClient::BlimpContentBrowserClient() {} | 14 BlimpContentBrowserClient::BlimpContentBrowserClient() {} |
| 36 | 15 |
| 37 BlimpContentBrowserClient::~BlimpContentBrowserClient() {} | 16 BlimpContentBrowserClient::~BlimpContentBrowserClient() {} |
| 38 | 17 |
| 39 content::BrowserMainParts* BlimpContentBrowserClient::CreateBrowserMainParts( | 18 content::BrowserMainParts* BlimpContentBrowserClient::CreateBrowserMainParts( |
| 40 const content::MainFunctionParams& parameters) { | 19 const content::MainFunctionParams& parameters) { |
| 41 blimp_browser_main_parts_ = new BlimpBrowserMainParts(parameters); | 20 blimp_browser_main_parts_ = new BlimpBrowserMainParts(parameters); |
| 42 // BrowserMainLoop takes ownership of the returned BrowserMainParts. | 21 // BrowserMainLoop takes ownership of the returned BrowserMainParts. |
| 43 return blimp_browser_main_parts_; | 22 return blimp_browser_main_parts_; |
| 44 } | 23 } |
| 45 | 24 |
| 46 void BlimpContentBrowserClient::OverrideWebkitPrefs( | 25 void BlimpContentBrowserClient::OverrideWebkitPrefs( |
| 47 content::RenderViewHost* render_view_host, | 26 content::RenderViewHost* render_view_host, |
| 48 content::WebPreferences* prefs) { | 27 content::WebPreferences* prefs) { |
| 49 if (!blimp_browser_main_parts_) | 28 if (!blimp_browser_main_parts_) |
| 50 return; | 29 return; |
| 51 | 30 |
| 52 if (!blimp_browser_main_parts_->GetSettingsManager()) | 31 if (!blimp_browser_main_parts_->GetSettingsManager()) |
| 53 return; | 32 return; |
| 54 | 33 |
| 55 blimp_browser_main_parts_->GetSettingsManager()->UpdateWebkitPreferences( | 34 blimp_browser_main_parts_->GetSettingsManager()->UpdateWebkitPreferences( |
| 56 prefs); | 35 prefs); |
| 57 } | 36 } |
| 58 | 37 |
| 59 BlimpBrowserContext* BlimpContentBrowserClient::GetBrowserContext() { | 38 BlimpBrowserContext* BlimpContentBrowserClient::GetBrowserContext() { |
| 60 return blimp_browser_main_parts_->GetBrowserContext(); | 39 return blimp_browser_main_parts_->GetBrowserContext(); |
| 61 } | 40 } |
| 62 | 41 |
| 63 content::GeolocationDelegate* | |
| 64 BlimpContentBrowserClient::CreateGeolocationDelegate() { | |
| 65 return new BlimpGeolocationDelegate(); | |
| 66 } | |
| 67 | |
| 68 void BlimpContentBrowserClient::ExposeInterfacesToRenderer( | 42 void BlimpContentBrowserClient::ExposeInterfacesToRenderer( |
| 69 shell::InterfaceRegistry* registry, | 43 shell::InterfaceRegistry* registry, |
| 70 content::RenderProcessHost* render_process_host) { | 44 content::RenderProcessHost* render_process_host) { |
| 71 registry->AddInterface<mojom::BlobChannel>( | 45 registry->AddInterface<mojom::BlobChannel>( |
| 72 base::Bind(&BlobChannelService::Create, | 46 base::Bind(&BlobChannelService::Create, |
| 73 blimp_browser_main_parts_->GetBlobChannelSender())); | 47 blimp_browser_main_parts_->GetBlobChannelSender())); |
| 74 } | 48 } |
| 75 | 49 |
| 76 } // namespace engine | 50 } // namespace engine |
| 77 } // namespace blimp | 51 } // namespace blimp |
| OLD | NEW |