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 "chrome/browser/plugins/plugin_observer.h" | 5 #include "chrome/browser/plugins/plugin_observer.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/debug/crash_logging.h" | 9 #include "base/debug/crash_logging.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
175 : content::WebContentsObserver(web_contents), | 175 : content::WebContentsObserver(web_contents), |
176 weak_ptr_factory_(this) { | 176 weak_ptr_factory_(this) { |
177 } | 177 } |
178 | 178 |
179 PluginObserver::~PluginObserver() { | 179 PluginObserver::~PluginObserver() { |
180 #if defined(ENABLE_PLUGIN_INSTALLATION) | 180 #if defined(ENABLE_PLUGIN_INSTALLATION) |
181 STLDeleteValues(&plugin_placeholders_); | 181 STLDeleteValues(&plugin_placeholders_); |
182 #endif | 182 #endif |
183 } | 183 } |
184 | 184 |
185 void PluginObserver::RenderViewCreated( | |
186 content::RenderViewHost* render_view_host) { | |
187 #if defined(USE_AURA) && defined(OS_WIN) | |
188 // If the window belongs to the Ash desktop, before we navigate we need | |
189 // to tell the renderview that NPAPI plugins are not supported so it does | |
190 // not try to instantiate them. The final decision is actually done in | |
191 // the IO thread by PluginInfoMessageFilter of this proces,s but it's more | |
192 // complex to manage a map of Ash views in PluginInfoMessageFilter than | |
193 // just telling the renderer via IPC. | |
194 if (!web_contents()) | |
jam
2013/11/07 00:13:07
this won't happen, so no need to check for this
| |
195 return; | |
196 | |
197 content::WebContentsView* wcv = web_contents()->GetView(); | |
198 if (!wcv) | |
jam
2013/11/07 00:13:07
ditto
| |
199 return; | |
200 | |
201 aura::Window* window = wcv->GetNativeView(); | |
202 if (chrome::GetHostDesktopTypeForNativeView(window) == | |
203 chrome::HOST_DESKTOP_TYPE_ASH) { | |
204 int routing_id = render_view_host->GetRoutingID(); | |
205 render_view_host->Send(new ChromeViewMsg_NPAPINotSupported(routing_id)); | |
206 } | |
207 #endif | |
208 } | |
209 | |
185 void PluginObserver::PluginCrashed(const base::FilePath& plugin_path, | 210 void PluginObserver::PluginCrashed(const base::FilePath& plugin_path, |
186 base::ProcessId plugin_pid) { | 211 base::ProcessId plugin_pid) { |
187 DCHECK(!plugin_path.value().empty()); | 212 DCHECK(!plugin_path.value().empty()); |
188 | 213 |
189 string16 plugin_name = | 214 string16 plugin_name = |
190 PluginService::GetInstance()->GetPluginDisplayNameByPath(plugin_path); | 215 PluginService::GetInstance()->GetPluginDisplayNameByPath(plugin_path); |
191 string16 infobar_text; | 216 string16 infobar_text; |
192 #if defined(OS_WIN) | 217 #if defined(OS_WIN) |
193 // Find out whether the plugin process is still alive. | 218 // Find out whether the plugin process is still alive. |
194 // Note: Although the chances are slim, it is possible that after the plugin | 219 // Note: Although the chances are slim, it is possible that after the plugin |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
247 OnCouldNotLoadPlugin) | 272 OnCouldNotLoadPlugin) |
248 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_NPAPINotSupported, | 273 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_NPAPINotSupported, |
249 OnNPAPINotSupported) | 274 OnNPAPINotSupported) |
250 | 275 |
251 IPC_MESSAGE_UNHANDLED(return false) | 276 IPC_MESSAGE_UNHANDLED(return false) |
252 IPC_END_MESSAGE_MAP() | 277 IPC_END_MESSAGE_MAP() |
253 | 278 |
254 return true; | 279 return true; |
255 } | 280 } |
256 | 281 |
257 void PluginObserver::AboutToNavigateRenderView( | |
258 content::RenderViewHost* render_view_host) { | |
259 #if defined(USE_AURA) && defined(OS_WIN) | |
260 // If the window belongs to the Ash desktop, before we navigate we need | |
261 // to tell the renderview that NPAPI plugins are not supported so it does | |
262 // not try to instantiate them. The final decision is actually done in | |
263 // the IO thread by PluginInfoMessageFilter of this proces,s but it's more | |
264 // complex to manage a map of Ash views in PluginInfoMessageFilter than | |
265 // just telling the renderer via IPC. | |
266 if (!web_contents()) | |
267 return; | |
268 | |
269 content::WebContentsView* wcv = web_contents()->GetView(); | |
270 if (!wcv) | |
271 return; | |
272 | |
273 aura::Window* window = wcv->GetNativeView(); | |
274 if (chrome::GetHostDesktopTypeForNativeView(window) == | |
275 chrome::HOST_DESKTOP_TYPE_ASH) { | |
276 int routing_id = render_view_host->GetRoutingID(); | |
277 render_view_host->Send(new ChromeViewMsg_NPAPINotSupported(routing_id)); | |
278 } | |
279 #endif | |
280 } | |
281 | |
282 void PluginObserver::OnBlockedUnauthorizedPlugin( | 282 void PluginObserver::OnBlockedUnauthorizedPlugin( |
283 const string16& name, | 283 const string16& name, |
284 const std::string& identifier) { | 284 const std::string& identifier) { |
285 UnauthorizedPluginInfoBarDelegate::Create( | 285 UnauthorizedPluginInfoBarDelegate::Create( |
286 InfoBarService::FromWebContents(web_contents()), | 286 InfoBarService::FromWebContents(web_contents()), |
287 Profile::FromBrowserContext(web_contents()->GetBrowserContext())-> | 287 Profile::FromBrowserContext(web_contents()->GetBrowserContext())-> |
288 GetHostContentSettingsMap(), | 288 GetHostContentSettingsMap(), |
289 name, identifier); | 289 name, identifier); |
290 } | 290 } |
291 | 291 |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
404 scoped_ptr<PluginMetadata> plugin; | 404 scoped_ptr<PluginMetadata> plugin; |
405 bool ret = PluginFinder::GetInstance()->FindPluginWithIdentifier( | 405 bool ret = PluginFinder::GetInstance()->FindPluginWithIdentifier( |
406 identifier, NULL, &plugin); | 406 identifier, NULL, &plugin); |
407 DCHECK(ret); | 407 DCHECK(ret); |
408 | 408 |
409 PluginMetroModeInfoBarDelegate::Create( | 409 PluginMetroModeInfoBarDelegate::Create( |
410 InfoBarService::FromWebContents(web_contents()), | 410 InfoBarService::FromWebContents(web_contents()), |
411 PluginMetroModeInfoBarDelegate::DESKTOP_MODE_REQUIRED, plugin->name()); | 411 PluginMetroModeInfoBarDelegate::DESKTOP_MODE_REQUIRED, plugin->name()); |
412 #endif | 412 #endif |
413 } | 413 } |
OLD | NEW |