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

Side by Side Diff: content/browser/browser_plugin/browser_plugin_guest.cc

Issue 1404353004: Delay creation of BrowserPluginMsg_X messages until after attach. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/browser_plugin/browser_plugin_guest.h" 5 #include "content/browser/browser_plugin/browser_plugin_guest.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/pickle.h" 10 #include "base/pickle.h"
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 cc::SurfaceManager* manager = GetSurfaceManager(); 437 cc::SurfaceManager* manager = GetSurfaceManager();
438 cc::Surface* surface = manager->GetSurfaceForId(id); 438 cc::Surface* surface = manager->GetSurfaceForId(id);
439 if (!surface) { 439 if (!surface) {
440 LOG(ERROR) << "Attempting to require callback on nonexistent surface"; 440 LOG(ERROR) << "Attempting to require callback on nonexistent surface";
441 return; 441 return;
442 } 442 }
443 surface->AddDestructionDependency(sequence); 443 surface->AddDestructionDependency(sequence);
444 } 444 }
445 445
446 void BrowserPluginGuest::SetContentsOpaque(bool opaque) { 446 void BrowserPluginGuest::SetContentsOpaque(bool opaque) {
447 SendMessageToEmbedder( 447 SendMessageToEmbedder([opaque](int browser_plugin_instance_id) {
448 new BrowserPluginMsg_SetContentsOpaque( 448 return new BrowserPluginMsg_SetContentsOpaque(browser_plugin_instance_id,
449 browser_plugin_instance_id(), opaque)); 449 opaque);
450 });
450 } 451 }
451 452
452 bool BrowserPluginGuest::Find(int request_id, 453 bool BrowserPluginGuest::Find(int request_id,
453 const base::string16& search_text, 454 const base::string16& search_text,
454 const blink::WebFindOptions& options) { 455 const blink::WebFindOptions& options) {
455 return delegate_->Find(request_id, search_text, options); 456 return delegate_->Find(request_id, search_text, options);
456 } 457 }
457 458
458 bool BrowserPluginGuest::StopFinding(StopFindAction action) { 459 bool BrowserPluginGuest::StopFinding(StopFindAction action) {
459 return delegate_->StopFinding(action); 460 return delegate_->StopFinding(action);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 gfx::Point BrowserPluginGuest::GetScreenCoordinates( 498 gfx::Point BrowserPluginGuest::GetScreenCoordinates(
498 const gfx::Point& relative_position) const { 499 const gfx::Point& relative_position) const {
499 if (!attached()) 500 if (!attached())
500 return relative_position; 501 return relative_position;
501 502
502 gfx::Point screen_pos(relative_position); 503 gfx::Point screen_pos(relative_position);
503 screen_pos += guest_window_rect_.OffsetFromOrigin(); 504 screen_pos += guest_window_rect_.OffsetFromOrigin();
504 return screen_pos; 505 return screen_pos;
505 } 506 }
506 507
508 // TODO(wjmaclean): Remove this function once all messages are handled with
509 // functionals.
507 void BrowserPluginGuest::SendMessageToEmbedder(IPC::Message* msg) { 510 void BrowserPluginGuest::SendMessageToEmbedder(IPC::Message* msg) {
508 // During tests, attache() may be true when there is no owner_web_contents_; 511 // During tests, attache() may be true when there is no owner_web_contents_;
509 // in this case just queue any messages we receive. 512 // in this case just queue any messages we receive.
510 if (!attached() || !owner_web_contents_) { 513 if (!attached() || !owner_web_contents_) {
511 // Some pages such as data URLs, javascript URLs, and about:blank 514 // Some pages such as data URLs, javascript URLs, and about:blank
512 // do not load external resources and so they load prior to attachment. 515 // do not load external resources and so they load prior to attachment.
513 // As a result, we must save all these IPCs until attachment and then 516 // As a result, we must save all these IPCs until attachment and then
514 // forward them so that the embedder gets a chance to see and process 517 // forward them so that the embedder gets a chance to see and process
515 // the load events. 518 // the load events.
516 pending_messages_.push_back(linked_ptr<IPC::Message>(msg)); 519 pending_messages_.push_back(linked_ptr<IPC::Message>(msg));
517 return; 520 return;
518 } 521 }
519 owner_web_contents_->Send(msg); 522 owner_web_contents_->Send(msg);
520 } 523 }
521 524
525 void BrowserPluginGuest::SendMessageToEmbedder(
526 BrowserPluginMessageFunc msg_func) {
527 // During tests, attache() may be true when there is no owner_web_contents_;
lazyboy 2015/10/16 00:15:48 attached()
528 // in this case just queue any messages we receive.
529 if (!attached() || !owner_web_contents_) {
530 // Some pages such as data URLs, javascript URLs, and about:blank
531 // do not load external resources and so they load prior to attachment.
532 // As a result, we must save all these IPCs until attachment and then
533 // forward them so that the embedder gets a chance to see and process
534 // the load events.
535 pending_message_funcs_.push_back(msg_func);
536 return;
537 }
538 owner_web_contents_->Send(msg_func(browser_plugin_instance_id()));
539 }
540
522 void BrowserPluginGuest::DragSourceEndedAt(int client_x, int client_y, 541 void BrowserPluginGuest::DragSourceEndedAt(int client_x, int client_y,
523 int screen_x, int screen_y, blink::WebDragOperation operation) { 542 int screen_x, int screen_y, blink::WebDragOperation operation) {
524 web_contents()->GetRenderViewHost()->DragSourceEndedAt(client_x, client_y, 543 web_contents()->GetRenderViewHost()->DragSourceEndedAt(client_x, client_y,
525 screen_x, screen_y, operation); 544 screen_x, screen_y, operation);
526 seen_embedder_drag_source_ended_at_ = true; 545 seen_embedder_drag_source_ended_at_ = true;
527 EndSystemDragIfApplicable(); 546 EndSystemDragIfApplicable();
528 } 547 }
529 548
530 void BrowserPluginGuest::EndSystemDragIfApplicable() { 549 void BrowserPluginGuest::EndSystemDragIfApplicable() {
531 // Ideally we'd want either WebDragStatusDrop or WebDragStatusLeave... 550 // Ideally we'd want either WebDragStatusDrop or WebDragStatusLeave...
(...skipping 29 matching lines...) Expand all
561 580
562 void BrowserPluginGuest::EmbedderSystemDragEnded() { 581 void BrowserPluginGuest::EmbedderSystemDragEnded() {
563 seen_embedder_system_drag_ended_ = true; 582 seen_embedder_system_drag_ended_ = true;
564 EndSystemDragIfApplicable(); 583 EndSystemDragIfApplicable();
565 } 584 }
566 585
567 void BrowserPluginGuest::SendQueuedMessages() { 586 void BrowserPluginGuest::SendQueuedMessages() {
568 if (!attached()) 587 if (!attached())
569 return; 588 return;
570 589
590 // TODO(wjmaclean): Remove this block once all messages are handled with
591 // functionals.
571 while (!pending_messages_.empty()) { 592 while (!pending_messages_.empty()) {
572 linked_ptr<IPC::Message> message_ptr = pending_messages_.front(); 593 linked_ptr<IPC::Message> message_ptr = pending_messages_.front();
Fady Samuel 2015/10/16 02:48:43 Perhaps you can grab the payload of the IPC::Messa
573 pending_messages_.pop_front(); 594 pending_messages_.pop_front();
574 SendMessageToEmbedder(message_ptr.release()); 595 SendMessageToEmbedder(message_ptr.release());
575 } 596 }
597
598 while (!pending_message_funcs_.empty()) {
lazyboy 2015/10/16 00:15:48 Having two queues will send messages out of order,
599 SendMessageToEmbedder(
600 pending_message_funcs_.front()(browser_plugin_instance_id()));
601 pending_message_funcs_.pop_front();
602 }
576 } 603 }
577 604
578 void BrowserPluginGuest::SendTextInputTypeChangedToView( 605 void BrowserPluginGuest::SendTextInputTypeChangedToView(
579 RenderWidgetHostViewBase* guest_rwhv) { 606 RenderWidgetHostViewBase* guest_rwhv) {
580 if (!guest_rwhv) 607 if (!guest_rwhv)
581 return; 608 return;
582 609
583 if (!owner_web_contents_) { 610 if (!owner_web_contents_) {
584 // If we were showing an interstitial, then we can end up here during 611 // If we were showing an interstitial, then we can end up here during
585 // embedder shutdown or when the embedder navigates to a different page. 612 // embedder shutdown or when the embedder navigates to a different page.
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
1011 range, character_bounds); 1038 range, character_bounds);
1012 } 1039 }
1013 #endif 1040 #endif
1014 1041
1015 void BrowserPluginGuest::SetContextMenuPosition(const gfx::Point& position) { 1042 void BrowserPluginGuest::SetContextMenuPosition(const gfx::Point& position) {
1016 if (delegate_) 1043 if (delegate_)
1017 delegate_->SetContextMenuPosition(position); 1044 delegate_->SetContextMenuPosition(position);
1018 } 1045 }
1019 1046
1020 } // namespace content 1047 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698