diff options
author | fsamuel <fsamuel@chromium.org> | 2014-11-19 15:19:34 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-11-19 23:19:52 +0000 |
commit | b45f55be7958e1a2dbd30261c10436b49829782d (patch) | |
tree | 0841bc11ee05c8b751c8dea4e2bc55f088a87864 | |
parent | 0fe32d756a8b45e34273dafa94b9c184c17ef971 (diff) | |
download | chromium_src-b45f55be7958e1a2dbd30261c10436b49829782d.zip chromium_src-b45f55be7958e1a2dbd30261c10436b49829782d.tar.gz chromium_src-b45f55be7958e1a2dbd30261c10436b49829782d.tar.bz2 |
Browser Plugin: Simplify attachment logic
This CL is both code simplification and fixes a subtle bug.
Prior to this CL, we were dropping resizes between calls to BrowserPlugin::Attach
and BrowserPlugin::OnAttachACK. It seems AttachACK is now unnecessary (its functionality
was moved out of BrowserPlugin), and so we can simply get rid of it and the associated
attach_pending_ flag.
BUG=434827
TBR=kenrb@chromium.org for browser_plugin_messages.h IPC removal.
Review URL: https://codereview.chromium.org/736953005
Cr-Commit-Position: refs/heads/master@{#304919}
4 files changed, 10 insertions, 32 deletions
diff --git a/content/browser/browser_plugin/browser_plugin_guest.cc b/content/browser/browser_plugin/browser_plugin_guest.cc index c2db313..544b869 100644 --- a/content/browser/browser_plugin/browser_plugin_guest.cc +++ b/content/browser/browser_plugin/browser_plugin_guest.cc @@ -251,10 +251,6 @@ void BrowserPluginGuest::Initialize( GetWebContents()->GetRenderViewHost()); guest_rvh->SetInputMethodActive(true); } - - // Inform the embedder of the guest's attachment. - SendMessageToEmbedder( - new BrowserPluginMsg_Attach_ACK(browser_plugin_instance_id_)); } BrowserPluginGuest::~BrowserPluginGuest() { diff --git a/content/common/browser_plugin/browser_plugin_messages.h b/content/common/browser_plugin/browser_plugin_messages.h index 61fbdef..57070855 100644 --- a/content/common/browser_plugin/browser_plugin_messages.h +++ b/content/common/browser_plugin/browser_plugin_messages.h @@ -162,11 +162,6 @@ IPC_MESSAGE_ROUTED2(BrowserPluginHostMsg_ResizeGuest, // ----------------------------------------------------------------------------- // These messages are from the browser process to the embedder. -// This message is sent in response to a completed attachment of a guest -// to a BrowserPlugin. -IPC_MESSAGE_CONTROL1(BrowserPluginMsg_Attach_ACK, - int /* browser_plugin_instance_id */) - // When the guest crashes, the browser process informs the embedder through this // message. IPC_MESSAGE_CONTROL1(BrowserPluginMsg_GuestGone, diff --git a/content/renderer/browser_plugin/browser_plugin.cc b/content/renderer/browser_plugin/browser_plugin.cc index 39e49d2..f153a89 100644 --- a/content/renderer/browser_plugin/browser_plugin.cc +++ b/content/renderer/browser_plugin/browser_plugin.cc @@ -62,7 +62,6 @@ BrowserPlugin::BrowserPlugin(RenderViewImpl* render_view, blink::WebFrame* frame, scoped_ptr<BrowserPluginDelegate> delegate) : attached_(false), - attach_pending_(false), render_view_(render_view->AsWeakPtr()), render_view_routing_id_(render_view->GetRoutingID()), container_(NULL), @@ -94,7 +93,6 @@ BrowserPlugin::~BrowserPlugin() { bool BrowserPlugin::OnMessageReceived(const IPC::Message& message) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(BrowserPlugin, message) - IPC_MESSAGE_HANDLER(BrowserPluginMsg_Attach_ACK, OnAttachACK) IPC_MESSAGE_HANDLER(BrowserPluginMsg_AdvanceFocus, OnAdvanceFocus) IPC_MESSAGE_HANDLER_GENERIC(BrowserPluginMsg_CompositorFrameSwapped, OnCompositorFrameSwapped(message)) @@ -122,8 +120,7 @@ void BrowserPlugin::UpdateDOMAttribute(const std::string& attribute_name, } void BrowserPlugin::Attach() { - if (ready()) { - attached_ = false; + if (attached()) { guest_crashed_ = false; EnableCompositing(false); if (compositing_helper_.get()) { @@ -153,7 +150,7 @@ void BrowserPlugin::Attach() { browser_plugin_instance_id_, attach_params)); - attach_pending_ = true; + attached_ = true; } void BrowserPlugin::DidCommitCompositorFrame() { @@ -167,12 +164,6 @@ void BrowserPlugin::OnAdvanceFocus(int browser_plugin_instance_id, render_view_->GetWebView()->advanceFocus(reverse); } -void BrowserPlugin::OnAttachACK(int browser_plugin_instance_id) { - DCHECK(!attached()); - attached_ = true; - attach_pending_ = false; -} - void BrowserPlugin::OnCompositorFrameSwapped(const IPC::Message& message) { BrowserPluginMsg_CompositorFrameSwapped::Param param; if (!BrowserPluginMsg_CompositorFrameSwapped::Read(&message, ¶m)) @@ -279,7 +270,7 @@ void BrowserPlugin::UpdateDeviceScaleFactor() { } void BrowserPlugin::UpdateGuestFocusState() { - if (!ready()) + if (!attached()) return; bool should_be_focused = ShouldGuestBeFocused(); browser_plugin_manager()->Send(new BrowserPluginHostMsg_SetFocus( @@ -405,7 +396,6 @@ void BrowserPlugin::paint(WebCanvas* canvas, const WebRect& rect) { bool BrowserPlugin::ShouldForwardToBrowserPlugin( const IPC::Message& message) { switch (message.type()) { - case BrowserPluginMsg_Attach_ACK::ID: case BrowserPluginMsg_AdvanceFocus::ID: case BrowserPluginMsg_CompositorFrameSwapped::ID: case BrowserPluginMsg_GuestGone::ID: @@ -473,7 +463,7 @@ void BrowserPlugin::updateVisibility(bool visible) { return; visible_ = visible; - if (!ready()) + if (!attached()) return; if (compositing_helper_.get()) @@ -491,7 +481,7 @@ bool BrowserPlugin::acceptsInputEvents() { bool BrowserPlugin::handleInputEvent(const blink::WebInputEvent& event, blink::WebCursorInfo& cursor_info) { - if (guest_crashed_ || !ready()) + if (guest_crashed_ || !attached()) return false; if (event.type == blink::WebInputEvent::ContextMenu) @@ -521,7 +511,7 @@ bool BrowserPlugin::handleDragStatusUpdate(blink::WebDragStatus drag_status, blink::WebDragOperationsMask mask, const blink::WebPoint& position, const blink::WebPoint& screen) { - if (guest_crashed_ || !ready()) + if (guest_crashed_ || !attached()) return false; browser_plugin_manager()->Send( new BrowserPluginHostMsg_DragStatusUpdate( @@ -583,7 +573,7 @@ bool BrowserPlugin::setComposition( const blink::WebVector<blink::WebCompositionUnderline>& underlines, int selectionStart, int selectionEnd) { - if (!ready()) + if (!attached()) return false; std::vector<blink::WebCompositionUnderline> std_underlines; for (size_t i = 0; i < underlines.size(); ++i) { @@ -603,7 +593,7 @@ bool BrowserPlugin::setComposition( bool BrowserPlugin::confirmComposition( const blink::WebString& text, blink::WebWidget::ConfirmCompositionBehavior selectionBehavior) { - if (!ready()) + if (!attached()) return false; bool keep_selection = (selectionBehavior == blink::WebWidget::KeepSelection); browser_plugin_manager()->Send(new BrowserPluginHostMsg_ImeConfirmComposition( @@ -616,7 +606,7 @@ bool BrowserPlugin::confirmComposition( } void BrowserPlugin::extendSelectionAndDelete(int before, int after) { - if (!ready()) + if (!attached()) return; browser_plugin_manager()->Send( new BrowserPluginHostMsg_ExtendSelectionAndDelete( diff --git a/content/renderer/browser_plugin/browser_plugin.h b/content/renderer/browser_plugin/browser_plugin.h index d072e7b..f0d9601 100644 --- a/content/renderer/browser_plugin/browser_plugin.h +++ b/content/renderer/browser_plugin/browser_plugin.h @@ -37,7 +37,6 @@ class CONTENT_EXPORT BrowserPlugin : int render_view_routing_id() const { return render_view_routing_id_; } int browser_plugin_instance_id() const { return browser_plugin_instance_id_; } bool attached() const { return attached_; } - bool ready() const { return attached_ || attach_pending_; } BrowserPluginManager* browser_plugin_manager() const { return browser_plugin_manager_.get(); } @@ -170,7 +169,6 @@ class CONTENT_EXPORT BrowserPlugin : // IPC message handlers. // Please keep in alphabetical order. void OnAdvanceFocus(int instance_id, bool reverse); - void OnAttachACK(int browser_plugin_instance_id); void OnCompositorFrameSwapped(const IPC::Message& message); void OnGuestGone(int instance_id); void OnSetContentsOpaque(int instance_id, bool opaque); @@ -181,9 +179,8 @@ class CONTENT_EXPORT BrowserPlugin : void OnShouldAcceptTouchEvents(int instance_id, bool accept); // This indicates whether this BrowserPlugin has been attached to a - // WebContents. + // WebContents and is ready to receive IPCs. bool attached_; - bool attach_pending_; const base::WeakPtr<RenderViewImpl> render_view_; // We cache the |render_view_|'s routing ID because we need it on destruction. // If the |render_view_| is destroyed before the BrowserPlugin is destroyed |