| 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_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED, |
| 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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 | 201 |
| 202 void BrowserPluginHost::WebContentsDestroyed(WebContents* web_contents) { | 202 void BrowserPluginHost::WebContentsDestroyed(WebContents* web_contents) { |
| 203 DestroyGuests(); | 203 DestroyGuests(); |
| 204 } | 204 } |
| 205 | 205 |
| 206 void BrowserPluginHost::Observe( | 206 void BrowserPluginHost::Observe( |
| 207 int type, | 207 int type, |
| 208 const NotificationSource& source, | 208 const NotificationSource& source, |
| 209 const NotificationDetails& details) { | 209 const NotificationDetails& details) { |
| 210 switch (type) { | 210 switch (type) { |
| 211 case NOTIFICATION_RENDER_VIEW_HOST_CREATED_FOR_TAB: { | 211 case NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED: { |
| 212 RenderViewHost* render_view_host = | 212 RenderViewHost* render_view_host = |
| 213 Details<RenderViewHost>(details).ptr(); | 213 Details<RenderViewHost>(details).ptr(); |
| 214 // BrowserPluginHostHelper is destroyed when its associated RenderViewHost | 214 // BrowserPluginHostHelper is destroyed when its associated RenderViewHost |
| 215 // is destroyed. | 215 // is destroyed. |
| 216 new BrowserPluginHostHelper(this, render_view_host); | 216 new BrowserPluginHostHelper(this, render_view_host); |
| 217 break; | 217 break; |
| 218 } | 218 } |
| 219 case NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED: { | 219 case NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED: { |
| 220 bool visible = *Details<bool>(details).ptr(); | 220 bool visible = *Details<bool>(details).ptr(); |
| 221 // If the embedder is hidden we need to hide the guests as well. | 221 // If the embedder is hidden we need to hide the guests as well. |
| 222 for (GuestMap::const_iterator it = guests_.begin(); | 222 for (GuestMap::const_iterator it = guests_.begin(); |
| 223 it != guests_.end(); ++it) { | 223 it != guests_.end(); ++it) { |
| 224 WebContentsImpl* web_contents = it->first; | 224 WebContentsImpl* web_contents = it->first; |
| 225 if (visible) | 225 if (visible) |
| 226 web_contents->WasRestored(); | 226 web_contents->WasRestored(); |
| 227 else | 227 else |
| 228 web_contents->WasHidden(); | 228 web_contents->WasHidden(); |
| 229 } | 229 } |
| 230 break; | 230 break; |
| 231 } | 231 } |
| 232 default: | 232 default: |
| 233 NOTREACHED() << "Unexpected notification type: " << type; | 233 NOTREACHED() << "Unexpected notification type: " << type; |
| 234 } | 234 } |
| 235 } | 235 } |
| 236 | 236 |
| 237 } // namespace content | 237 } // namespace content |
| OLD | NEW |