summaryrefslogtreecommitdiffstats
path: root/content/browser/browser_plugin
diff options
context:
space:
mode:
authorfsamuel@chromium.org <fsamuel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-29 21:06:54 +0000
committerfsamuel@chromium.org <fsamuel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-29 21:06:54 +0000
commit738f57aacade9291769daf8be80a08e3b508ca57 (patch)
tree1fad4ce0127b3538b3252763e3b120a6e33146c9 /content/browser/browser_plugin
parent045af40b931762bae677c5a5ec5868cf912c24ac (diff)
downloadchromium_src-738f57aacade9291769daf8be80a08e3b508ca57.zip
chromium_src-738f57aacade9291769daf8be80a08e3b508ca57.tar.gz
chromium_src-738f57aacade9291769daf8be80a08e3b508ca57.tar.bz2
Decouple GuestView creation from attachment.
This enables attaching the GuestView earlier on prior to loading resources. Loading events that occur prior to attachment are queued until attachment and then sent to the embedder on attachment. This CL also moves loadstop from content to chrome. Existing tests exercise the need for queuing. BUG=166165 Test=WebViewTest.Shim (newwindow tests) Review URL: https://chromiumcodereview.appspot.com/17624004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@209345 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/browser_plugin')
-rw-r--r--content/browser/browser_plugin/browser_plugin_embedder.cc12
-rw-r--r--content/browser/browser_plugin/browser_plugin_guest.cc29
-rw-r--r--content/browser/browser_plugin/browser_plugin_guest.h5
-rw-r--r--content/browser/browser_plugin/browser_plugin_guest_manager.cc6
-rw-r--r--content/browser/browser_plugin/browser_plugin_guest_manager.h4
-rw-r--r--content/browser/browser_plugin/browser_plugin_host_browsertest.cc69
6 files changed, 39 insertions, 86 deletions
diff --git a/content/browser/browser_plugin/browser_plugin_embedder.cc b/content/browser/browser_plugin/browser_plugin_embedder.cc
index 4f4fb3a..8f4d3fd 100644
--- a/content/browser/browser_plugin/browser_plugin_embedder.cc
+++ b/content/browser/browser_plugin/browser_plugin_embedder.cc
@@ -179,25 +179,31 @@ void BrowserPluginEmbedder::OnAttach(
if (guest) {
+ // There is an implicit order expectation here:
+ // 1. The content embedder is made aware of the attachment.
+ // 2. BrowserPluginGuest::Attach is called.
+ // 3. The content embedder issues queued events if any that happened
+ // prior to attachment.
GetContentClient()->browser()->GuestWebContentsAttached(
guest->GetWebContents(),
web_contents(),
params.browser_plugin_instance_id,
extra_params);
-
guest->Attach(static_cast<WebContentsImpl*>(web_contents()), params);
return;
}
+ scoped_ptr<base::DictionaryValue> copy_extra_params(extra_params.DeepCopy());
guest = GetBrowserPluginGuestManager()->CreateGuest(
- web_contents()->GetSiteInstance(), instance_id, params);
+ web_contents()->GetSiteInstance(),
+ instance_id, params,
+ copy_extra_params.Pass());
if (guest) {
GetContentClient()->browser()->GuestWebContentsAttached(
guest->GetWebContents(),
web_contents(),
params.browser_plugin_instance_id,
extra_params);
-
guest->Initialize(static_cast<WebContentsImpl*>(web_contents()), params);
}
}
diff --git a/content/browser/browser_plugin/browser_plugin_guest.cc b/content/browser/browser_plugin/browser_plugin_guest.cc
index 3b2e08a..ada1760 100644
--- a/content/browser/browser_plugin/browser_plugin_guest.cc
+++ b/content/browser/browser_plugin/browser_plugin_guest.cc
@@ -473,11 +473,19 @@ BrowserPluginGuest::~BrowserPluginGuest() {
// static
BrowserPluginGuest* BrowserPluginGuest::Create(
int instance_id,
- WebContentsImpl* web_contents) {
+ WebContentsImpl* web_contents,
+ scoped_ptr<base::DictionaryValue> extra_params) {
RecordAction(UserMetricsAction("BrowserPlugin.Guest.Create"));
- if (factory_)
- return factory_->CreateBrowserPluginGuest(instance_id, web_contents);
- return new BrowserPluginGuest(instance_id, web_contents, NULL, false);
+ BrowserPluginGuest* guest = NULL;
+ if (factory_) {
+ guest = factory_->CreateBrowserPluginGuest(instance_id, web_contents);
+ } else {
+ guest = new BrowserPluginGuest(instance_id, web_contents, NULL, false);
+ }
+ web_contents->SetBrowserPluginGuest(guest);
+ GetContentClient()->browser()->GuestWebContentsCreated(
+ web_contents, NULL, extra_params.Pass());
+ return guest;
}
// static
@@ -486,10 +494,14 @@ BrowserPluginGuest* BrowserPluginGuest::CreateWithOpener(
WebContentsImpl* web_contents,
BrowserPluginGuest* opener,
bool has_render_view) {
- return new BrowserPluginGuest(instance_id,
- web_contents,
- opener,
- has_render_view);
+ BrowserPluginGuest* guest =
+ new BrowserPluginGuest(
+ instance_id, web_contents, opener, has_render_view);
+ web_contents->SetBrowserPluginGuest(guest);
+ GetContentClient()->browser()->GuestWebContentsCreated(
+ web_contents, opener->GetWebContents(),
+ scoped_ptr<base::DictionaryValue>());
+ return guest;
}
RenderWidgetHostView* BrowserPluginGuest::GetEmbedderRenderWidgetHostView() {
@@ -937,7 +949,6 @@ void BrowserPluginGuest::DidStopLoading(RenderViewHost* render_view_host) {
render_view_host->ExecuteJavascriptInWebFrame(string16(),
ASCIIToUTF16(script));
}
- SendMessageToEmbedder(new BrowserPluginMsg_LoadStop(instance_id()));
}
void BrowserPluginGuest::RenderViewReady() {
diff --git a/content/browser/browser_plugin/browser_plugin_guest.h b/content/browser/browser_plugin/browser_plugin_guest.h
index 3278afb..c857913 100644
--- a/content/browser/browser_plugin/browser_plugin_guest.h
+++ b/content/browser/browser_plugin/browser_plugin_guest.h
@@ -28,7 +28,7 @@
#include "base/id_map.h"
#include "base/memory/weak_ptr.h"
#include "base/shared_memory.h"
-#include "base/time/time.h"
+#include "base/values.h"
#include "content/common/browser_plugin/browser_plugin_message_enums.h"
#include "content/common/edit_command.h"
#include "content/port/common/input_event_ack_state.h"
@@ -92,7 +92,8 @@ class CONTENT_EXPORT BrowserPluginGuest
static BrowserPluginGuest* Create(
int instance_id,
- WebContentsImpl* web_contents);
+ WebContentsImpl* web_contents,
+ scoped_ptr<base::DictionaryValue> extra_params);
static BrowserPluginGuest* CreateWithOpener(
int instance_id,
diff --git a/content/browser/browser_plugin/browser_plugin_guest_manager.cc b/content/browser/browser_plugin/browser_plugin_guest_manager.cc
index 83bfb88b..75de203 100644
--- a/content/browser/browser_plugin/browser_plugin_guest_manager.cc
+++ b/content/browser/browser_plugin/browser_plugin_guest_manager.cc
@@ -41,7 +41,8 @@ BrowserPluginGuestManager* BrowserPluginGuestManager::Create() {
BrowserPluginGuest* BrowserPluginGuestManager::CreateGuest(
SiteInstance* embedder_site_instance,
int instance_id,
- const BrowserPluginHostMsg_Attach_Params& params) {
+ const BrowserPluginHostMsg_Attach_Params& params,
+ scoped_ptr<base::DictionaryValue> extra_params) {
SiteInstance* guest_site_instance = NULL;
// Validate that the partition id coming from the renderer is valid UTF-8,
// since we depend on this in other parts of the code, such as FilePath
@@ -99,7 +100,8 @@ BrowserPluginGuest* BrowserPluginGuestManager::CreateGuest(
return WebContentsImpl::CreateGuest(
embedder_site_instance->GetBrowserContext(),
guest_site_instance,
- instance_id);
+ instance_id,
+ extra_params.Pass());
}
BrowserPluginGuest* BrowserPluginGuestManager::GetGuestByInstanceID(
diff --git a/content/browser/browser_plugin/browser_plugin_guest_manager.h b/content/browser/browser_plugin/browser_plugin_guest_manager.h
index c2589af..a657bfa 100644
--- a/content/browser/browser_plugin/browser_plugin_guest_manager.h
+++ b/content/browser/browser_plugin/browser_plugin_guest_manager.h
@@ -11,6 +11,7 @@
#include "base/basictypes.h"
#include "base/supports_user_data.h"
+#include "base/values.h"
#include "content/common/content_export.h"
#include "ipc/ipc_message.h"
@@ -60,7 +61,8 @@ class CONTENT_EXPORT BrowserPluginGuestManager :
BrowserPluginGuest* CreateGuest(
SiteInstance* embedder_site_instance,
int instance_id,
- const BrowserPluginHostMsg_Attach_Params& params);
+ const BrowserPluginHostMsg_Attach_Params& params,
+ scoped_ptr<base::DictionaryValue> extra_params);
// Returns a BrowserPluginGuest given an |instance_id|. Returns NULL if the
// guest wasn't found. If the embedder is not permitted to access the given
diff --git a/content/browser/browser_plugin/browser_plugin_host_browsertest.cc b/content/browser/browser_plugin/browser_plugin_host_browsertest.cc
index 342f16f..b202528 100644
--- a/content/browser/browser_plugin/browser_plugin_host_browsertest.cc
+++ b/content/browser/browser_plugin/browser_plugin_host_browsertest.cc
@@ -972,23 +972,6 @@ IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, DISABLED_PostMessageToIFrame) {
}
}
-IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, LoadStop) {
- const char* kEmbedderURL = "/browser_plugin_embedder.html";
- StartBrowserPluginTest(kEmbedderURL, "about:blank", true, std::string());
-
- const string16 expected_title = ASCIIToUTF16("loadStop");
- content::TitleWatcher title_watcher(
- test_embedder()->web_contents(), expected_title);
- // Renavigate the guest to |kHTMLForGuest|.
- RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>(
- test_embedder()->web_contents()->GetRenderViewHost());
- ExecuteSyncJSFunction(rvh,
- base::StringPrintf("SetSrc('%s');", kHTMLForGuest));
-
- string16 actual_title = title_watcher.WaitAndGetTitle();
- EXPECT_EQ(expected_title, actual_title);
-}
-
// This test verifies that if a browser plugin is hidden before navigation,
// the guest starts off hidden.
IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, HiddenBeforeNavigation) {
@@ -1179,58 +1162,6 @@ IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, GetRenderViewHostAtPositionTest) {
test_embedder()->last_rvh_at_position_response());
}
-// Flaky on Win Aura Tests (1) bot. See http://crbug.com/233087.
-#if defined(OS_WIN) && defined(USE_AURA)
-#define MAYBE_ChangeWindowName DISABLED_ChangeWindowName
-#else
-#define MAYBE_ChangeWindowName ChangeWindowName
-#endif
-
-IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, MAYBE_ChangeWindowName) {
- const char kEmbedderURL[] = "/browser_plugin_naming_embedder.html";
- const char* kGuestURL = "/browser_plugin_naming_guest.html";
- StartBrowserPluginTest(kEmbedderURL, kGuestURL, false, std::string());
-
- RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>(
- test_embedder()->web_contents()->GetRenderViewHost());
- // Verify that the plugin's name is properly initialized.
- {
- scoped_ptr<base::Value> value = content::ExecuteScriptAndGetValue(
- rvh, "document.getElementById('plugin').name");
- std::string result;
- EXPECT_TRUE(value->GetAsString(&result));
- EXPECT_EQ("start", result);
- }
- {
- // Open a channel with the guest, wait until it replies,
- // then verify that the plugin's name has been updated.
- const string16 expected_title = ASCIIToUTF16("guest");
- content::TitleWatcher title_watcher(test_embedder()->web_contents(),
- expected_title);
- ExecuteSyncJSFunction(rvh, "OpenCommChannel();");
- string16 actual_title = title_watcher.WaitAndGetTitle();
- EXPECT_EQ(expected_title, actual_title);
-
- scoped_ptr<base::Value> value = content::ExecuteScriptAndGetValue(
- rvh, "document.getElementById('plugin').name");
- std::string result;
- EXPECT_TRUE(value->GetAsString(&result));
- EXPECT_EQ("guest", result);
- }
- {
- // Set the plugin's name and verify that the window.name of the guest
- // has been updated.
- const string16 expected_title = ASCIIToUTF16("foobar");
- content::TitleWatcher title_watcher(test_embedder()->web_contents(),
- expected_title);
- ExecuteSyncJSFunction(rvh,
- "document.getElementById('plugin').name = 'foobar';");
- string16 actual_title = title_watcher.WaitAndGetTitle();
- EXPECT_EQ(expected_title, actual_title);
-
- }
-}
-
// This test verifies that all autosize attributes can be removed
// without crashing the plugin, or throwing errors.
IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, RemoveAutosizeAttributes) {