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

Unified Diff: content/browser/renderer_host/render_view_host.cc

Issue 8124024: Applescript: return value from execute javascript command (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: fix rebase mistake so it compiles Created 9 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/renderer_host/render_view_host.cc
diff --git a/content/browser/renderer_host/render_view_host.cc b/content/browser/renderer_host/render_view_host.cc
index 8135f5e0d18f8d93cb6584d53d8c9e098bf48088..c3b45f0f8e194951c14c081ee6d206a67fd74ad8 100644
--- a/content/browser/renderer_host/render_view_host.cc
+++ b/content/browser/renderer_host/render_view_host.cc
@@ -485,6 +485,42 @@ int RenderViewHost::ExecuteJavascriptInWebFrameNotifyResult(
return next_id++;
}
+typedef std::pair<int, Value*> ExecuteDetailType;
+
+ExecuteNotificationObserver::ExecuteNotificationObserver(int id)
+: id_(id) {
+}
+
+ExecuteNotificationObserver::~ExecuteNotificationObserver() {
+}
+
+void ExecuteNotificationObserver::Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) {
+ content::Details<ExecuteDetailType> execute_details =
+ static_cast<content::Details<ExecuteDetailType> >(details);
+ int id = execute_details->first;
+ if (id != id_)
+ return;
+ Value* value = execute_details->second;
+ if (value)
+ value_.reset(value->DeepCopy());
+ MessageLoop::current()->Quit();
+}
+
+Value* RenderViewHost::ExecuteJavascriptAndGetValue(const string16& frame_xpath,
+ const string16& jscript) {
+ int id = ExecuteJavascriptInWebFrameNotifyResult(frame_xpath, jscript);
+ ExecuteNotificationObserver observer(id);
+ content::NotificationRegistrar notification_registrar;
+ notification_registrar.Add(
+ &observer, content::NOTIFICATION_EXECUTE_JAVASCRIPT_RESULT,
+ content::Source<RenderViewHost>(this));
+ MessageLoop* loop = MessageLoop::current();
+ loop->Run();
+ return observer.value()->DeepCopy();
+}
+
void RenderViewHost::JavaScriptDialogClosed(IPC::Message* reply_msg,
bool success,
const string16& user_input) {
« no previous file with comments | « content/browser/renderer_host/render_view_host.h ('k') | content/browser/renderer_host/render_view_host_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698