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

Unified Diff: chrome/browser/automation/testing_automation_provider.cc

Issue 10070012: Geolocation support for chromedriver. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 8 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: chrome/browser/automation/testing_automation_provider.cc
diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc
index 09b66736b8342b61d42d3f83977ab601cbb3ca51..5913a72ba5d46eb70851710a64d82bc47ffda47f 100644
--- a/chrome/browser/automation/testing_automation_provider.cc
+++ b/chrome/browser/automation/testing_automation_provider.cc
@@ -126,6 +126,7 @@
#include "content/public/browser/browser_child_process_host_iterator.h"
#include "content/public/browser/child_process_data.h"
#include "content/public/browser/favicon_status.h"
+#include "content/public/browser/geolocation.h"
#include "content/public/browser/interstitial_page.h"
#include "content/public/browser/interstitial_page_delegate.h"
#include "content/public/browser/navigation_entry.h"
@@ -2266,11 +2267,13 @@ void TestingAutomationProvider::SendJSONRequest(int handle,
&TestingAutomationProvider::TriggerBrowserActionById;
handler_map["UpdateExtensionsNow"] =
&TestingAutomationProvider::UpdateExtensionsNow;
-
#if !defined(NO_TCMALLOC) && (defined(OS_LINUX) || defined(OS_CHROMEOS))
handler_map["HeapProfilerDump"] =
&TestingAutomationProvider::HeapProfilerDump;
#endif // !defined(NO_TCMALLOC) && (defined(OS_LINUX) || defined(OS_CHROMEOS))
+ handler_map["OverrideGeoposition"] =
+ &TestingAutomationProvider::OverrideGeoposition;
+
#if defined(OS_CHROMEOS)
handler_map["GetLoginInfo"] = &TestingAutomationProvider::GetLoginInfo;
handler_map["ShowCreateAccountUI"] =
@@ -4850,6 +4853,33 @@ void TestingAutomationProvider::HeapProfilerDump(
}
#endif // !defined(NO_TCMALLOC) && (defined(OS_LINUX) || defined(OS_CHROMEOS))
+namespace {
+
+void SendSuccessIfAlive(
+ base::WeakPtr<AutomationProvider> provider,
+ IPC::Message* reply_message) {
+ if (provider)
+ AutomationJSONReply(provider.get(), reply_message).SendSuccess(NULL);
+}
+
+} // namespace
+
+void TestingAutomationProvider::OverrideGeoposition(
+ base::DictionaryValue* args,
+ IPC::Message* reply_message) {
+ double latitude, longitude, altitude;
+ if (!args->GetDouble("latitude", &latitude) ||
+ !args->GetDouble("longitude", &longitude) ||
+ !args->GetDouble("altitude", &altitude)) {
+ AutomationJSONReply(this, reply_message).SendError(
+ "Missing or invalid geolocation parameters");
+ return;
+ }
+ content::OverrideLocationForTesting(
+ latitude, longitude, altitude,
+ base::Bind(&SendSuccessIfAlive, AsWeakPtr(), reply_message));
+}
+
// Sample json input:
// { "command": "GetAutofillProfile" }
// Refer to GetAutofillProfile() in chrome/test/pyautolib/pyauto.py for sample
« no previous file with comments | « chrome/browser/automation/testing_automation_provider.h ('k') | chrome/browser/extensions/extension_geolocation_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698