| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/geolocation/mock_location_provider.h" | 8 #include "content/browser/geolocation/mock_location_provider.h" |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 position_.accuracy = 3; | 79 position_.accuracy = 3; |
| 80 position_.latitude = 4.3; | 80 position_.latitude = 4.3; |
| 81 position_.longitude = -7.8; | 81 position_.longitude = -7.8; |
| 82 // Webkit compares the timestamp to wall clock time, so we need it to be | 82 // Webkit compares the timestamp to wall clock time, so we need it to be |
| 83 // contemporary. | 83 // contemporary. |
| 84 position_.timestamp = base::Time::Now(); | 84 position_.timestamp = base::Time::Now(); |
| 85 } else { | 85 } else { |
| 86 position_.error_code = Geoposition::ERROR_CODE_POSITION_UNAVAILABLE; | 86 position_.error_code = Geoposition::ERROR_CODE_POSITION_UNAVAILABLE; |
| 87 } | 87 } |
| 88 } | 88 } |
| 89 virtual bool StartProvider(bool high_accuracy) OVERRIDE { | 89 virtual bool StartProvider(bool high_accuracy) override { |
| 90 MockLocationProvider::StartProvider(high_accuracy); | 90 MockLocationProvider::StartProvider(high_accuracy); |
| 91 if (!requires_permission_to_start_) { | 91 if (!requires_permission_to_start_) { |
| 92 UpdateListenersIfNeeded(); | 92 UpdateListenersIfNeeded(); |
| 93 } | 93 } |
| 94 return true; | 94 return true; |
| 95 } | 95 } |
| 96 | 96 |
| 97 virtual void OnPermissionGranted() OVERRIDE { | 97 virtual void OnPermissionGranted() override { |
| 98 MockLocationProvider::OnPermissionGranted(); | 98 MockLocationProvider::OnPermissionGranted(); |
| 99 if (requires_permission_to_start_) { | 99 if (requires_permission_to_start_) { |
| 100 UpdateListenersIfNeeded(); | 100 UpdateListenersIfNeeded(); |
| 101 } | 101 } |
| 102 } | 102 } |
| 103 | 103 |
| 104 void UpdateListenersIfNeeded() { | 104 void UpdateListenersIfNeeded() { |
| 105 if (!listeners_updated_) { | 105 if (!listeners_updated_) { |
| 106 listeners_updated_ = true; | 106 listeners_updated_ = true; |
| 107 base::MessageLoop::current()->PostTask( | 107 base::MessageLoop::current()->PostTask( |
| (...skipping 19 matching lines...) Expand all Loading... |
| 127 | 127 |
| 128 LocationProvider* NewAutoFailMockLocationProvider() { | 128 LocationProvider* NewAutoFailMockLocationProvider() { |
| 129 return new AutoMockLocationProvider(false, false); | 129 return new AutoMockLocationProvider(false, false); |
| 130 } | 130 } |
| 131 | 131 |
| 132 LocationProvider* NewAutoSuccessMockNetworkLocationProvider() { | 132 LocationProvider* NewAutoSuccessMockNetworkLocationProvider() { |
| 133 return new AutoMockLocationProvider(true, true); | 133 return new AutoMockLocationProvider(true, true); |
| 134 } | 134 } |
| 135 | 135 |
| 136 } // namespace content | 136 } // namespace content |
| OLD | NEW |