| 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_api.h" | 5 #include "chrome/browser/extensions/api/location/location_api.h" |
| 6 | 6 |
| 7 #include "chrome/browser/extensions/api/location/location_manager.h" | 7 #include "chrome/browser/extensions/api/location/location_manager.h" |
| 8 #include "chrome/browser/profiles/profile.h" | |
| 9 #include "chrome/common/extensions/api/location.h" | 8 #include "chrome/common/extensions/api/location.h" |
| 10 #include "extensions/common/error_utils.h" | 9 #include "extensions/common/error_utils.h" |
| 11 | 10 |
| 12 // TODO(vadimt): add tests. | 11 // TODO(vadimt): add tests. |
| 13 | 12 |
| 14 namespace location = extensions::api::location; | 13 namespace location = extensions::api::location; |
| 15 namespace WatchLocation = location::WatchLocation; | 14 namespace WatchLocation = location::WatchLocation; |
| 16 namespace ClearWatch = location::ClearWatch; | 15 namespace ClearWatch = location::ClearWatch; |
| 17 | 16 |
| 18 namespace extensions { | 17 namespace extensions { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 42 double* min_time_in_milliseconds = | 41 double* min_time_in_milliseconds = |
| 43 params->request_info.min_time_in_milliseconds.get(); | 42 params->request_info.min_time_in_milliseconds.get(); |
| 44 if (IsNegative(min_time_in_milliseconds)) { | 43 if (IsNegative(min_time_in_milliseconds)) { |
| 45 error_ = ErrorUtils::FormatErrorMessage( | 44 error_ = ErrorUtils::FormatErrorMessage( |
| 46 kMustBePositive, | 45 kMustBePositive, |
| 47 kMinTimeInMilliseconds); | 46 kMinTimeInMilliseconds); |
| 48 return false; | 47 return false; |
| 49 } | 48 } |
| 50 | 49 |
| 51 // TODO(vadimt): validate and use params->request_info.maximumAge | 50 // TODO(vadimt): validate and use params->request_info.maximumAge |
| 52 LocationManager::Get(GetProfile()) | 51 LocationManager::Get(browser_context()) |
| 53 ->AddLocationRequest(extension_id(), | 52 ->AddLocationRequest(extension_id(), |
| 54 params->name, | 53 params->name, |
| 55 min_distance_in_meters, | 54 min_distance_in_meters, |
| 56 min_time_in_milliseconds); | 55 min_time_in_milliseconds); |
| 57 | 56 |
| 58 return true; | 57 return true; |
| 59 } | 58 } |
| 60 | 59 |
| 61 bool LocationClearWatchFunction::RunSync() { | 60 bool LocationClearWatchFunction::RunSync() { |
| 62 scoped_ptr<ClearWatch::Params> params( | 61 scoped_ptr<ClearWatch::Params> params( |
| 63 ClearWatch::Params::Create(*args_)); | 62 ClearWatch::Params::Create(*args_)); |
| 64 EXTENSION_FUNCTION_VALIDATE(params.get()); | 63 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 65 | 64 |
| 66 LocationManager::Get(GetProfile()) | 65 LocationManager::Get(browser_context()) |
| 67 ->RemoveLocationRequest(extension_id(), params->name); | 66 ->RemoveLocationRequest(extension_id(), params->name); |
| 68 | 67 |
| 69 return true; | 68 return true; |
| 70 } | 69 } |
| 71 | 70 |
| 72 } // namespace extensions | 71 } // namespace extensions |
| OLD | NEW |