1bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant// Copyright (c) 2012 The Chromium Authors. All rights reserved.
2bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant// Use of this source code is governed by a BSD-style license that can be
3f5256e16dfc425c1d466f6308d4026d529ce9e0bHoward Hinnant// found in the LICENSE file.
4bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant
5b64f8b07c104c6cc986570ac8ee0ed16a9f23976Howard Hinnant#include "content/browser/geolocation/location_provider_android.h"
6b64f8b07c104c6cc986570ac8ee0ed16a9f23976Howard Hinnant
7bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant#include "base/time/time.h"
8bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant#include "content/browser/geolocation/location_api_adapter_android.h"
9bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant#include "content/public/common/geoposition.h"
10bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant
11bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnantnamespace content {
12bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant
13// LocationProviderAndroid
14LocationProviderAndroid::LocationProviderAndroid() {
15}
16
17LocationProviderAndroid::~LocationProviderAndroid() {
18  StopProvider();
19}
20
21void LocationProviderAndroid::NotifyNewGeoposition(
22    const Geoposition& position) {
23  last_position_ = position;
24  NotifyCallback(last_position_);
25}
26
27bool LocationProviderAndroid::StartProvider(bool high_accuracy) {
28  return AndroidLocationApiAdapter::GetInstance()->Start(this, high_accuracy);
29}
30
31void LocationProviderAndroid::StopProvider() {
32  AndroidLocationApiAdapter::GetInstance()->Stop();
33}
34
35void LocationProviderAndroid::GetPosition(Geoposition* position) {
36  *position = last_position_;
37}
38
39void LocationProviderAndroid::RequestRefresh() {
40  // Nothing to do here, android framework will call us back on new position.
41}
42
43void LocationProviderAndroid::OnPermissionGranted() {
44  // Nothing to do here.
45}
46
47LocationProvider* NewSystemLocationProvider() {
48  return new LocationProviderAndroid;
49}
50
51}  // namespace content
52