summaryrefslogtreecommitdiffstats
path: root/content/browser/browser_plugin
diff options
context:
space:
mode:
authorpaulmeyer <paulmeyer@chromium.org>2015-02-24 11:15:10 -0800
committerCommit bot <commit-bot@chromium.org>2015-02-24 19:16:05 +0000
commit9ef6e446e6621ea47df1eebabae2747fdf4a2290 (patch)
tree176e9ddf635992af875edee8f28ed03783eeb982 /content/browser/browser_plugin
parent355ef6861a0af7fdf163615abe04bd00cd640f1e (diff)
downloadchromium_src-9ef6e446e6621ea47df1eebabae2747fdf4a2290.zip
chromium_src-9ef6e446e6621ea47df1eebabae2747fdf4a2290.tar.gz
chromium_src-9ef6e446e6621ea47df1eebabae2747fdf4a2290.tar.bz2
All guestview sizing now utilizes the new sizing infrastructure from https://codereview.chromium.org/856563002/ and https://codereview.chromium.org/857093003/. The existing sizing code in BrowserPluginGuest was removed, which allowed for a large amount of plumbing that went into and out of BrowserPluginGuest to be removed as well.
BUG=434226 TBR=rockot@chromium.org Review URL: https://codereview.chromium.org/889303003 Cr-Commit-Position: refs/heads/master@{#317849}
Diffstat (limited to 'content/browser/browser_plugin')
-rw-r--r--content/browser/browser_plugin/browser_plugin_embedder.cc18
-rw-r--r--content/browser/browser_plugin/browser_plugin_embedder.h6
-rw-r--r--content/browser/browser_plugin/browser_plugin_guest.cc38
-rw-r--r--content/browser/browser_plugin/browser_plugin_guest.h7
4 files changed, 31 insertions, 38 deletions
diff --git a/content/browser/browser_plugin/browser_plugin_embedder.cc b/content/browser/browser_plugin/browser_plugin_embedder.cc
index 99a8fde..acb72f0 100644
--- a/content/browser/browser_plugin/browser_plugin_embedder.cc
+++ b/content/browser/browser_plugin/browser_plugin_embedder.cc
@@ -46,6 +46,24 @@ void BrowserPluginEmbedder::DragLeftGuest(BrowserPluginGuest* guest) {
}
}
+// static
+bool BrowserPluginEmbedder::NotifyScreenInfoChanged(
+ WebContents* guest_web_contents) {
+ if (guest_web_contents->GetRenderViewHost()) {
+ auto render_widget_host =
+ RenderWidgetHostImpl::From(guest_web_contents->GetRenderViewHost());
+ render_widget_host->NotifyScreenInfoChanged();
+ }
+
+ // Returns false to iterate over all guests.
+ return false;
+}
+
+void BrowserPluginEmbedder::ScreenInfoChanged() {
+ GetBrowserPluginGuestManager()->ForEachGuest(web_contents(), base::Bind(
+ &BrowserPluginEmbedder::NotifyScreenInfoChanged));
+}
+
void BrowserPluginEmbedder::StartDrag(BrowserPluginGuest* guest) {
guest_started_drag_ = guest->AsWeakPtr();
guest_drag_ending_ = false;
diff --git a/content/browser/browser_plugin/browser_plugin_embedder.h b/content/browser/browser_plugin/browser_plugin_embedder.h
index c42f7b8..74f259e 100644
--- a/content/browser/browser_plugin/browser_plugin_embedder.h
+++ b/content/browser/browser_plugin/browser_plugin_embedder.h
@@ -53,6 +53,9 @@ class CONTENT_EXPORT BrowserPluginEmbedder : public WebContentsObserver {
// Indicates that a drag operation has left the bounds of a given |guest|.
void DragLeftGuest(BrowserPluginGuest* guest);
+ // Called when the screen info has changed.
+ void ScreenInfoChanged();
+
// Called by WebContentsViewGuest when a drag operation is started within
// |guest|. This |guest| will be signaled at the end of the drag operation.
void StartDrag(BrowserPluginGuest* guest);
@@ -80,6 +83,9 @@ class CONTENT_EXPORT BrowserPluginEmbedder : public WebContentsObserver {
static bool DidSendScreenRectsCallback(WebContents* guest_web_contents);
+ // Notifies a guest that the embedder's screen info has changed.
+ static bool NotifyScreenInfoChanged(WebContents* guest_web_contents);
+
static bool UnlockMouseIfNecessaryCallback(bool* mouse_unlocked,
WebContents* guest);
diff --git a/content/browser/browser_plugin/browser_plugin_guest.cc b/content/browser/browser_plugin/browser_plugin_guest.cc
index 36df52f..a29b56d 100644
--- a/content/browser/browser_plugin/browser_plugin_guest.cc
+++ b/content/browser/browser_plugin/browser_plugin_guest.cc
@@ -76,7 +76,6 @@ BrowserPluginGuest::BrowserPluginGuest(bool has_render_view,
owner_web_contents_(nullptr),
attached_(false),
browser_plugin_instance_id_(browser_plugin::kInstanceIDNone),
- guest_device_scale_factor_(1.0f),
focused_(false),
mouse_locked_(false),
pending_lock_request_(false),
@@ -214,7 +213,6 @@ bool BrowserPluginGuest::OnMessageReceivedFromEmbedder(
IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_LockMouse_ACK, OnLockMouseAck)
IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ReclaimCompositorResources,
OnReclaimCompositorResources)
- IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ResizeGuest, OnResizeGuest)
IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetEditCommandsForNextKeyEvent,
OnSetEditCommandsForNextKeyEvent)
IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetFocus, OnSetFocus)
@@ -238,8 +236,7 @@ void BrowserPluginGuest::InitInternal(
UpdateVisibility();
is_full_page_plugin_ = params.is_full_page_plugin;
- guest_window_rect_ = gfx::Rect(params.origin,
- params.resize_guest_params.view_size);
+ guest_window_rect_ = gfx::Rect(params.origin, params.view_size);
if (owner_web_contents_ != owner_web_contents) {
WebContentsViewGuest* new_view =
@@ -277,9 +274,12 @@ void BrowserPluginGuest::InitInternal(
embedder_visibility_observer_.reset(new EmbedderVisibilityObserver(this));
- // The instance ID does not matter here. This instance ID is used by the IPC
- // for routing, but here we're calling OnResizeGuest for initialization.
- OnResizeGuest(browser_plugin::kInstanceIDNone, params.resize_guest_params);
+ DCHECK(GetWebContents()->GetRenderViewHost());
+
+ // Initialize the device scale factor by calling |NotifyScreenInfoChanged|.
+ auto render_widget_host =
+ RenderWidgetHostImpl::From(GetWebContents()->GetRenderViewHost());
+ render_widget_host->NotifyScreenInfoChanged();
// TODO(chrishtr): this code is wrong. The navigate_on_drag_drop field will
// be reset again the next time preferences are updated.
@@ -519,7 +519,6 @@ bool BrowserPluginGuest::ShouldForwardToBrowserPluginGuest(
case BrowserPluginHostMsg_ImeSetComposition::ID:
case BrowserPluginHostMsg_LockMouse_ACK::ID:
case BrowserPluginHostMsg_ReclaimCompositorResources::ID:
- case BrowserPluginHostMsg_ResizeGuest::ID:
case BrowserPluginHostMsg_SetEditCommandsForNextKeyEvent::ID:
case BrowserPluginHostMsg_SetFocus::ID:
case BrowserPluginHostMsg_SetVisibility::ID:
@@ -781,29 +780,6 @@ void BrowserPluginGuest::OnLockMouseAck(int browser_plugin_instance_id,
mouse_locked_ = true;
}
-void BrowserPluginGuest::OnResizeGuest(
- int browser_plugin_instance_id,
- const BrowserPluginHostMsg_ResizeGuest_Params& params) {
- // If we are setting the size for the first time before navigating then
- // BrowserPluginGuest does not yet have a RenderViewHost.
- if (guest_device_scale_factor_ != params.scale_factor &&
- GetWebContents()->GetRenderViewHost()) {
- auto render_widget_host =
- RenderWidgetHostImpl::From(GetWebContents()->GetRenderViewHost());
- guest_device_scale_factor_ = params.scale_factor;
- render_widget_host->NotifyScreenInfoChanged();
- }
-
- if (last_seen_browser_plugin_size_ != params.view_size) {
- delegate_->ElementSizeChanged(params.view_size);
- last_seen_browser_plugin_size_ = params.view_size;
- }
-
- // Just repaint the WebContents if needed.
- if (params.repaint)
- Send(new ViewMsg_Repaint(routing_id(), params.view_size));
-}
-
void BrowserPluginGuest::OnSetFocus(int browser_plugin_instance_id,
bool focused,
blink::WebFocusType focus_type) {
diff --git a/content/browser/browser_plugin/browser_plugin_guest.h b/content/browser/browser_plugin/browser_plugin_guest.h
index 5376174..eb0a173 100644
--- a/content/browser/browser_plugin/browser_plugin_guest.h
+++ b/content/browser/browser_plugin/browser_plugin_guest.h
@@ -42,7 +42,6 @@
class GuestSizer;
class SkBitmap;
struct BrowserPluginHostMsg_Attach_Params;
-struct BrowserPluginHostMsg_ResizeGuest_Params;
struct FrameHostMsg_CompositorFrameSwappedACK_Params;
struct FrameHostMsg_ReclaimCompositorResources_Params;
struct FrameMsg_CompositorFrameSwapped_Params;
@@ -266,9 +265,6 @@ class CONTENT_EXPORT BrowserPluginGuest : public GuestSizer,
bool privileged);
void OnLockMouseAck(int instance_id, bool succeeded);
// Resizes the guest's web contents.
- void OnResizeGuest(
- int browser_plugin_instance_id,
- const BrowserPluginHostMsg_ResizeGuest_Params& params);
void OnSetFocus(int instance_id,
bool focused,
blink::WebFocusType focus_type);
@@ -352,7 +348,6 @@ class CONTENT_EXPORT BrowserPluginGuest : public GuestSizer,
// An identifier that uniquely identifies a browser plugin within an embedder.
int browser_plugin_instance_id_;
- float guest_device_scale_factor_;
gfx::Rect guest_window_rect_;
bool focused_;
bool mouse_locked_;
@@ -371,8 +366,6 @@ class CONTENT_EXPORT BrowserPluginGuest : public GuestSizer,
// Last seen size of guest contents (by SwapCompositorFrame).
gfx::Size last_seen_view_size_;
- // Last seen size of BrowserPlugin (by OnResizeGuest).
- gfx::Size last_seen_browser_plugin_size_;
bool is_in_destruction_;