summaryrefslogtreecommitdiffstats
path: root/content/browser/browser_plugin/browser_plugin_embedder.cc
diff options
context:
space:
mode:
authorfsamuel@chromium.org <fsamuel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-06 03:31:30 +0000
committerfsamuel@chromium.org <fsamuel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-06 03:31:30 +0000
commit2456926a4579ff3bfa2b686c05a06014dab5b78f (patch)
treec49fee81d578a3520b92a3e89b9a724ec0f0418f /content/browser/browser_plugin/browser_plugin_embedder.cc
parent8022ed59d498755730a7c2d290596b48458b4f62 (diff)
downloadchromium_src-2456926a4579ff3bfa2b686c05a06014dab5b78f.zip
chromium_src-2456926a4579ff3bfa2b686c05a06014dab5b78f.tar.gz
chromium_src-2456926a4579ff3bfa2b686c05a06014dab5b78f.tar.bz2
Towards moving guest management to chrome: Introduce GuestViewManager
This CL moves a lot of functionality from BrowserPluginGuestManager to GuestViewManager including instance ID allocation. Currently GuestViewManager is a BrowserPluginGuestManagerDelegate. In the future, GuestViewManager will completely replace BrowserPluginGuestManager. BUG=364141, 330264 Review URL: https://codereview.chromium.org/258373002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@268391 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/browser_plugin/browser_plugin_embedder.cc')
-rw-r--r--content/browser/browser_plugin/browser_plugin_embedder.cc44
1 files changed, 21 insertions, 23 deletions
diff --git a/content/browser/browser_plugin/browser_plugin_embedder.cc b/content/browser/browser_plugin/browser_plugin_embedder.cc
index cb4fcf2..152f75e 100644
--- a/content/browser/browser_plugin/browser_plugin_embedder.cc
+++ b/content/browser/browser_plugin/browser_plugin_embedder.cc
@@ -31,7 +31,8 @@ namespace content {
BrowserPluginHostFactory* BrowserPluginEmbedder::factory_ = NULL;
BrowserPluginEmbedder::BrowserPluginEmbedder(WebContentsImpl* web_contents)
- : WebContentsObserver(web_contents) {
+ : WebContentsObserver(web_contents),
+ weak_ptr_factory_(this) {
}
BrowserPluginEmbedder::~BrowserPluginEmbedder() {
@@ -61,10 +62,16 @@ void BrowserPluginEmbedder::StartDrag(BrowserPluginGuest* guest) {
guest_started_drag_ = guest->AsWeakPtr();
}
-WebContentsImpl* BrowserPluginEmbedder::GetWebContents() {
+WebContentsImpl* BrowserPluginEmbedder::GetWebContents() const {
return static_cast<WebContentsImpl*>(web_contents());
}
+BrowserPluginGuestManager*
+BrowserPluginEmbedder::GetBrowserPluginGuestManager() const {
+ return BrowserPluginGuestManager::FromBrowserContext(
+ GetWebContents()->GetBrowserContext());
+}
+
bool BrowserPluginEmbedder::DidSendScreenRectsCallback(
BrowserPluginGuest* guest) {
static_cast<RenderViewHostImpl*>(
@@ -93,7 +100,8 @@ bool BrowserPluginEmbedder::HandleKeyboardEvent(
return false;
}
- return GetBrowserPluginGuestManager()->ForEachGuest(GetWebContents(),
+ return GetBrowserPluginGuestManager()->ForEachGuest(
+ GetWebContents(),
base::Bind(&BrowserPluginEmbedder::UnlockMouseIfNecessaryCallback,
base::Unretained(this),
event));
@@ -108,10 +116,11 @@ bool BrowserPluginEmbedder::SetZoomLevelCallback(
}
void BrowserPluginEmbedder::SetZoomLevel(double level) {
- GetBrowserPluginGuestManager()->ForEachGuest(GetWebContents(), base::Bind(
- &BrowserPluginEmbedder::SetZoomLevelCallback,
- base::Unretained(this),
- level));
+ GetBrowserPluginGuestManager()->ForEachGuest(
+ GetWebContents(), base::Bind(
+ &BrowserPluginEmbedder::SetZoomLevelCallback,
+ base::Unretained(this),
+ level));
}
bool BrowserPluginEmbedder::OnMessageReceived(const IPC::Message& message) {
@@ -151,20 +160,8 @@ void BrowserPluginEmbedder::OnUpdateDragCursor(bool* handled) {
*handled = (guest_dragging_over_.get() != NULL);
}
-BrowserPluginGuestManager*
- BrowserPluginEmbedder::GetBrowserPluginGuestManager() {
- BrowserPluginGuestManager* guest_manager =
- GetWebContents()->GetBrowserPluginGuestManager();
- if (!guest_manager) {
- guest_manager = BrowserPluginGuestManager::Create();
- GetWebContents()->GetBrowserContext()->SetUserData(
- browser_plugin::kBrowserPluginGuestManagerKeyName, guest_manager);
- }
- return guest_manager;
-}
-
void BrowserPluginEmbedder::OnAllocateInstanceID(int request_id) {
- int instance_id = GetBrowserPluginGuestManager()->get_next_instance_id();
+ int instance_id = GetBrowserPluginGuestManager()->GetNextInstanceID();
Send(new BrowserPluginMsg_AllocateInstanceID_ACK(
routing_id(), request_id, instance_id));
}
@@ -173,12 +170,13 @@ void BrowserPluginEmbedder::OnAttach(
int instance_id,
const BrowserPluginHostMsg_Attach_Params& params,
const base::DictionaryValue& extra_params) {
- if (!GetBrowserPluginGuestManager()->CanEmbedderAccessInstanceIDMaybeKill(
+ BrowserPluginGuestManager* guest_manager = GetBrowserPluginGuestManager();
+ if (!guest_manager->CanEmbedderAccessInstanceIDMaybeKill(
GetWebContents()->GetRenderProcessHost()->GetID(), instance_id))
return;
BrowserPluginGuest* guest =
- GetBrowserPluginGuestManager()->GetGuestByInstanceID(
+ guest_manager->GetGuestByInstanceID(
instance_id, GetWebContents()->GetRenderProcessHost()->GetID());
if (guest) {
@@ -196,7 +194,7 @@ void BrowserPluginEmbedder::OnAttach(
}
scoped_ptr<base::DictionaryValue> copy_extra_params(extra_params.DeepCopy());
- guest = GetBrowserPluginGuestManager()->CreateGuest(
+ guest = guest_manager->CreateGuest(
GetWebContents()->GetSiteInstance(),
instance_id, params,
copy_extra_params.Pass());