Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(447)

Side by Side Diff: blimp/engine/feature/geolocation/blimp_location_provider.cc

Issue 2091023006: Adds EngineGeolocationFeature for Blimp Geolocation project. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge with head Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 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 #include "blimp/engine/feature/geolocation/blimp_location_provider.h" 5 #include "blimp/engine/feature/geolocation/blimp_location_provider.h"
6 6
7 #include "base/bind.h"
8 #include "base/bind_helpers.h"
9 #include "base/memory/weak_ptr.h"
7 #include "content/public/common/geoposition.h" 10 #include "content/public/common/geoposition.h"
8 11
9 namespace blimp { 12 namespace blimp {
10 namespace engine { 13 namespace engine {
11 14
12 BlimpLocationProvider::BlimpLocationProvider() {} 15 BlimpLocationProvider::BlimpLocationProvider(
16 base::WeakPtr<BlimpLocationProvider::Delegate> delegate) {
17 DCHECK(delegate);
13 18
14 BlimpLocationProvider::~BlimpLocationProvider() { 19 delegate_ = delegate;
15 StopProvider();
16 } 20 }
17 21
22 BlimpLocationProvider::~BlimpLocationProvider() {}
23
18 bool BlimpLocationProvider::StartProvider(bool high_accuracy) { 24 bool BlimpLocationProvider::StartProvider(bool high_accuracy) {
19 NOTIMPLEMENTED(); 25 if (delegate_) {
20 return true; 26 if (high_accuracy) {
27 delegate_->RequestAccuracy(
28 GeolocationSetInterestLevelMessage::HIGH_ACCURACY);
29 } else {
30 delegate_->RequestAccuracy(
31 GeolocationSetInterestLevelMessage::LOW_ACCURACY);
32 }
33 return true;
34 }
35 return false;
21 } 36 }
22 37
23 void BlimpLocationProvider::StopProvider() { 38 void BlimpLocationProvider::StopProvider() {
39 if (delegate_) {
40 delegate_->RequestAccuracy(GeolocationSetInterestLevelMessage::NO_INTEREST);
41 }
24 } 42 }
25 43
26 void BlimpLocationProvider::GetPosition(content::Geoposition* position) { 44 void BlimpLocationProvider::GetPosition(content::Geoposition* position) {
27 DCHECK(position);
28
29 *position = position_; 45 *position = position_;
30 } 46 }
31 47
32 void BlimpLocationProvider::RequestRefresh() { 48 void BlimpLocationProvider::RequestRefresh() {
33 NOTIMPLEMENTED(); 49 if (delegate_) {
50 delegate_->RequestRefresh();
51 }
34 } 52 }
35 53
36 void BlimpLocationProvider::OnPermissionGranted() { 54 void BlimpLocationProvider::OnPermissionGranted() {
37 RequestRefresh(); 55 RequestRefresh();
38 NOTIMPLEMENTED();
39 }
40
41 void BlimpLocationProvider::NotifyCallback(
42 const content::Geoposition& position) {
43 DCHECK(!callback_.is_null());
44
45 callback_.Run(this, position);
46 }
47
48 void BlimpLocationProvider::OnLocationResponse(
49 const content::Geoposition& position) {
50 NotifyCallback(position);
51 NOTIMPLEMENTED();
52 } 56 }
53 57
54 void BlimpLocationProvider::SetUpdateCallback( 58 void BlimpLocationProvider::SetUpdateCallback(
55 const LocationProviderUpdateCallback& callback) { 59 const LocationProviderUpdateCallback& callback) {
56 DCHECK(!callback.is_null()); 60 if (delegate_) {
57 61 delegate_->SetUpdateCallback(base::Bind(callback, base::Unretained(this)));
58 callback_ = callback; 62 }
59 } 63 }
60 64
61 } // namespace engine 65 } // namespace engine
62 } // namespace blimp 66 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698