| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // This file implements a mock location provider and the factory functions for | 5 // This file implements a mock location provider and the factory functions for |
| 6 // various ways of creating it. | 6 // various ways of creating it. |
| 7 | 7 |
| 8 #include "chrome/browser/geolocation/mock_location_provider.h" | 8 #include "chrome/browser/geolocation/mock_location_provider.h" |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 AutoMockLocationProvider(bool has_valid_location, | 71 AutoMockLocationProvider(bool has_valid_location, |
| 72 bool requires_permission_to_start) | 72 bool requires_permission_to_start) |
| 73 : MockLocationProvider(&instance_), | 73 : MockLocationProvider(&instance_), |
| 74 ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)), | 74 ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)), |
| 75 requires_permission_to_start_(requires_permission_to_start), | 75 requires_permission_to_start_(requires_permission_to_start), |
| 76 listeners_updated_(false) { | 76 listeners_updated_(false) { |
| 77 if (has_valid_location) { | 77 if (has_valid_location) { |
| 78 position_.accuracy = 3; | 78 position_.accuracy = 3; |
| 79 position_.latitude = 4.3; | 79 position_.latitude = 4.3; |
| 80 position_.longitude = -7.8; | 80 position_.longitude = -7.8; |
| 81 position_.timestamp = base::Time::FromDoubleT(4567.8); | 81 // Webkit compares the timestamp to wall clock time, so we need it to be |
| 82 // contemporary. |
| 83 position_.timestamp = base::Time::Now(); |
| 82 } else { | 84 } else { |
| 83 position_.error_code = Geoposition::ERROR_CODE_POSITION_UNAVAILABLE; | 85 position_.error_code = Geoposition::ERROR_CODE_POSITION_UNAVAILABLE; |
| 84 } | 86 } |
| 85 } | 87 } |
| 86 virtual bool StartProvider(bool high_accuracy) { | 88 virtual bool StartProvider(bool high_accuracy) { |
| 87 MockLocationProvider::StartProvider(high_accuracy); | 89 MockLocationProvider::StartProvider(high_accuracy); |
| 88 if (!requires_permission_to_start_) { | 90 if (!requires_permission_to_start_) { |
| 89 UpdateListenersIfNeeded(); | 91 UpdateListenersIfNeeded(); |
| 90 } | 92 } |
| 91 return true; | 93 return true; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 120 return new AutoMockLocationProvider(true, false); | 122 return new AutoMockLocationProvider(true, false); |
| 121 } | 123 } |
| 122 | 124 |
| 123 LocationProviderBase* NewAutoFailMockLocationProvider() { | 125 LocationProviderBase* NewAutoFailMockLocationProvider() { |
| 124 return new AutoMockLocationProvider(false, false); | 126 return new AutoMockLocationProvider(false, false); |
| 125 } | 127 } |
| 126 | 128 |
| 127 LocationProviderBase* NewAutoSuccessMockNetworkLocationProvider() { | 129 LocationProviderBase* NewAutoSuccessMockNetworkLocationProvider() { |
| 128 return new AutoMockLocationProvider(true, true); | 130 return new AutoMockLocationProvider(true, true); |
| 129 } | 131 } |
| OLD | NEW |