| 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" |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 292 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 293 for (UpdatePolicyVector::iterator it = update_policies_.begin(); | 293 for (UpdatePolicyVector::iterator it = update_policies_.begin(); |
| 294 it != update_policies_.end(); | 294 it != update_policies_.end(); |
| 295 ++it) { | 295 ++it) { |
| 296 (*it)->OnPositionReported(position); | 296 (*it)->OnPositionReported(position); |
| 297 } | 297 } |
| 298 } | 298 } |
| 299 | 299 |
| 300 LocationManager::LocationManager(content::BrowserContext* context) | 300 LocationManager::LocationManager(content::BrowserContext* context) |
| 301 : profile_(Profile::FromBrowserContext(context)) { | 301 : profile_(Profile::FromBrowserContext(context)) { |
| 302 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, | 302 registrar_.Add(this, |
| 303 chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, |
| 303 content::Source<Profile>(profile_)); | 304 content::Source<Profile>(profile_)); |
| 304 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, | 305 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, |
| 305 content::Source<Profile>(profile_)); | 306 content::Source<Profile>(profile_)); |
| 306 } | 307 } |
| 307 | 308 |
| 308 void LocationManager::AddLocationRequest( | 309 void LocationManager::AddLocationRequest( |
| 309 const std::string& extension_id, | 310 const std::string& extension_id, |
| 310 const std::string& request_name, | 311 const std::string& request_name, |
| 311 const double* distance_update_threshold_meters, | 312 const double* distance_update_threshold_meters, |
| 312 const double* time_between_updates_ms) { | 313 const double* time_between_updates_ms) { |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 EventRouter::Get(profile_) | 397 EventRouter::Get(profile_) |
| 397 ->DispatchEventToExtension(extension_id, event.Pass()); | 398 ->DispatchEventToExtension(extension_id, event.Pass()); |
| 398 } | 399 } |
| 399 | 400 |
| 400 void LocationManager::Observe(int type, | 401 void LocationManager::Observe(int type, |
| 401 const content::NotificationSource& source, | 402 const content::NotificationSource& source, |
| 402 const content::NotificationDetails& details) { | 403 const content::NotificationDetails& details) { |
| 403 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 404 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 404 | 405 |
| 405 switch (type) { | 406 switch (type) { |
| 406 case chrome::NOTIFICATION_EXTENSION_LOADED: { | 407 case chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED: { |
| 407 // Grants permission to use geolocation once an extension with "location" | 408 // Grants permission to use geolocation once an extension with "location" |
| 408 // permission is loaded. | 409 // permission is loaded. |
| 409 const Extension* extension = | 410 const Extension* extension = |
| 410 content::Details<const Extension>(details).ptr(); | 411 content::Details<const Extension>(details).ptr(); |
| 411 | 412 |
| 412 if (extension->HasAPIPermission(APIPermission::kLocation)) { | 413 if (extension->HasAPIPermission(APIPermission::kLocation)) { |
| 413 BrowserThread::PostTask( | 414 BrowserThread::PostTask( |
| 414 BrowserThread::IO, | 415 BrowserThread::IO, |
| 415 FROM_HERE, | 416 FROM_HERE, |
| 416 base::Bind(&LocationRequest::GrantPermission)); | 417 base::Bind(&LocationRequest::GrantPermission)); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 438 LocationManager::GetFactoryInstance() { | 439 LocationManager::GetFactoryInstance() { |
| 439 return g_factory.Pointer(); | 440 return g_factory.Pointer(); |
| 440 } | 441 } |
| 441 | 442 |
| 442 // static | 443 // static |
| 443 LocationManager* LocationManager::Get(content::BrowserContext* context) { | 444 LocationManager* LocationManager::Get(content::BrowserContext* context) { |
| 444 return BrowserContextKeyedAPIFactory<LocationManager>::Get(context); | 445 return BrowserContextKeyedAPIFactory<LocationManager>::Get(context); |
| 445 } | 446 } |
| 446 | 447 |
| 447 } // namespace extensions | 448 } // namespace extensions |
| OLD | NEW |