Home | History | Annotate | Download | only in geolocation
      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.
      4 
      5 #include "content/browser/geolocation/location_provider_android.h"
      6 
      7 #include "base/time/time.h"
      8 #include "content/browser/geolocation/location_api_adapter_android.h"
      9 #include "content/public/common/geoposition.h"
     10 
     11 namespace content {
     12 
     13 // LocationProviderAndroid
     14 LocationProviderAndroid::LocationProviderAndroid() {
     15 }
     16 
     17 LocationProviderAndroid::~LocationProviderAndroid() {
     18   StopProvider();
     19 }
     20 
     21 void LocationProviderAndroid::NotifyNewGeoposition(
     22     const Geoposition& position) {
     23   last_position_ = position;
     24   NotifyCallback(last_position_);
     25 }
     26 
     27 bool LocationProviderAndroid::StartProvider(bool high_accuracy) {
     28   return AndroidLocationApiAdapter::GetInstance()->Start(this, high_accuracy);
     29 }
     30 
     31 void LocationProviderAndroid::StopProvider() {
     32   AndroidLocationApiAdapter::GetInstance()->Stop();
     33 }
     34 
     35 void LocationProviderAndroid::GetPosition(Geoposition* position) {
     36   *position = last_position_;
     37 }
     38 
     39 void LocationProviderAndroid::RequestRefresh() {
     40   // Nothing to do here, android framework will call us back on new position.
     41 }
     42 
     43 void LocationProviderAndroid::OnPermissionGranted() {
     44   // Nothing to do here.
     45 }
     46 
     47 LocationProvider* NewSystemLocationProvider() {
     48   return new LocationProviderAndroid;
     49 }
     50 
     51 }  // namespace content
     52