| 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) {
|
|
|