summaryrefslogtreecommitdiff
path: root/chromium/content/browser/browser_plugin
diff options
context:
space:
mode:
authorZeno Albisser <zeno.albisser@digia.com>2013-11-21 14:09:57 +0100
committerAndras Becsi <andras.becsi@digia.com>2013-11-29 15:14:36 +0100
commiteb32ba6f51d0c21d58cd7d89785285ff8fa64624 (patch)
tree2c7c940e1dbee81b89d935626110816b494aa32c /chromium/content/browser/browser_plugin
parent9427c1a0222ebd67efef1a2c7990a0fa5c9aac84 (diff)
downloadqtwebengine-chromium-eb32ba6f51d0c21d58cd7d89785285ff8fa64624.tar.gz
Update chromium to branch 1599.
Change-Id: I04e775a946a208bb4500d3b722bcb05c82b9d7cb Reviewed-by: Andras Becsi <andras.becsi@digia.com>
Diffstat (limited to 'chromium/content/browser/browser_plugin')
-rw-r--r--chromium/content/browser/browser_plugin/browser_plugin_guest.cc28
-rw-r--r--chromium/content/browser/browser_plugin/browser_plugin_guest.h6
-rw-r--r--chromium/content/browser/browser_plugin/browser_plugin_host_browsertest.cc130
3 files changed, 136 insertions, 28 deletions
diff --git a/chromium/content/browser/browser_plugin/browser_plugin_guest.cc b/chromium/content/browser/browser_plugin/browser_plugin_guest.cc
index 31250b7d626..5f1ec69e8af 100644
--- a/chromium/content/browser/browser_plugin/browser_plugin_guest.cc
+++ b/chromium/content/browser/browser_plugin/browser_plugin_guest.cc
@@ -127,7 +127,7 @@ class BrowserPluginGuest::GeolocationRequest : public PermissionRequest {
// in the fact whether the embedder/app has geolocation
// permission. Therefore we use an invalid |bridge_id|.
-1 /* bridge_id */,
- web_contents->GetLastCommittedURL(),
+ web_contents->GetURL(),
geolocation_callback);
return;
}
@@ -348,7 +348,7 @@ BrowserPluginGuest::BrowserPluginGuest(
embedder_visible_(true),
next_permission_request_id_(browser_plugin::kInvalidPermissionRequestID),
has_render_view_(has_render_view),
- last_seen_auto_size_enabled_(false) {
+ is_in_destruction_(false) {
DCHECK(web_contents);
web_contents->SetDelegate(this);
if (opener)
@@ -422,6 +422,7 @@ int BrowserPluginGuest::RequestPermission(
}
void BrowserPluginGuest::Destroy() {
+ is_in_destruction_ = true;
if (!attached() && opener())
opener()->pending_new_windows_.erase(this);
DestroyUnattachedWindows();
@@ -765,10 +766,6 @@ WebContentsImpl* BrowserPluginGuest::GetWebContents() {
base::SharedMemory* BrowserPluginGuest::GetDamageBufferFromEmbedder(
const BrowserPluginHostMsg_ResizeGuest_Params& params) {
- if (!attached()) {
- LOG(WARNING) << "Attempting to map a damage buffer prior to attachment.";
- return NULL;
- }
#if defined(OS_WIN)
base::ProcessHandle handle =
embedder_web_contents_->GetRenderProcessHost()->GetHandle();
@@ -1264,7 +1261,7 @@ void BrowserPluginGuest::OnLockMouse(bool user_gesture,
base::Value::CreateBooleanValue(last_unlocked_by_target));
request_info.Set(browser_plugin::kURL,
base::Value::CreateStringValue(
- web_contents()->GetLastCommittedURL().spec()));
+ web_contents()->GetURL().spec()));
RequestPermission(BROWSER_PLUGIN_PERMISSION_TYPE_POINTER_LOCK,
new PointerLockRequest(this),
@@ -1321,13 +1318,6 @@ void BrowserPluginGuest::OnResizeGuest(
render_widget_host->NotifyScreenInfoChanged();
}
}
- // When autosize is turned off and as a result there is a layout change, we
- // send a sizechanged event.
- if (!auto_size_enabled_ && last_seen_auto_size_enabled_ &&
- !params.view_rect.size().IsEmpty() && delegate_) {
- delegate_->SizeChanged(last_seen_view_size_, params.view_rect.size());
- last_seen_auto_size_enabled_ = false;
- }
// Invalid damage buffer means we are in HW compositing mode,
// so just resize the WebContents and repaint if needed.
if (!base::SharedMemory::IsHandleValid(params.damage_buffer_handle)) {
@@ -1590,16 +1580,6 @@ void BrowserPluginGuest::OnUpdateRect(
params.flags);
relay_params.needs_ack = params.needs_ack;
- bool size_changed = last_seen_view_size_ != params.view_size;
- gfx::Size old_size = last_seen_view_size_;
- last_seen_view_size_ = params.view_size;
-
- if ((auto_size_enabled_ || last_seen_auto_size_enabled_) &&
- size_changed && delegate_) {
- delegate_->SizeChanged(old_size, last_seen_view_size_);
- }
- last_seen_auto_size_enabled_ = auto_size_enabled_;
-
// HW accelerated case, acknowledge resize only
if (!params.needs_ack || !damage_buffer_) {
relay_params.damage_buffer_sequence_id = 0;
diff --git a/chromium/content/browser/browser_plugin/browser_plugin_guest.h b/chromium/content/browser/browser_plugin/browser_plugin_guest.h
index ffe8d566145..6098cacca38 100644
--- a/chromium/content/browser/browser_plugin/browser_plugin_guest.h
+++ b/chromium/content/browser/browser_plugin/browser_plugin_guest.h
@@ -136,6 +136,7 @@ class CONTENT_EXPORT BrowserPluginGuest
bool focused() const { return focused_; }
bool visible() const { return guest_visible_; }
void clear_damage_buffer() { damage_buffer_.reset(); }
+ bool is_in_destruction() { return is_in_destruction_; }
BrowserPluginGuest* opener() const { return opener_.get(); }
@@ -515,10 +516,7 @@ class CONTENT_EXPORT BrowserPluginGuest
// this guest is attached.
bool has_render_view_;
- // Last seen size of guest contents (by OnUpdateRect).
- gfx::Size last_seen_view_size_;
- // Last seen autosize attribute state (by OnUpdateRect).
- bool last_seen_auto_size_enabled_;
+ bool is_in_destruction_;
// This is a queue of messages that are destined to be sent to the embedder
// once the guest is attached to a particular embedder.
diff --git a/chromium/content/browser/browser_plugin/browser_plugin_host_browsertest.cc b/chromium/content/browser/browser_plugin/browser_plugin_host_browsertest.cc
index c50e8cfa8a3..4fc2ae80335 100644
--- a/chromium/content/browser/browser_plugin/browser_plugin_host_browsertest.cc
+++ b/chromium/content/browser/browser_plugin/browser_plugin_host_browsertest.cc
@@ -786,6 +786,63 @@ IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, FocusTracksEmbedder) {
test_guest()->WaitForBlur();
}
+// This test verifies that if a browser plugin is in autosize mode before
+// navigation then the guest starts auto-sized.
+IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, AutoSizeBeforeNavigation) {
+ const char* kEmbedderURL = "/browser_plugin_embedder.html";
+ const std::string embedder_code =
+ "document.getElementById('plugin').minwidth = 300;"
+ "document.getElementById('plugin').minheight = 200;"
+ "document.getElementById('plugin').maxwidth = 600;"
+ "document.getElementById('plugin').maxheight = 400;"
+ "document.getElementById('plugin').autosize = true;";
+ StartBrowserPluginTest(
+ kEmbedderURL, kHTMLForGuestWithSize, true, embedder_code);
+ // Verify that the guest has been auto-sized.
+ test_guest()->WaitForViewSize(gfx::Size(300, 400));
+}
+
+// This test verifies that enabling autosize resizes the guest and triggers
+// a 'sizechanged' event.
+IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, AutoSizeAfterNavigation) {
+ const char* kEmbedderURL = "/browser_plugin_embedder.html";
+ StartBrowserPluginTest(
+ kEmbedderURL, kHTMLForGuestWithSize, true, std::string());
+ RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>(
+ test_embedder()->web_contents()->GetRenderViewHost());
+
+ {
+ const string16 expected_title = ASCIIToUTF16("AutoSize(300, 400)");
+ content::TitleWatcher title_watcher(test_embedder()->web_contents(),
+ expected_title);
+ ExecuteSyncJSFunction(
+ rvh,
+ "document.getElementById('plugin').minwidth = 300;"
+ "document.getElementById('plugin').minheight = 200;"
+ "document.getElementById('plugin').maxwidth = 600;"
+ "document.getElementById('plugin').maxheight = 400;"
+ "document.getElementById('plugin').autosize = true;");
+ string16 actual_title = title_watcher.WaitAndGetTitle();
+ EXPECT_EQ(expected_title, actual_title);
+ }
+ {
+ // Change the minwidth and verify that it causes relayout.
+ const string16 expected_title = ASCIIToUTF16("AutoSize(350, 400)");
+ content::TitleWatcher title_watcher(test_embedder()->web_contents(),
+ expected_title);
+ ExecuteSyncJSFunction(
+ rvh, "document.getElementById('plugin').minwidth = 350;");
+ string16 actual_title = title_watcher.WaitAndGetTitle();
+ EXPECT_EQ(expected_title, actual_title);
+ }
+ {
+ // Turn off autoSize and verify that the guest resizes to fit the container.
+ ExecuteSyncJSFunction(
+ rvh, "document.getElementById('plugin').autosize = null;");
+ test_guest()->WaitForViewSize(gfx::Size(640, 480));
+ }
+}
+
// Test for regression http://crbug.com/162961.
IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, GetRenderViewHostAtPositionTest) {
const char kEmbedderURL[] = "/browser_plugin_embedder.html";
@@ -801,6 +858,79 @@ IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, GetRenderViewHostAtPositionTest) {
test_embedder()->last_rvh_at_position_response());
}
+// This test verifies that all autosize attributes can be removed
+// without crashing the plugin, or throwing errors.
+IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, RemoveAutosizeAttributes) {
+ const char* kEmbedderURL = "/browser_plugin_embedder.html";
+ const std::string embedder_code =
+ "document.getElementById('plugin').minwidth = 300;"
+ "document.getElementById('plugin').minheight = 200;"
+ "document.getElementById('plugin').maxwidth = 600;"
+ "document.getElementById('plugin').maxheight = 400;"
+ "document.getElementById('plugin').name = 'name';"
+ "document.getElementById('plugin').src = 'foo';"
+ "document.getElementById('plugin').autosize = '';";
+ StartBrowserPluginTest(
+ kEmbedderURL, kHTMLForGuestWithSize, true, embedder_code);
+ RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>(
+ test_embedder()->web_contents()->GetRenderViewHost());
+ RemoveAttributes(rvh, "maxheight, maxwidth, minheight, minwidth, autosize");
+
+ // Verify that the guest resizes to fit the container (and hasn't crashed).
+ test_guest()->WaitForViewSize(gfx::Size(640, 480));
+ EXPECT_TRUE(IsAttributeNull(rvh, "maxheight"));
+ EXPECT_TRUE(IsAttributeNull(rvh, "maxwidth"));
+ EXPECT_TRUE(IsAttributeNull(rvh, "minheight"));
+ EXPECT_TRUE(IsAttributeNull(rvh, "minwidth"));
+ EXPECT_TRUE(IsAttributeNull(rvh, "autosize"));
+}
+
+// This test verifies that autosize works when some of the parameters are unset.
+IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, PartialAutosizeAttributes) {
+ const char* kEmbedderURL = "/browser_plugin_embedder.html";
+ const std::string embedder_code =
+ "document.getElementById('plugin').minwidth = 300;"
+ "document.getElementById('plugin').minheight = 200;"
+ "document.getElementById('plugin').maxwidth = 700;"
+ "document.getElementById('plugin').maxheight = 600;"
+ "document.getElementById('plugin').autosize = '';";
+ StartBrowserPluginTest(
+ kEmbedderURL, kHTMLForGuestWithSize, true, embedder_code);
+ RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>(
+ test_embedder()->web_contents()->GetRenderViewHost());
+ {
+ // Remove an autosize attribute and verify that it causes relayout.
+ const string16 expected_title = ASCIIToUTF16("AutoSize(640, 400)");
+ content::TitleWatcher title_watcher(test_embedder()->web_contents(),
+ expected_title);
+ RemoveAttributes(rvh, "minwidth");
+ string16 actual_title = title_watcher.WaitAndGetTitle();
+ EXPECT_EQ(expected_title, actual_title);
+ }
+ {
+ // Remove an autosize attribute and verify that it causes relayout.
+ // Also tests that when minwidth > maxwidth, minwidth = maxwidth.
+ const string16 expected_title = ASCIIToUTF16("AutoSize(700, 480)");
+ content::TitleWatcher title_watcher(test_embedder()->web_contents(),
+ expected_title);
+ RemoveAttributes(rvh, "maxheight");
+ ExecuteSyncJSFunction(
+ rvh, "document.getElementById('plugin').minwidth = 800;"
+ "document.getElementById('plugin').minheight = 800;");
+ string16 actual_title = title_watcher.WaitAndGetTitle();
+ EXPECT_EQ(expected_title, actual_title);
+ }
+ {
+ // Remove maxwidth and make sure the size returns to plugin size.
+ const string16 expected_title = ASCIIToUTF16("AutoSize(640, 480)");
+ content::TitleWatcher title_watcher(test_embedder()->web_contents(),
+ expected_title);
+ RemoveAttributes(rvh, "maxwidth");
+ string16 actual_title = title_watcher.WaitAndGetTitle();
+ EXPECT_EQ(expected_title, actual_title);
+ }
+}
+
// This test verifies that if IME is enabled in the embedder, it is also enabled
// in the guest.
IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, VerifyInputMethodActive) {