[content shell] implement testRunner.overridePreference
[chromium-blink-merge.git] / content / browser / geolocation / core_location_provider_mac.mm
blob0380247e00e0e6c9d1ac6a04331816e6eab93b71
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
3 // found in the LICENSE file.
5 #include "content/browser/geolocation/core_location_provider_mac.h"
7 #include "base/logging.h"
8 #include "base/command_line.h"
9 #include "content/browser/geolocation/core_location_data_provider_mac.h"
10 #include "content/public/common/content_switches.h"
12 namespace content {
14 CoreLocationProviderMac::CoreLocationProviderMac()
15     : is_updating_(false) {
16   data_provider_ = new CoreLocationDataProviderMac();
17   data_provider_->AddRef();
20 CoreLocationProviderMac::~CoreLocationProviderMac() {
21   data_provider_->StopUpdating();
22   data_provider_->Release();
25 bool CoreLocationProviderMac::StartProvider(bool high_accuracy) {
26   // StartProvider maybe called multiple times. For example, to update the high
27   // accuracy hint.
28   // TODO(jknotten): Support high_accuracy hint in underlying data provider.
29   if (is_updating_)
30     return true;
32   is_updating_ = data_provider_->StartUpdating(this);
33   return true;
36 void CoreLocationProviderMac::StopProvider() {
37   data_provider_->StopUpdating();
38   is_updating_ = false;
41 void CoreLocationProviderMac::GetPosition(Geoposition* position) {
42   DCHECK(position);
43   *position = position_;
44   DCHECK(position->Validate() ||
45          position->error_code != Geoposition::ERROR_CODE_NONE);
48 void CoreLocationProviderMac::SetPosition(Geoposition* position) {
49   DCHECK(position);
50   position_ = *position;
51   DCHECK(position->Validate() ||
52          position->error_code != Geoposition::ERROR_CODE_NONE);
53   UpdateListeners();
56 LocationProviderBase* NewSystemLocationProvider() {
57   if (CommandLine::ForCurrentProcess()->HasSwitch(
58           switches::kExperimentalLocationFeatures)) {
59     return new CoreLocationProviderMac;
60   }
61   return NULL;
64 }  // namespace content