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 "base/memory/weak_ptr.h" | |
5 #include "blimp/engine/app/blimp_content_browser_client.h" | 6 #include "blimp/engine/app/blimp_content_browser_client.h" |
6 #include "blimp/engine/app/blimp_browser_main_parts.h" | 7 #include "blimp/engine/app/blimp_browser_main_parts.h" |
7 #include "blimp/engine/app/settings_manager.h" | 8 #include "blimp/engine/app/settings_manager.h" |
8 #include "blimp/engine/feature/geolocation/blimp_location_provider.h" | 9 #include "blimp/engine/feature/geolocation/blimp_location_provider.h" |
10 #include "blimp/engine/feature/geolocation/engine_geolocation_feature.h" | |
9 #include "blimp/engine/mojo/blob_channel_service.h" | 11 #include "blimp/engine/mojo/blob_channel_service.h" |
12 #include "blimp/engine/session/blimp_engine_session.h" | |
10 #include "content/public/browser/geolocation_delegate.h" | 13 #include "content/public/browser/geolocation_delegate.h" |
11 #include "services/shell/public/cpp/interface_registry.h" | 14 #include "services/shell/public/cpp/interface_registry.h" |
12 | 15 |
13 namespace blimp { | 16 namespace blimp { |
14 namespace engine { | 17 namespace engine { |
15 | 18 |
16 namespace { | 19 namespace { |
17 // A provider of services needed by Geolocation. | 20 // A provider of services needed by Geolocation. |
18 class BlimpGeolocationDelegate : public content::GeolocationDelegate { | 21 class BlimpGeolocationDelegate : public content::GeolocationDelegate { |
19 public: | 22 public: |
20 BlimpGeolocationDelegate() = default; | 23 explicit BlimpGeolocationDelegate( |
24 base::WeakPtr<EngineGeolocationFeature> feature) { | |
Wez
2016/07/12 21:35:12
nit: Looks like you mean to just pass WeakPtr<Blim
CJ
2016/07/13 21:49:19
Done.
| |
25 feature_ = feature; | |
26 } | |
21 | 27 |
22 bool UseNetworkLocationProviders() final { return false; } | 28 bool UseNetworkLocationProviders() final { return false; } |
23 | 29 |
24 std::unique_ptr<content::LocationProvider> OverrideSystemLocationProvider() | 30 std::unique_ptr<content::LocationProvider> |
25 final { | 31 OverrideSystemLocationProvider() final { |
26 return base::WrapUnique(new BlimpLocationProvider()); | 32 BlimpLocationProvider* location_provider = new BlimpLocationProvider(); |
33 location_provider->SetDelegate(feature_); | |
34 return base::WrapUnique(location_provider); | |
27 } | 35 } |
28 | 36 |
29 private: | 37 private: |
38 base::WeakPtr<BlimpLocationProvider::Delegate> feature_; | |
Wez
2016/07/12 21:35:12
You're assigning this from an EngineGeolocationFea
CJ
2016/07/13 21:49:19
It does. EngineGeolocationFeature is a BlimpLocati
Wez
2016/07/14 01:19:21
Right, but it's strange to require that the caller
CJ
2016/07/14 23:55:08
Acknowledged.
| |
39 | |
30 DISALLOW_COPY_AND_ASSIGN(BlimpGeolocationDelegate); | 40 DISALLOW_COPY_AND_ASSIGN(BlimpGeolocationDelegate); |
31 }; | 41 }; |
32 | 42 |
33 } // anonymous namespace | 43 } // anonymous namespace |
34 | 44 |
35 BlimpContentBrowserClient::BlimpContentBrowserClient() {} | 45 BlimpContentBrowserClient::BlimpContentBrowserClient() {} |
36 | 46 |
37 BlimpContentBrowserClient::~BlimpContentBrowserClient() {} | 47 BlimpContentBrowserClient::~BlimpContentBrowserClient() {} |
38 | 48 |
39 content::BrowserMainParts* BlimpContentBrowserClient::CreateBrowserMainParts( | 49 content::BrowserMainParts* BlimpContentBrowserClient::CreateBrowserMainParts( |
(...skipping 15 matching lines...) Expand all Loading... | |
55 blimp_browser_main_parts_->GetSettingsManager()->UpdateWebkitPreferences( | 65 blimp_browser_main_parts_->GetSettingsManager()->UpdateWebkitPreferences( |
56 prefs); | 66 prefs); |
57 } | 67 } |
58 | 68 |
59 BlimpBrowserContext* BlimpContentBrowserClient::GetBrowserContext() { | 69 BlimpBrowserContext* BlimpContentBrowserClient::GetBrowserContext() { |
60 return blimp_browser_main_parts_->GetBrowserContext(); | 70 return blimp_browser_main_parts_->GetBrowserContext(); |
61 } | 71 } |
62 | 72 |
63 content::GeolocationDelegate* | 73 content::GeolocationDelegate* |
64 BlimpContentBrowserClient::CreateGeolocationDelegate() { | 74 BlimpContentBrowserClient::CreateGeolocationDelegate() { |
65 return new BlimpGeolocationDelegate(); | 75 EngineGeolocationFeature* geolocation_feature = blimp_browser_main_parts() |
76 ->GetBlimpEngineSession() | |
77 ->GetGeolocationFeature(); | |
Wez
2016/07/12 21:35:12
nit: Is this the git cl format preferred line-wrap
CJ
2016/07/13 21:49:19
Yes.
| |
78 BlimpGeolocationDelegate* delegate = | |
79 new BlimpGeolocationDelegate(geolocation_feature->GetWeakPtr()); | |
Wez
2016/07/12 21:35:13
Rather than expose WeakPtr<EngineGelocationFeature
CJ
2016/07/13 21:49:19
BlimpGeolocationDelegate has nothing to do with En
Wez
2016/07/14 01:19:21
I'm not sure what you mean by "has nothing to do w
CJ
2016/07/14 23:55:08
Done.
| |
80 return delegate; | |
66 } | 81 } |
67 | 82 |
68 void BlimpContentBrowserClient::ExposeInterfacesToRenderer( | 83 void BlimpContentBrowserClient::ExposeInterfacesToRenderer( |
69 shell::InterfaceRegistry* registry, | 84 shell::InterfaceRegistry* registry, |
70 content::RenderProcessHost* render_process_host) { | 85 content::RenderProcessHost* render_process_host) { |
71 registry->AddInterface<mojom::BlobChannel>( | 86 registry->AddInterface<mojom::BlobChannel>( |
72 base::Bind(&BlobChannelService::Create, | 87 base::Bind(&BlobChannelService::Create, |
73 blimp_browser_main_parts_->GetBlobChannelSender())); | 88 blimp_browser_main_parts_->GetBlobChannelSender())); |
74 } | 89 } |
75 | 90 |
76 } // namespace engine | 91 } // namespace engine |
77 } // namespace blimp | 92 } // namespace blimp |
OLD | NEW |