| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "chrome/browser/extensions/api/location/location_manager.h" | 5 #include "chrome/browser/extensions/api/location/location_manager.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
| 12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
| 13 #include "chrome/browser/chrome_notification_types.h" | 13 #include "chrome/browser/chrome_notification_types.h" |
| 14 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/common/extensions/api/location.h" | 15 #include "chrome/common/extensions/api/location.h" |
| 15 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
| 16 #include "content/public/browser/geolocation_provider.h" | 17 #include "content/public/browser/geolocation_provider.h" |
| 17 #include "content/public/browser/notification_details.h" | 18 #include "content/public/browser/notification_details.h" |
| 18 #include "content/public/browser/notification_source.h" | 19 #include "content/public/browser/notification_source.h" |
| 19 #include "content/public/common/geoposition.h" | 20 #include "content/public/common/geoposition.h" |
| 20 #include "extensions/browser/event_router.h" | 21 #include "extensions/browser/event_router.h" |
| 21 #include "extensions/browser/extension_system.h" | 22 #include "extensions/browser/extension_system.h" |
| 22 #include "extensions/common/extension.h" | 23 #include "extensions/common/extension.h" |
| 23 #include "extensions/common/permissions/permission_set.h" | 24 #include "extensions/common/permissions/permission_set.h" |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 | 290 |
| 290 void LocationRequest::OnPositionReported(const content::Geoposition& position) { | 291 void LocationRequest::OnPositionReported(const content::Geoposition& position) { |
| 291 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 292 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 292 for (UpdatePolicyVector::iterator it = update_policies_.begin(); | 293 for (UpdatePolicyVector::iterator it = update_policies_.begin(); |
| 293 it != update_policies_.end(); | 294 it != update_policies_.end(); |
| 294 ++it) { | 295 ++it) { |
| 295 (*it)->OnPositionReported(position); | 296 (*it)->OnPositionReported(position); |
| 296 } | 297 } |
| 297 } | 298 } |
| 298 | 299 |
| 299 LocationManager::LocationManager(Profile* profile) | 300 LocationManager::LocationManager(content::BrowserContext* context) |
| 300 : profile_(profile) { | 301 : profile_(Profile::FromBrowserContext(context)) { |
| 301 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, | 302 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, |
| 302 content::Source<Profile>(profile_)); | 303 content::Source<Profile>(profile_)); |
| 303 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, | 304 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, |
| 304 content::Source<Profile>(profile_)); | 305 content::Source<Profile>(profile_)); |
| 305 } | 306 } |
| 306 | 307 |
| 307 void LocationManager::AddLocationRequest( | 308 void LocationManager::AddLocationRequest( |
| 308 const std::string& extension_id, | 309 const std::string& extension_id, |
| 309 const std::string& request_name, | 310 const std::string& request_name, |
| 310 const double* distance_update_threshold_meters, | 311 const double* distance_update_threshold_meters, |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 | 432 |
| 432 static base::LazyInstance<ProfileKeyedAPIFactory<LocationManager> > | 433 static base::LazyInstance<ProfileKeyedAPIFactory<LocationManager> > |
| 433 g_factory = LAZY_INSTANCE_INITIALIZER; | 434 g_factory = LAZY_INSTANCE_INITIALIZER; |
| 434 | 435 |
| 435 // static | 436 // static |
| 436 ProfileKeyedAPIFactory<LocationManager>* LocationManager::GetFactoryInstance() { | 437 ProfileKeyedAPIFactory<LocationManager>* LocationManager::GetFactoryInstance() { |
| 437 return g_factory.Pointer(); | 438 return g_factory.Pointer(); |
| 438 } | 439 } |
| 439 | 440 |
| 440 // static | 441 // static |
| 441 LocationManager* LocationManager::Get(Profile* profile) { | 442 LocationManager* LocationManager::Get(content::BrowserContext* context) { |
| 442 return ProfileKeyedAPIFactory<LocationManager>::GetForProfile(profile); | 443 return ProfileKeyedAPIFactory<LocationManager>::GetForProfile(context); |
| 443 } | 444 } |
| 444 | 445 |
| 445 } // namespace extensions | 446 } // namespace extensions |
| OLD | NEW |