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 // Webkit compares the timestamp to wall clock time, so we need it to be | 81 position_.timestamp = base::Time::FromDoubleT(4567.8); |
82 // contemporary. | |
83 position_.timestamp = base::Time::Now(); | |
84 } else { | 82 } else { |
85 position_.error_code = Geoposition::ERROR_CODE_POSITION_UNAVAILABLE; | 83 position_.error_code = Geoposition::ERROR_CODE_POSITION_UNAVAILABLE; |
86 } | 84 } |
87 } | 85 } |
88 virtual bool StartProvider(bool high_accuracy) { | 86 virtual bool StartProvider(bool high_accuracy) { |
89 MockLocationProvider::StartProvider(high_accuracy); | 87 MockLocationProvider::StartProvider(high_accuracy); |
90 if (!requires_permission_to_start_) { | 88 if (!requires_permission_to_start_) { |
91 UpdateListenersIfNeeded(); | 89 UpdateListenersIfNeeded(); |
92 } | 90 } |
93 return true; | 91 return true; |
(...skipping 28 matching lines...) Expand all Loading... |
122 return new AutoMockLocationProvider(true, false); | 120 return new AutoMockLocationProvider(true, false); |
123 } | 121 } |
124 | 122 |
125 LocationProviderBase* NewAutoFailMockLocationProvider() { | 123 LocationProviderBase* NewAutoFailMockLocationProvider() { |
126 return new AutoMockLocationProvider(false, false); | 124 return new AutoMockLocationProvider(false, false); |
127 } | 125 } |
128 | 126 |
129 LocationProviderBase* NewAutoSuccessMockNetworkLocationProvider() { | 127 LocationProviderBase* NewAutoSuccessMockNetworkLocationProvider() { |
130 return new AutoMockLocationProvider(true, true); | 128 return new AutoMockLocationProvider(true, true); |
131 } | 129 } |
OLD | NEW |