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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: blimp/engine/feature/geolocation/blimp_location_provider.cc
diff --git a/blimp/engine/feature/geolocation/blimp_location_provider.cc b/blimp/engine/feature/geolocation/blimp_location_provider.cc
index de86b9fc1e65b31384c8cbdd43cca52128e388ca..aae0471d975023c785e351271301a267144d29e0 100644
--- a/blimp/engine/feature/geolocation/blimp_location_provider.cc
+++ b/blimp/engine/feature/geolocation/blimp_location_provider.cc
@@ -4,58 +4,62 @@
#include "blimp/engine/feature/geolocation/blimp_location_provider.h"
+#include "base/bind.h"
+#include "base/bind_helpers.h"
+#include "base/memory/weak_ptr.h"
#include "content/public/common/geoposition.h"
namespace blimp {
namespace engine {
-BlimpLocationProvider::BlimpLocationProvider() {}
+BlimpLocationProvider::BlimpLocationProvider(
+ base::WeakPtr<BlimpLocationProvider::Delegate> delegate) {
+ DCHECK(delegate);
-BlimpLocationProvider::~BlimpLocationProvider() {
- StopProvider();
+ delegate_ = delegate;
}
+BlimpLocationProvider::~BlimpLocationProvider() {}
+
bool BlimpLocationProvider::StartProvider(bool high_accuracy) {
- NOTIMPLEMENTED();
- return true;
+ if (delegate_) {
+ if (high_accuracy) {
+ delegate_->RequestAccuracy(
+ GeolocationSetInterestLevelMessage::HIGH_ACCURACY);
+ } else {
+ delegate_->RequestAccuracy(
+ GeolocationSetInterestLevelMessage::LOW_ACCURACY);
+ }
+ return true;
+ }
+ return false;
}
void BlimpLocationProvider::StopProvider() {
+ if (delegate_) {
+ delegate_->RequestAccuracy(GeolocationSetInterestLevelMessage::NO_INTEREST);
+ }
}
void BlimpLocationProvider::GetPosition(content::Geoposition* position) {
- DCHECK(position);
-
*position = position_;
}
void BlimpLocationProvider::RequestRefresh() {
- NOTIMPLEMENTED();
+ if (delegate_) {
+ delegate_->RequestRefresh();
+ }
}
void BlimpLocationProvider::OnPermissionGranted() {
RequestRefresh();
- NOTIMPLEMENTED();
-}
-
-void BlimpLocationProvider::NotifyCallback(
- const content::Geoposition& position) {
- DCHECK(!callback_.is_null());
-
- callback_.Run(this, position);
-}
-
-void BlimpLocationProvider::OnLocationResponse(
- const content::Geoposition& position) {
- NotifyCallback(position);
- NOTIMPLEMENTED();
}
void BlimpLocationProvider::SetUpdateCallback(
const LocationProviderUpdateCallback& callback) {
- DCHECK(!callback.is_null());
-
- callback_ = callback;
+ if (delegate_) {
+ delegate_->SetUpdateCallback(base::Bind(callback, base::Unretained(this)));
+ }
}
} // namespace engine

Powered by Google App Engine
This is Rietveld 408576698