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

Unified Diff: content/browser/devtools/protocol/page_handler.cc

Issue 603323004: DevTools: Add geolocation override in browser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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: content/browser/devtools/protocol/page_handler.cc
diff --git a/content/browser/devtools/protocol/page_handler.cc b/content/browser/devtools/protocol/page_handler.cc
index 33fac54f483c319a57e3338b220262b7ae632168..d94f16805ebf7e79add088182a68aafb02358e5e 100644
--- a/content/browser/devtools/protocol/page_handler.cc
+++ b/content/browser/devtools/protocol/page_handler.cc
@@ -5,7 +5,9 @@
#include "content/browser/devtools/protocol/page_handler.h"
#include "base/base64.h"
+#include "content/browser/geolocation/geolocation_dispatcher_host.h"
#include "content/browser/renderer_host/render_view_host_impl.h"
+#include "content/browser/web_contents/web_contents_impl.h"
namespace content {
namespace devtools {
@@ -57,6 +59,36 @@ Response PageHandler::NavigateToHistoryEntry(int entry_id) {
return Response::FallThrough();
}
+Response PageHandler::SetGeolocationOverride(double* latitude,
+ double* longitude,
+ double* accuracy) {
+ WebContentsImpl* web_contents = static_cast<WebContentsImpl*>(
+ WebContents::FromRenderViewHost(host_));
+ GeolocationDispatcherHost* geolocation_host =
dgozman 2014/10/06 11:03:26 if (!web_contents) return Response::InternalErro
vkuzkokov 2014/10/06 13:48:20 Done.
+ web_contents->geolocation_dispatcher_host();
+ scoped_ptr<Geoposition> geoposition(new Geoposition());
+ if (latitude && longitude && accuracy) {
+ geoposition->latitude = *latitude;
+ geoposition->longitude = *longitude;
+ geoposition->accuracy = *accuracy;
+ geoposition->timestamp = base::Time::Now();
+ } else {
+ geoposition->error_code = Geoposition::ERROR_CODE_POSITION_UNAVAILABLE;
+ }
+ geolocation_host->SetOverride(geoposition.Pass());
dgozman 2014/10/06 11:03:26 Could |geolocation_host| be NULL?
Michael van Ouwerkerk 2014/10/06 13:38:23 It should really never be, it is instantiated in W
+ return Response::OK();
+}
+
+Response PageHandler::ClearGeolocationOverride() {
+ WebContentsImpl* web_contents = static_cast<WebContentsImpl*>(
dgozman 2014/10/06 11:03:26 Check |web_contents| and maybe |geolocation_host|.
vkuzkokov 2014/10/06 13:48:20 Done.
+ WebContents::FromRenderViewHost(host_));
+ GeolocationDispatcherHost* geolocation_host =
+ web_contents->geolocation_dispatcher_host();
+ geolocation_host->ClearOverride();
+ return Response::OK();
+}
+
+
Response PageHandler::SetTouchEmulationEnabled(bool enabled) {
return Response::FallThrough();
}

Powered by Google App Engine
This is Rietveld 408576698