| Index: content/browser/browser_plugin/browser_plugin_embedder.cc
|
| diff --git a/content/browser/browser_plugin/browser_plugin_embedder.cc b/content/browser/browser_plugin/browser_plugin_embedder.cc
|
| index cb4fcf2add52afd49b81dbcc71536be726e05d86..a40e4625d335ad72cc8546903a2a0d7b543fbad5 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() {
|
| @@ -74,9 +75,11 @@ bool BrowserPluginEmbedder::DidSendScreenRectsCallback(
|
| }
|
|
|
| void BrowserPluginEmbedder::DidSendScreenRects() {
|
| - GetBrowserPluginGuestManager()->ForEachGuest(GetWebContents(), base::Bind(
|
| - &BrowserPluginEmbedder::DidSendScreenRectsCallback,
|
| - base::Unretained(this)));
|
| + BrowserPluginGuestManager::FromBrowserContext(
|
| + GetWebContents()->GetBrowserContext())->ForEachGuest(
|
| + GetWebContents(), base::Bind(
|
| + &BrowserPluginEmbedder::DidSendScreenRectsCallback,
|
| + base::Unretained(this)));
|
| }
|
|
|
| bool BrowserPluginEmbedder::UnlockMouseIfNecessaryCallback(
|
| @@ -93,10 +96,12 @@ bool BrowserPluginEmbedder::HandleKeyboardEvent(
|
| return false;
|
| }
|
|
|
| - return GetBrowserPluginGuestManager()->ForEachGuest(GetWebContents(),
|
| - base::Bind(&BrowserPluginEmbedder::UnlockMouseIfNecessaryCallback,
|
| - base::Unretained(this),
|
| - event));
|
| + return BrowserPluginGuestManager::FromBrowserContext(
|
| + GetWebContents()->GetBrowserContext())->ForEachGuest(
|
| + GetWebContents(),
|
| + base::Bind(&BrowserPluginEmbedder::UnlockMouseIfNecessaryCallback,
|
| + base::Unretained(this),
|
| + event));
|
| }
|
|
|
| bool BrowserPluginEmbedder::SetZoomLevelCallback(
|
| @@ -108,10 +113,12 @@ bool BrowserPluginEmbedder::SetZoomLevelCallback(
|
| }
|
|
|
| void BrowserPluginEmbedder::SetZoomLevel(double level) {
|
| - GetBrowserPluginGuestManager()->ForEachGuest(GetWebContents(), base::Bind(
|
| - &BrowserPluginEmbedder::SetZoomLevelCallback,
|
| - base::Unretained(this),
|
| - level));
|
| + BrowserPluginGuestManager::FromBrowserContext(
|
| + GetWebContents()->GetBrowserContext())->ForEachGuest(
|
| + GetWebContents(), base::Bind(
|
| + &BrowserPluginEmbedder::SetZoomLevelCallback,
|
| + base::Unretained(this),
|
| + level));
|
| }
|
|
|
| bool BrowserPluginEmbedder::OnMessageReceived(const IPC::Message& message) {
|
| @@ -151,34 +158,34 @@ 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();
|
| +void BrowserPluginEmbedder::AllocateInstanceIDResponse(int request_id,
|
| + int instance_id) {
|
| Send(new BrowserPluginMsg_AllocateInstanceID_ACK(
|
| routing_id(), request_id, instance_id));
|
| }
|
|
|
| +void BrowserPluginEmbedder::OnAllocateInstanceID(int request_id,
|
| + const std::string& src) {
|
| + BrowserPluginGuestManager::FromBrowserContext(
|
| + GetWebContents()->GetBrowserContext())->RequestInstanceID(
|
| + src, base::Bind(&BrowserPluginEmbedder::AllocateInstanceIDResponse,
|
| + weak_ptr_factory_.GetWeakPtr(),
|
| + request_id));
|
| +}
|
| +
|
| void BrowserPluginEmbedder::OnAttach(
|
| int instance_id,
|
| const BrowserPluginHostMsg_Attach_Params& params,
|
| const base::DictionaryValue& extra_params) {
|
| - if (!GetBrowserPluginGuestManager()->CanEmbedderAccessInstanceIDMaybeKill(
|
| + BrowserPluginGuestManager* guest_manager =
|
| + BrowserPluginGuestManager::FromBrowserContext(
|
| + GetWebContents()->GetBrowserContext());
|
| + 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 +203,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());
|
|
|