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/browser/profiles/profile.h" |
15 #include "chrome/common/extensions/api/location.h" | 15 #include "chrome/common/extensions/api/location.h" |
16 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
17 #include "content/public/browser/geolocation_provider.h" | 17 #include "content/public/browser/geolocation_provider.h" |
18 #include "content/public/browser/notification_details.h" | 18 #include "content/public/browser/notification_details.h" |
19 #include "content/public/browser/notification_source.h" | 19 #include "content/public/browser/notification_source.h" |
20 #include "content/public/common/geoposition.h" | 20 #include "content/public/common/geoposition.h" |
21 #include "extensions/browser/event_router.h" | 21 #include "extensions/browser/event_router.h" |
22 #include "extensions/browser/extension_system.h" | 22 #include "extensions/browser/extension_system.h" |
23 #include "extensions/common/extension.h" | 23 #include "extensions/common/extension.h" |
24 #include "extensions/common/permissions/permission_set.h" | 24 #include "extensions/common/permissions/permission_set.h" |
| 25 #include "extensions/common/permissions/permissions_data.h" |
25 | 26 |
26 using content::BrowserThread; | 27 using content::BrowserThread; |
27 | 28 |
28 // TODO(vadimt): Add tests. | 29 // TODO(vadimt): Add tests. |
29 namespace extensions { | 30 namespace extensions { |
30 | 31 |
31 namespace location = api::location; | 32 namespace location = api::location; |
32 | 33 |
33 namespace updatepolicy { | 34 namespace updatepolicy { |
34 | 35 |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 const content::NotificationDetails& details) { | 352 const content::NotificationDetails& details) { |
352 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 353 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
353 | 354 |
354 switch (type) { | 355 switch (type) { |
355 case chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED: { | 356 case chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED: { |
356 // Grants permission to use geolocation once an extension with "location" | 357 // Grants permission to use geolocation once an extension with "location" |
357 // permission is loaded. | 358 // permission is loaded. |
358 const Extension* extension = | 359 const Extension* extension = |
359 content::Details<const Extension>(details).ptr(); | 360 content::Details<const Extension>(details).ptr(); |
360 | 361 |
361 if (extension->HasAPIPermission(APIPermission::kLocation)) { | 362 if (extension->permissions_data()->HasAPIPermission( |
| 363 APIPermission::kLocation)) { |
362 content::GeolocationProvider::GetInstance()-> | 364 content::GeolocationProvider::GetInstance()-> |
363 UserDidOptIntoLocationServices(); | 365 UserDidOptIntoLocationServices(); |
364 } | 366 } |
365 break; | 367 break; |
366 } | 368 } |
367 case chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: { | 369 case chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: { |
368 // Delete all requests from the unloaded extension. | 370 // Delete all requests from the unloaded extension. |
369 const Extension* extension = | 371 const Extension* extension = |
370 content::Details<const UnloadedExtensionInfo>(details)->extension; | 372 content::Details<const UnloadedExtensionInfo>(details)->extension; |
371 location_requests_.erase(extension->id()); | 373 location_requests_.erase(extension->id()); |
(...skipping 13 matching lines...) Expand all Loading... |
385 LocationManager::GetFactoryInstance() { | 387 LocationManager::GetFactoryInstance() { |
386 return g_factory.Pointer(); | 388 return g_factory.Pointer(); |
387 } | 389 } |
388 | 390 |
389 // static | 391 // static |
390 LocationManager* LocationManager::Get(content::BrowserContext* context) { | 392 LocationManager* LocationManager::Get(content::BrowserContext* context) { |
391 return BrowserContextKeyedAPIFactory<LocationManager>::Get(context); | 393 return BrowserContextKeyedAPIFactory<LocationManager>::Get(context); |
392 } | 394 } |
393 | 395 |
394 } // namespace extensions | 396 } // namespace extensions |
OLD | NEW |