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

Side by Side Diff: webkit/plugins/ppapi/message_channel.cc

Issue 8340019: Try a workaround for initMessageEvent bug. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update the Note. Created 9 years, 1 month 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "webkit/plugins/ppapi/message_channel.h" 5 #include "webkit/plugins/ppapi/message_channel.h"
6 6
7 #include <cstdlib> 7 #include <cstdlib>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 bool MessageChannel::EvaluateOnMessageInvoker() { 299 bool MessageChannel::EvaluateOnMessageInvoker() {
300 // If we've already evaluated the function, just return. 300 // If we've already evaluated the function, just return.
301 if (NPVARIANT_IS_OBJECT(onmessage_invoker_)) 301 if (NPVARIANT_IS_OBJECT(onmessage_invoker_))
302 return true; 302 return true;
303 303
304 // This is the javascript code that we invoke to create and dispatch a 304 // This is the javascript code that we invoke to create and dispatch a
305 // message event. 305 // message event.
306 const char invoke_onmessage_js[] = 306 const char invoke_onmessage_js[] =
307 "(function(window, module_instance, message_data) {" 307 "(function(window, module_instance, message_data) {"
308 " if (module_instance) {" 308 " if (module_instance) {"
309 " var message_event = window.document.createEvent('MessageEvent');" 309 " var message_event = new MessageEvent('message', "
310 " message_event.initMessageEvent('message'," // type 310 " { data: message_data });"
311 " false," // canBubble
312 " false," // cancelable
313 " message_data," // data
314 " ''," // origin [*]
315 " ''," // lastEventId
316 " null," // source [*]
317 " []);" // ports
318 " module_instance.dispatchEvent(message_event);" 311 " module_instance.dispatchEvent(message_event);"
319 " }" 312 " }"
320 "})"; 313 "})";
321 // [*] Note that the |origin| is only specified for cross-document and server- 314 // Note that we purposely omit |origin| and |source|. The |origin| is only
322 // sent messages, while |source| is only specified for cross-document 315 // specified for cross-document and server-sent messages, while |source| is
323 // messages: 316 // only specified for cross-document messages:
324 // http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html 317 // http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html
325 // This currently behaves like Web Workers. On Firefox, Chrome, and Safari 318 // This currently behaves like Web Workers. On Firefox, Chrome, and Safari
326 // at least, postMessage on Workers does not provide the origin or source. 319 // at least, postMessage on Workers does not provide the origin or source.
327 // TODO(dmichael): Add origin if we change to a more iframe-like origin 320 // TODO(dmichael): Add origin if we change to a more iframe-like origin
328 // policy (see crbug.com/81537) 321 // policy (see crbug.com/81537)
329 322
330 NPString function_string = { invoke_onmessage_js, 323 NPString function_string = { invoke_onmessage_js,
331 sizeof(invoke_onmessage_js)-1 }; 324 sizeof(invoke_onmessage_js)-1 };
332 // Get the current frame to pass to the evaluate function. 325 // Get the current frame to pass to the evaluate function.
333 WebKit::WebFrame* frame = 326 WebKit::WebFrame* frame =
334 instance_->container()->element().document().frame(); 327 instance_->container()->element().document().frame();
335 // Evaluate the function and obtain an NPVariant pointing to it. 328 // Evaluate the function and obtain an NPVariant pointing to it.
336 if (!WebBindings::evaluate(NULL, frame->windowObject(), &function_string, 329 if (!WebBindings::evaluate(NULL, frame->windowObject(), &function_string,
337 &onmessage_invoker_)) { 330 &onmessage_invoker_)) {
338 // If it fails, do nothing. 331 // If it fails, do nothing.
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 // SetPassthroughObject(passthrough_object()); 417 // SetPassthroughObject(passthrough_object());
425 if (passthrough_object_) 418 if (passthrough_object_)
426 WebBindings::releaseObject(passthrough_object_); 419 WebBindings::releaseObject(passthrough_object_);
427 420
428 passthrough_object_ = passthrough; 421 passthrough_object_ = passthrough;
429 } 422 }
430 423
431 } // namespace ppapi 424 } // namespace ppapi
432 } // namespace webkit 425 } // namespace webkit
433 426
OLDNEW
« 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