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 <utility> |
8 #include <vector> | 9 #include <vector> |
9 | 10 |
10 #include "base/bind.h" | 11 #include "base/bind.h" |
11 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
12 #include "base/macros.h" | 13 #include "base/macros.h" |
13 #include "base/time/time.h" | 14 #include "base/time/time.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/common/geoposition.h" | 18 #include "content/public/common/geoposition.h" |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 histogram_value = events::LOCATION_ON_LOCATION_UPDATE; | 330 histogram_value = events::LOCATION_ON_LOCATION_UPDATE; |
330 event_name = location::OnLocationUpdate::kEventName; | 331 event_name = location::OnLocationUpdate::kEventName; |
331 } else { | 332 } else { |
332 // Set data for onLocationError event. | 333 // Set data for onLocationError event. |
333 // TODO(vadimt): Set name. | 334 // TODO(vadimt): Set name. |
334 args->AppendString(position.error_message); | 335 args->AppendString(position.error_message); |
335 histogram_value = events::LOCATION_ON_LOCATION_ERROR; | 336 histogram_value = events::LOCATION_ON_LOCATION_ERROR; |
336 event_name = location::OnLocationError::kEventName; | 337 event_name = location::OnLocationError::kEventName; |
337 } | 338 } |
338 | 339 |
339 scoped_ptr<Event> event(new Event(histogram_value, event_name, args.Pass())); | 340 scoped_ptr<Event> event( |
| 341 new Event(histogram_value, event_name, std::move(args))); |
340 | 342 |
341 EventRouter::Get(browser_context_) | 343 EventRouter::Get(browser_context_) |
342 ->DispatchEventToExtension(extension_id, event.Pass()); | 344 ->DispatchEventToExtension(extension_id, std::move(event)); |
343 } | 345 } |
344 | 346 |
345 void LocationManager::OnExtensionLoaded( | 347 void LocationManager::OnExtensionLoaded( |
346 content::BrowserContext* browser_context, | 348 content::BrowserContext* browser_context, |
347 const Extension* extension) { | 349 const Extension* extension) { |
348 // Grants permission to use geolocation once an extension with "location" | 350 // Grants permission to use geolocation once an extension with "location" |
349 // permission is loaded. | 351 // permission is loaded. |
350 if (extension->permissions_data()->HasAPIPermission( | 352 if (extension->permissions_data()->HasAPIPermission( |
351 APIPermission::kLocation)) { | 353 APIPermission::kLocation)) { |
352 content::GeolocationProvider::GetInstance() | 354 content::GeolocationProvider::GetInstance() |
(...skipping 17 matching lines...) Expand all Loading... |
370 LocationManager::GetFactoryInstance() { | 372 LocationManager::GetFactoryInstance() { |
371 return g_factory.Pointer(); | 373 return g_factory.Pointer(); |
372 } | 374 } |
373 | 375 |
374 // static | 376 // static |
375 LocationManager* LocationManager::Get(content::BrowserContext* context) { | 377 LocationManager* LocationManager::Get(content::BrowserContext* context) { |
376 return BrowserContextKeyedAPIFactory<LocationManager>::Get(context); | 378 return BrowserContextKeyedAPIFactory<LocationManager>::Get(context); |
377 } | 379 } |
378 | 380 |
379 } // namespace extensions | 381 } // namespace extensions |
OLD | NEW |