diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-05 03:34:53 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-05 03:34:53 +0000 |
commit | 882b7b2ac4db4348b28f0de68e48febbfd814a70 (patch) | |
tree | aa53683904901bebe5f012851bede0edb20f757c /chrome/browser/renderer_host/render_view_host.cc | |
parent | 428f54bcc8e53882375b7fb9f30b2bc577c59b8a (diff) | |
download | chromium_src-882b7b2ac4db4348b28f0de68e48febbfd814a70.zip chromium_src-882b7b2ac4db4348b28f0de68e48febbfd814a70.tar.gz chromium_src-882b7b2ac4db4348b28f0de68e48febbfd814a70.tar.bz2 |
Adds RenderViewHost::ExecuteJavascriptInWebFrameNotifyResult which
executes script and uses a notification to post the results back.
BUG=54833
TEST=none
Review URL: http://codereview.chromium.org/3591008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61475 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/renderer_host/render_view_host.cc')
-rw-r--r-- | chrome/browser/renderer_host/render_view_host.cc | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc index de32b0c..a702b08 100644 --- a/chrome/browser/renderer_host/render_view_host.cc +++ b/chrome/browser/renderer_host/render_view_host.cc @@ -14,6 +14,7 @@ #include "base/stats_counters.h" #include "base/string_util.h" #include "base/time.h" +#include "base/values.h" #include "chrome/browser/blocked_plugin_manager.h" #include "chrome/browser/browser_list.h" #include "chrome/browser/child_process_security_policy.h" @@ -490,8 +491,20 @@ void RenderViewHost::ReservePageIDRange(int size) { } void RenderViewHost::ExecuteJavascriptInWebFrame( - const std::wstring& frame_xpath, const std::wstring& jscript) { - Send(new ViewMsg_ScriptEvalRequest(routing_id(), frame_xpath, jscript)); + const std::wstring& frame_xpath, + const std::wstring& jscript) { + Send(new ViewMsg_ScriptEvalRequest(routing_id(), WideToUTF16(frame_xpath), + WideToUTF16(jscript), + 0, false)); +} + +int RenderViewHost::ExecuteJavascriptInWebFrameNotifyResult( + const string16& frame_xpath, + const string16& jscript) { + static int next_id = 1; + Send(new ViewMsg_ScriptEvalRequest(routing_id(), frame_xpath, jscript, + next_id, true)); + return next_id++; } void RenderViewHost::InsertCSSInWebFrame( @@ -871,6 +884,7 @@ void RenderViewHost::OnMessageReceived(const IPC::Message& msg) { IPC_MESSAGE_HANDLER(ViewHostMsg_SetSuggestResult, OnSetSuggestResult) IPC_MESSAGE_HANDLER(ViewHostMsg_DetectedPhishingSite, OnDetectedPhishingSite) + IPC_MESSAGE_HANDLER(ViewHostMsg_ScriptEvalResponse, OnScriptEvalResponse) // Have the super handle all other messages. IPC_MESSAGE_UNHANDLED(RenderWidgetHost::OnMessageReceived(msg)) IPC_END_MESSAGE_MAP_EX() @@ -2102,3 +2116,12 @@ void RenderViewHost::OnDetectedPhishingSite(const GURL& phishing_url, // TODO(noelutz): send an HTTP request to the client-side detection frontends // to confirm that the URL is really phishing. } + +void RenderViewHost::OnScriptEvalResponse(int id, bool result) { + scoped_ptr<Value> result_value(Value::CreateBooleanValue(result)); + std::pair<int, Value*> details(id, result_value.get()); + NotificationService::current()->Notify( + NotificationType::EXECUTE_JAVASCRIPT_RESULT, + Source<RenderViewHost>(this), + Details<std::pair<int, Value*> >(&details)); +} |