Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/browser_plugin/old/browser_plugin_host.h" | 5 #include "content/browser/browser_plugin/old/browser_plugin_host.h" |
| 6 | 6 |
| 7 #include "content/browser/browser_plugin/old/browser_plugin_host_helper.h" | 7 #include "content/browser/browser_plugin/old/browser_plugin_host_helper.h" |
| 8 #include "content/browser/renderer_host/render_view_host_impl.h" | 8 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 9 #include "content/browser/web_contents/web_contents_impl.h" | 9 #include "content/browser/web_contents/web_contents_impl.h" |
| 10 #include "content/common/browser_plugin_messages.h" | 10 #include "content/common/browser_plugin_messages.h" |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 embedder_render_process_host_(NULL), | 26 embedder_render_process_host_(NULL), |
| 27 instance_id_(0) { | 27 instance_id_(0) { |
| 28 // Listen to visibility changes so that an embedder hides its guests | 28 // Listen to visibility changes so that an embedder hides its guests |
| 29 // as well. | 29 // as well. |
| 30 registrar_.Add(this, | 30 registrar_.Add(this, |
| 31 NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED, | 31 NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED, |
| 32 Source<WebContents>(web_contents)); | 32 Source<WebContents>(web_contents)); |
| 33 // Construct plumbing helpers when a new RenderViewHost is created for | 33 // Construct plumbing helpers when a new RenderViewHost is created for |
| 34 // this BrowserPluginHost's WebContentsImpl. | 34 // this BrowserPluginHost's WebContentsImpl. |
| 35 registrar_.Add(this, | 35 registrar_.Add(this, |
| 36 NOTIFICATION_RENDER_VIEW_HOST_CREATED_FOR_TAB, | 36 NOTIFICATION_WILL_CREATE_RENDER_VIEW, |
|
Fady Samuel
2012/07/06 15:14:44
Given you're applying changes to the new design, c
| |
| 37 Source<WebContents>(web_contents)); | 37 Source<WebContents>(web_contents)); |
| 38 } | 38 } |
| 39 | 39 |
| 40 BrowserPluginHost::~BrowserPluginHost() { | 40 BrowserPluginHost::~BrowserPluginHost() { |
| 41 } | 41 } |
| 42 | 42 |
| 43 BrowserPluginHost* BrowserPluginHost::GetGuestByContainerID(int container_id) { | 43 BrowserPluginHost* BrowserPluginHost::GetGuestByContainerID(int container_id) { |
| 44 ContainerInstanceMap::const_iterator it = | 44 ContainerInstanceMap::const_iterator it = |
| 45 guests_by_container_id_.find(container_id); | 45 guests_by_container_id_.find(container_id); |
| 46 if (it != guests_by_container_id_.end()) | 46 if (it != guests_by_container_id_.end()) |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 69 OnNavigateFromGuest) | 69 OnNavigateFromGuest) |
| 70 IPC_MESSAGE_UNHANDLED(handled = false) | 70 IPC_MESSAGE_UNHANDLED(handled = false) |
| 71 IPC_END_MESSAGE_MAP() | 71 IPC_END_MESSAGE_MAP() |
| 72 return handled; | 72 return handled; |
| 73 } | 73 } |
| 74 | 74 |
| 75 void BrowserPluginHost::NavigateGuestFromEmbedder( | 75 void BrowserPluginHost::NavigateGuestFromEmbedder( |
| 76 RenderViewHost* render_view_host, | 76 RenderViewHost* render_view_host, |
| 77 int container_instance_id, | 77 int container_instance_id, |
| 78 long long frame_id, | 78 long long frame_id, |
| 79 const std::string& src) { | 79 const std::string& src, |
| 80 const BrowserPluginHostMsg_Surface_Params& params) { | |
| 80 BrowserPluginHost* guest_observer = | 81 BrowserPluginHost* guest_observer = |
| 81 GetGuestByContainerID(container_instance_id); | 82 GetGuestByContainerID(container_instance_id); |
| 82 WebContentsImpl* guest_web_contents = | 83 WebContentsImpl* guest_web_contents = |
| 83 guest_observer ? | 84 guest_observer ? |
| 84 static_cast<WebContentsImpl*>(guest_observer->web_contents()): NULL; | 85 static_cast<WebContentsImpl*>(guest_observer->web_contents()): NULL; |
| 85 GURL url(src); | 86 GURL url(src); |
| 86 if (!guest_observer) { | 87 if (!guest_observer) { |
| 87 std::string host = render_view_host->GetSiteInstance()->GetSite().host(); | 88 std::string host = render_view_host->GetSiteInstance()->GetSite().host(); |
| 88 GURL guest_url( | 89 GURL guest_url( |
| 89 base::StringPrintf("%s://%s", chrome::kGuestScheme, host.c_str())); | 90 base::StringPrintf("%s://%s", chrome::kGuestScheme, host.c_str())); |
| 90 // The SiteInstance of a given guest is based on the fact that it's a guest | 91 // The SiteInstance of a given guest is based on the fact that it's a guest |
| 91 // in addition to which platform application the guest belongs to, rather | 92 // in addition to which platform application the guest belongs to, rather |
| 92 // than the URL that the guest is being navigated to. | 93 // than the URL that the guest is being navigated to. |
| 93 SiteInstance* guest_site_instance = | 94 SiteInstance* guest_site_instance = |
| 94 SiteInstance::CreateForURL(web_contents()->GetBrowserContext(), | 95 SiteInstance::CreateForURL(web_contents()->GetBrowserContext(), |
| 95 guest_url); | 96 guest_url); |
| 96 guest_web_contents = | 97 guest_web_contents = |
| 97 static_cast<WebContentsImpl*>( | 98 static_cast<WebContentsImpl*>( |
| 98 WebContents::Create( | 99 WebContents::Create( |
| 99 web_contents()->GetBrowserContext(), | 100 web_contents()->GetBrowserContext(), |
| 100 guest_site_instance, | 101 guest_site_instance, |
| 101 MSG_ROUTING_NONE, | 102 MSG_ROUTING_NONE, |
| 102 NULL, // base WebContents | 103 NULL, // base WebContents |
| 103 NULL // session storage namespace | 104 NULL // session storage namespace |
| 104 )); | 105 )); |
| 105 guest_observer = | 106 guest_observer = |
| 106 guest_web_contents->browser_plugin_host(); | 107 guest_web_contents->browser_plugin_host(); |
| 108 guest_observer->set_surface_params(params); | |
| 107 guest_observer->set_embedder_render_process_host( | 109 guest_observer->set_embedder_render_process_host( |
| 108 render_view_host->GetProcess()); | 110 render_view_host->GetProcess()); |
| 109 guest_observer->set_instance_id(container_instance_id); | 111 guest_observer->set_instance_id(container_instance_id); |
| 110 RegisterContainerInstance(container_instance_id, guest_observer); | 112 RegisterContainerInstance(container_instance_id, guest_observer); |
| 111 AddGuest(guest_web_contents, frame_id); | 113 AddGuest(guest_web_contents, frame_id); |
| 112 } | 114 } |
| 113 guest_observer->web_contents()->SetDelegate(guest_observer); | 115 guest_observer->web_contents()->SetDelegate(guest_observer); |
| 114 guest_observer->web_contents()->GetController().LoadURL( | 116 guest_observer->web_contents()->GetController().LoadURL( |
| 115 url, | 117 url, |
| 116 Referrer(), | 118 Referrer(), |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 201 | 203 |
| 202 void BrowserPluginHost::WebContentsDestroyed(WebContents* web_contents) { | 204 void BrowserPluginHost::WebContentsDestroyed(WebContents* web_contents) { |
| 203 DestroyGuests(); | 205 DestroyGuests(); |
| 204 } | 206 } |
| 205 | 207 |
| 206 void BrowserPluginHost::Observe( | 208 void BrowserPluginHost::Observe( |
| 207 int type, | 209 int type, |
| 208 const NotificationSource& source, | 210 const NotificationSource& source, |
| 209 const NotificationDetails& details) { | 211 const NotificationDetails& details) { |
| 210 switch (type) { | 212 switch (type) { |
| 211 case NOTIFICATION_RENDER_VIEW_HOST_CREATED_FOR_TAB: { | 213 case NOTIFICATION_WILL_CREATE_RENDER_VIEW: { |
| 212 RenderViewHost* render_view_host = | 214 RenderViewHost* render_view_host = |
| 213 Details<RenderViewHost>(details).ptr(); | 215 Details<RenderViewHost>(details).ptr(); |
| 214 // BrowserPluginHostHelper is destroyed when its associated RenderViewHost | 216 // BrowserPluginHostHelper is destroyed when its associated RenderViewHost |
| 215 // is destroyed. | 217 // is destroyed. |
| 216 new BrowserPluginHostHelper(this, render_view_host); | 218 new BrowserPluginHostHelper(this, render_view_host, surface_params_); |
| 217 break; | 219 break; |
| 218 } | 220 } |
| 219 case NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED: { | 221 case NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED: { |
| 220 bool visible = *Details<bool>(details).ptr(); | 222 bool visible = *Details<bool>(details).ptr(); |
| 221 // If the embedder is hidden we need to hide the guests as well. | 223 // If the embedder is hidden we need to hide the guests as well. |
| 222 for (GuestMap::const_iterator it = guests_.begin(); | 224 for (GuestMap::const_iterator it = guests_.begin(); |
| 223 it != guests_.end(); ++it) { | 225 it != guests_.end(); ++it) { |
| 224 WebContentsImpl* web_contents = it->first; | 226 WebContentsImpl* web_contents = it->first; |
| 225 if (visible) | 227 if (visible) |
| 226 web_contents->WasRestored(); | 228 web_contents->WasRestored(); |
| 227 else | 229 else |
| 228 web_contents->WasHidden(); | 230 web_contents->WasHidden(); |
| 229 } | 231 } |
| 230 break; | 232 break; |
| 231 } | 233 } |
| 232 default: | 234 default: |
| 233 NOTREACHED() << "Unexpected notification type: " << type; | 235 NOTREACHED() << "Unexpected notification type: " << type; |
| 234 } | 236 } |
| 235 } | 237 } |
| 236 | 238 |
| 237 } // namespace content | 239 } // namespace content |
| OLD | NEW |