| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/geolocation/geolocation_provider_impl.h" | 5 #include "content/browser/geolocation/geolocation_provider_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 13 #include "base/memory/singleton.h" | 13 #include "base/memory/singleton.h" |
| 14 #include "base/single_thread_task_runner.h" | 14 #include "base/single_thread_task_runner.h" |
| 15 #include "content/browser/geolocation/location_arbitrator_impl.h" | 15 #include "content/browser/geolocation/location_arbitrator_impl.h" |
| 16 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
| 17 #include "content/public/browser/content_browser_client.h" |
| 17 | 18 |
| 18 namespace content { | 19 namespace content { |
| 19 | 20 |
| 20 GeolocationProvider* GeolocationProvider::GetInstance() { | 21 GeolocationProvider* GeolocationProvider::GetInstance() { |
| 21 return GeolocationProviderImpl::GetInstance(); | 22 return GeolocationProviderImpl::GetInstance(); |
| 22 } | 23 } |
| 23 | 24 |
| 24 std::unique_ptr<GeolocationProvider::Subscription> | 25 std::unique_ptr<GeolocationProvider::Subscription> |
| 25 GeolocationProviderImpl::AddLocationUpdateCallback( | 26 GeolocationProviderImpl::AddLocationUpdateCallback( |
| 26 const LocationUpdateCallback& callback, | 27 const LocationUpdateCallback& callback, |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 | 168 |
| 168 void GeolocationProviderImpl::CleanUp() { | 169 void GeolocationProviderImpl::CleanUp() { |
| 169 DCHECK(OnGeolocationThread()); | 170 DCHECK(OnGeolocationThread()); |
| 170 arbitrator_.reset(); | 171 arbitrator_.reset(); |
| 171 } | 172 } |
| 172 | 173 |
| 173 std::unique_ptr<LocationArbitrator> | 174 std::unique_ptr<LocationArbitrator> |
| 174 GeolocationProviderImpl::CreateArbitrator() { | 175 GeolocationProviderImpl::CreateArbitrator() { |
| 175 LocationArbitratorImpl::LocationUpdateCallback callback = base::Bind( | 176 LocationArbitratorImpl::LocationUpdateCallback callback = base::Bind( |
| 176 &GeolocationProviderImpl::OnLocationUpdate, base::Unretained(this)); | 177 &GeolocationProviderImpl::OnLocationUpdate, base::Unretained(this)); |
| 177 return base::WrapUnique(new LocationArbitratorImpl(callback)); | 178 |
| 179 // Use the embedder's Delegate or fall back to the default one. |
| 180 delegate_.reset(GetContentClient()->browser()->CreateGeolocationDelegate()); |
| 181 if (!delegate_) |
| 182 delegate_.reset(new GeolocationProvider::Delegate); |
| 183 |
| 184 return base::WrapUnique( |
| 185 new LocationArbitratorImpl(callback, delegate_.get())); |
| 178 } | 186 } |
| 179 | 187 |
| 180 } // namespace content | 188 } // namespace content |
| OLD | NEW |