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

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: Fixed issues 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 441acb68d0af6feca7bf6053804fd4c59949fb21..f854182f5ebc19f14babe980309bfffbbeeb6d95 100644
--- a/content/browser/renderer_host/render_view_host.cc
+++ b/content/browser/renderer_host/render_view_host.cc
@@ -50,6 +50,8 @@
#include "webkit/glue/webaccessibility.h"
#include "webkit/glue/webdropdata.h"
+#include "content/common/notification_details.h"
+
using base::TimeDelta;
using WebKit::WebConsoleMessage;
using WebKit::WebDragOperation;
@@ -481,6 +483,36 @@ int RenderViewHost::ExecuteJavascriptInWebFrameNotifyResult(
return next_id++;
}
+typedef std::pair<int, Value*> ExecuteDetailType;
+
+ExecuteNotificationObserver::ExecuteNotificationObserver(int id) : id_(id) { }
Avi (use Gerrit) 2011/10/17 14:20:38 adhere to style guide
keishi 2011/10/21 05:05:43 Done.
+ExecuteNotificationObserver::~ExecuteNotificationObserver() { }
Avi (use Gerrit) 2011/10/17 14:20:38 ditto
keishi 2011/10/21 05:05:43 Done.
+void ExecuteNotificationObserver::Observe(int type,
+ const NotificationSource& source,
+ const NotificationDetails& details)
+{
Avi (use Gerrit) 2011/10/17 14:20:38 opening brace always on previous line
keishi 2011/10/21 05:05:43 Done.
+ int id = (static_cast<Details<ExecuteDetailType > >(details))->first;
Avi (use Gerrit) 2011/10/17 14:20:38 no space before first >
keishi 2011/10/21 05:05:43 Done.
+ if (id != id_)
+ return;
+ Value* value = (static_cast<Details<ExecuteDetailType > >(details))->second;
Avi (use Gerrit) 2011/10/17 14:20:38 ditto
keishi 2011/10/21 05:05:43 Done.
+ if (value)
+ value_.reset(value->DeepCopy());
+ MessageLoop::current()->Quit();
+}
+
+Value* RenderViewHost::ExecuteJavascriptAndGetValue(const string16& frame_xpath,
+ const string16& jscript) {
Avi (use Gerrit) 2011/10/17 14:20:38 align params
keishi 2011/10/21 05:05:43 Done.
+ int id = ExecuteJavascriptInWebFrameNotifyResult(frame_xpath, jscript);
+ ExecuteNotificationObserver observer(id);
+ NotificationRegistrar notification_registrar;
+ notification_registrar.Add(
+ &observer, content::NOTIFICATION_EXECUTE_JAVASCRIPT_RESULT,
+ Source<RenderViewHost>(this));
+ MessageLoop* loop = MessageLoop::current();
+ loop->Run();
+ return observer.value()->DeepCopy();
Avi (use Gerrit) 2011/10/17 14:20:38 We make two copies?
keishi 2011/10/21 05:05:43 The value must outlive the observer so this copy i
+}
+
void RenderViewHost::JavaScriptDialogClosed(IPC::Message* reply_msg,
bool success,
const string16& user_input) {

Powered by Google App Engine
This is Rietveld 408576698