diff options
author | mlamouri <mlamouri@chromium.org> | 2014-12-11 08:55:29 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-12-11 16:55:53 +0000 |
commit | ebb4bf8090b06979fd44411af69304b505681f4d (patch) | |
tree | 757f95c44e86749e64b2cad312c542e285b24588 /extensions/renderer/messaging_bindings.cc | |
parent | d2b68827125a71539cbe2ba56eb63aed7c6630e2 (diff) | |
download | chromium_src-ebb4bf8090b06979fd44411af69304b505681f4d.zip chromium_src-ebb4bf8090b06979fd44411af69304b505681f4d.tar.gz chromium_src-ebb4bf8090b06979fd44411af69304b505681f4d.tar.bz2 |
Update extensions::MessagingBindings to use WebScopedWindowFocusAllowedIndicator with WebDocument.
This will allow Blink to delete some deprecated code.
This is part of a three-sided CL:
Part 1: https://codereview.chromium.org/777483004/
Part 2: <this>
Part 3: https://codereview.chromium.org/722423004
BUG=440740
Review URL: https://codereview.chromium.org/786403003
Cr-Commit-Position: refs/heads/master@{#307914}
Diffstat (limited to 'extensions/renderer/messaging_bindings.cc')
-rw-r--r-- | extensions/renderer/messaging_bindings.cc | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/extensions/renderer/messaging_bindings.cc b/extensions/renderer/messaging_bindings.cc index cb24496..2fd2676 100644 --- a/extensions/renderer/messaging_bindings.cc +++ b/extensions/renderer/messaging_bindings.cc @@ -25,6 +25,7 @@ #include "extensions/renderer/scoped_persistent.h" #include "extensions/renderer/script_context.h" #include "extensions/renderer/script_context_set.h" +#include "third_party/WebKit/public/web/WebDocument.h" #include "third_party/WebKit/public/web/WebLocalFrame.h" #include "third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h" #include "third_party/WebKit/public/web/WebScopedUserGesture.h" @@ -324,7 +325,7 @@ void DispatchOnConnectToScriptContext( } } -void DeliverMessageToScriptContext(const std::string& message_data, +void DeliverMessageToScriptContext(const Message& message, int target_port_id, ScriptContext* script_context) { v8::Isolate* isolate = script_context->isolate(); @@ -344,10 +345,23 @@ void DeliverMessageToScriptContext(const std::string& message_data, std::vector<v8::Handle<v8::Value> > arguments; arguments.push_back(v8::String::NewFromUtf8(isolate, - message_data.c_str(), + message.data.c_str(), v8::String::kNormalString, - message_data.size())); + message.data.size())); arguments.push_back(port_id_handle); + + scoped_ptr<blink::WebScopedUserGesture> web_user_gesture; + scoped_ptr<blink::WebScopedWindowFocusAllowedIndicator> allow_window_focus; + if (message.user_gesture) { + web_user_gesture.reset(new blink::WebScopedUserGesture); + + if (script_context->web_frame()) { + blink::WebDocument document = script_context->web_frame()->document(); + allow_window_focus.reset(new blink::WebScopedWindowFocusAllowedIndicator( + &document)); + } + } + script_context->module_system()->CallModuleMethod( "messaging", "dispatchOnMessage", &arguments); } @@ -411,20 +425,13 @@ void MessagingBindings::DeliverMessage( int target_port_id, const Message& message, content::RenderFrame* restrict_to_render_frame) { - scoped_ptr<blink::WebScopedUserGesture> web_user_gesture; - scoped_ptr<blink::WebScopedWindowFocusAllowedIndicator> allow_window_focus; - if (message.user_gesture) { - web_user_gesture.reset(new blink::WebScopedUserGesture); - allow_window_focus.reset(new blink::WebScopedWindowFocusAllowedIndicator); - } - // TODO(robwu): ScriptContextSet.ForEach should accept RenderFrame*. content::RenderView* restrict_to_render_view = restrict_to_render_frame ? restrict_to_render_frame->GetRenderView() : NULL; context_set.ForEach( restrict_to_render_view, - base::Bind(&DeliverMessageToScriptContext, message.data, target_port_id)); + base::Bind(&DeliverMessageToScriptContext, message, target_port_id)); } // static |