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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/renderer_host/render_view_host.h" 5 #include "content/browser/renderer_host/render_view_host.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 478
479 int RenderViewHost::ExecuteJavascriptInWebFrameNotifyResult( 479 int RenderViewHost::ExecuteJavascriptInWebFrameNotifyResult(
480 const string16& frame_xpath, 480 const string16& frame_xpath,
481 const string16& jscript) { 481 const string16& jscript) {
482 static int next_id = 1; 482 static int next_id = 1;
483 Send(new ViewMsg_ScriptEvalRequest(routing_id(), frame_xpath, jscript, 483 Send(new ViewMsg_ScriptEvalRequest(routing_id(), frame_xpath, jscript,
484 next_id, true)); 484 next_id, true));
485 return next_id++; 485 return next_id++;
486 } 486 }
487 487
488 typedef std::pair<int, Value*> ExecuteDetailType;
489
490 ExecuteNotificationObserver::ExecuteNotificationObserver(int id)
491 : id_(id) {
492 }
493
494 ExecuteNotificationObserver::~ExecuteNotificationObserver() {
495 }
496
497 void ExecuteNotificationObserver::Observe(int type,
498 const content::NotificationSource& source,
499 const content::NotificationDetails& details) {
500 content::Details<ExecuteDetailType> execute_details =
501 static_cast<content::Details<ExecuteDetailType> >(details);
502 int id = execute_details->first;
503 if (id != id_)
504 return;
505 Value* value = execute_details->second;
506 if (value)
507 value_.reset(value->DeepCopy());
508 MessageLoop::current()->Quit();
509 }
510
511 Value* RenderViewHost::ExecuteJavascriptAndGetValue(const string16& frame_xpath,
512 const string16& jscript) {
513 int id = ExecuteJavascriptInWebFrameNotifyResult(frame_xpath, jscript);
514 ExecuteNotificationObserver observer(id);
515 content::NotificationRegistrar notification_registrar;
516 notification_registrar.Add(
517 &observer, content::NOTIFICATION_EXECUTE_JAVASCRIPT_RESULT,
518 content::Source<RenderViewHost>(this));
519 MessageLoop* loop = MessageLoop::current();
520 loop->Run();
521 return observer.value()->DeepCopy();
522 }
523
488 void RenderViewHost::JavaScriptDialogClosed(IPC::Message* reply_msg, 524 void RenderViewHost::JavaScriptDialogClosed(IPC::Message* reply_msg,
489 bool success, 525 bool success,
490 const string16& user_input) { 526 const string16& user_input) {
491 process()->set_ignore_input_events(false); 527 process()->set_ignore_input_events(false);
492 bool is_waiting = 528 bool is_waiting =
493 is_waiting_for_beforeunload_ack_ || is_waiting_for_unload_ack_; 529 is_waiting_for_beforeunload_ack_ || is_waiting_for_unload_ack_;
494 if (is_waiting) 530 if (is_waiting)
495 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); 531 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS));
496 532
497 ViewHostMsg_RunJavaScriptMessage::WriteReplyParams(reply_msg, 533 ViewHostMsg_RunJavaScriptMessage::WriteReplyParams(reply_msg,
(...skipping 962 matching lines...) Expand 10 before | Expand all | Expand 10 after
1460 1496
1461 void RenderViewHost::OnWebUISend(const GURL& source_url, 1497 void RenderViewHost::OnWebUISend(const GURL& source_url,
1462 const std::string& name, 1498 const std::string& name,
1463 const base::ListValue& args) { 1499 const base::ListValue& args) {
1464 delegate_->WebUISend(this, source_url, name, args); 1500 delegate_->WebUISend(this, source_url, name, args);
1465 } 1501 }
1466 1502
1467 void RenderViewHost::ClearPowerSaveBlockers() { 1503 void RenderViewHost::ClearPowerSaveBlockers() {
1468 STLDeleteValues(&power_save_blockers_); 1504 STLDeleteValues(&power_save_blockers_);
1469 } 1505 }
OLDNEW
« 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