diff options
author | mlamouri <mlamouri@chromium.org> | 2015-04-21 03:43:54 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-04-21 10:44:11 +0000 |
commit | 9b4c024f001519ea0c35decc04335bb768190ad5 (patch) | |
tree | 1062ed2c3fefef28ac13179680f784674ce5ae00 /extensions/renderer/messaging_bindings.cc | |
parent | a3635a7de383a295e52a35c1ae4e72aecab14d77 (diff) | |
download | chromium_src-9b4c024f001519ea0c35decc04335bb768190ad5.zip chromium_src-9b4c024f001519ea0c35decc04335bb768190ad5.tar.gz chromium_src-9b4c024f001519ea0c35decc04335bb768190ad5.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
Committed: https://crrev.com/ebb4bf8090b06979fd44411af69304b505681f4d
Cr-Commit-Position: refs/heads/master@{#307914}
Review URL: https://codereview.chromium.org/786403003
Cr-Commit-Position: refs/heads/master@{#326007}
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 d379bac..dab2113 100644 --- a/extensions/renderer/messaging_bindings.cc +++ b/extensions/renderer/messaging_bindings.cc @@ -26,6 +26,7 @@ #include "extensions/renderer/object_backed_native_handler.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" @@ -334,7 +335,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(); @@ -354,10 +355,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); } @@ -421,20 +435,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 |