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

Unified Diff: extensions/renderer/messaging_bindings.cc

Issue 786403003: Update extensions::MessagingBindings to use WebScopedWindowFocusAllowedIndicator with WebDocument. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/renderer/messaging_bindings.cc
diff --git a/extensions/renderer/messaging_bindings.cc b/extensions/renderer/messaging_bindings.cc
index d379bacd1a77f43a69b8abaaae497dec3543165b..dab2113ff76279a1bd8d508c353fe24d4883682f 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698