Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(548)

Side by Side Diff: blimp/engine/app/blimp_content_browser_client.cc

Issue 2098553002: Geolocation: extract ContentBrowserClient methods specific to Geolocation into a class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Minor touch in LocationArbitratorImplTest to restate previous behaviour. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
8 #include "blimp/engine/mojo/blob_channel_service.h" 9 #include "blimp/engine/mojo/blob_channel_service.h"
9 #include "services/shell/public/cpp/interface_registry.h" 10 #include "services/shell/public/cpp/interface_registry.h"
10 11
11 namespace blimp { 12 namespace blimp {
12 namespace engine { 13 namespace engine {
13 14
15 namespace {
16 // A provider of services needed by Geolocation.
17 class BlimpGeolocationDelegate : public content::GeolocationProvider::Delegate {
Michael van Ouwerkerk 2016/06/28 11:17:07 nit: DISALLOW_COPY_AND_ASSIGN
mcasas 2016/06/28 16:51:25 Done.
18 public:
19 bool UseNetworkLocationProviders() final { return false; }
20
21 content::LocationProvider* OverrideSystemLocationProvider() final {
22 if (!location_provider_)
23 location_provider_ = base::WrapUnique(new BlimpLocationProvider());
24 return location_provider_.get();
25 }
26
27 private:
28 std::unique_ptr<BlimpLocationProvider> location_provider_;
29 };
30
31 } // anonymous namespace
32
14 BlimpContentBrowserClient::BlimpContentBrowserClient() {} 33 BlimpContentBrowserClient::BlimpContentBrowserClient() {}
15 34
16 BlimpContentBrowserClient::~BlimpContentBrowserClient() {} 35 BlimpContentBrowserClient::~BlimpContentBrowserClient() {}
17 36
18 content::BrowserMainParts* BlimpContentBrowserClient::CreateBrowserMainParts( 37 content::BrowserMainParts* BlimpContentBrowserClient::CreateBrowserMainParts(
19 const content::MainFunctionParams& parameters) { 38 const content::MainFunctionParams& parameters) {
20 blimp_browser_main_parts_ = new BlimpBrowserMainParts(parameters); 39 blimp_browser_main_parts_ = new BlimpBrowserMainParts(parameters);
21 // BrowserMainLoop takes ownership of the returned BrowserMainParts. 40 // BrowserMainLoop takes ownership of the returned BrowserMainParts.
22 return blimp_browser_main_parts_; 41 return blimp_browser_main_parts_;
23 } 42 }
24 43
25 void BlimpContentBrowserClient::OverrideWebkitPrefs( 44 void BlimpContentBrowserClient::OverrideWebkitPrefs(
26 content::RenderViewHost* render_view_host, 45 content::RenderViewHost* render_view_host,
27 content::WebPreferences* prefs) { 46 content::WebPreferences* prefs) {
28 if (!blimp_browser_main_parts_) 47 if (!blimp_browser_main_parts_)
29 return; 48 return;
30 49
31 if (!blimp_browser_main_parts_->GetSettingsManager()) 50 if (!blimp_browser_main_parts_->GetSettingsManager())
32 return; 51 return;
33 52
34 blimp_browser_main_parts_->GetSettingsManager()->UpdateWebkitPreferences( 53 blimp_browser_main_parts_->GetSettingsManager()->UpdateWebkitPreferences(
35 prefs); 54 prefs);
36 } 55 }
37 56
38 BlimpBrowserContext* BlimpContentBrowserClient::GetBrowserContext() { 57 BlimpBrowserContext* BlimpContentBrowserClient::GetBrowserContext() {
39 return blimp_browser_main_parts_->GetBrowserContext(); 58 return blimp_browser_main_parts_->GetBrowserContext();
40 } 59 }
41 60
42 content::LocationProvider* 61 content::GeolocationProvider::Delegate*
43 BlimpContentBrowserClient::OverrideSystemLocationProvider() { 62 BlimpContentBrowserClient::CreateGeolocationDelegate() {
44 if (!location_provider_) { 63 return new BlimpGeolocationDelegate();
45 location_provider_ = base::WrapUnique(new BlimpLocationProvider());
46 }
47 return location_provider_.get();
48 }
49
50 bool BlimpContentBrowserClient::UseNetworkLocationProviders() {
51 return false;
52 } 64 }
53 65
54 void BlimpContentBrowserClient::ExposeInterfacesToRenderer( 66 void BlimpContentBrowserClient::ExposeInterfacesToRenderer(
55 shell::InterfaceRegistry* registry, 67 shell::InterfaceRegistry* registry,
56 content::RenderProcessHost* render_process_host) { 68 content::RenderProcessHost* render_process_host) {
57 registry->AddInterface<mojom::BlobChannel>( 69 registry->AddInterface<mojom::BlobChannel>(
58 base::Bind(&BlobChannelService::Create, 70 base::Bind(&BlobChannelService::Create,
59 blimp_browser_main_parts_->GetBlobChannelSender())); 71 blimp_browser_main_parts_->GetBlobChannelSender()));
60 } 72 }
61 73
62 } // namespace engine 74 } // namespace engine
63 } // namespace blimp 75 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698