Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(637)

Side by Side Diff: chrome/browser/plugins/plugin_observer.cc

Issue 62373004: Move the Ash NPAPI plugin blocker logic (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/plugins/plugin_observer.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 content::WebContentsView* wcv = web_contents()->GetView();
195 aura::Window* window = wcv->GetNativeView();
196 if (chrome::GetHostDesktopTypeForNativeView(window) ==
197 chrome::HOST_DESKTOP_TYPE_ASH) {
198 int routing_id = render_view_host->GetRoutingID();
199 render_view_host->Send(new ChromeViewMsg_NPAPINotSupported(routing_id));
200 }
201 #endif
202 }
203
185 void PluginObserver::PluginCrashed(const base::FilePath& plugin_path, 204 void PluginObserver::PluginCrashed(const base::FilePath& plugin_path,
186 base::ProcessId plugin_pid) { 205 base::ProcessId plugin_pid) {
187 DCHECK(!plugin_path.value().empty()); 206 DCHECK(!plugin_path.value().empty());
188 207
189 string16 plugin_name = 208 string16 plugin_name =
190 PluginService::GetInstance()->GetPluginDisplayNameByPath(plugin_path); 209 PluginService::GetInstance()->GetPluginDisplayNameByPath(plugin_path);
191 string16 infobar_text; 210 string16 infobar_text;
192 #if defined(OS_WIN) 211 #if defined(OS_WIN)
193 // Find out whether the plugin process is still alive. 212 // Find out whether the plugin process is still alive.
194 // Note: Although the chances are slim, it is possible that after the plugin 213 // 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
247 OnCouldNotLoadPlugin) 266 OnCouldNotLoadPlugin)
248 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_NPAPINotSupported, 267 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_NPAPINotSupported,
249 OnNPAPINotSupported) 268 OnNPAPINotSupported)
250 269
251 IPC_MESSAGE_UNHANDLED(return false) 270 IPC_MESSAGE_UNHANDLED(return false)
252 IPC_END_MESSAGE_MAP() 271 IPC_END_MESSAGE_MAP()
253 272
254 return true; 273 return true;
255 } 274 }
256 275
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( 276 void PluginObserver::OnBlockedUnauthorizedPlugin(
283 const string16& name, 277 const string16& name,
284 const std::string& identifier) { 278 const std::string& identifier) {
285 UnauthorizedPluginInfoBarDelegate::Create( 279 UnauthorizedPluginInfoBarDelegate::Create(
286 InfoBarService::FromWebContents(web_contents()), 280 InfoBarService::FromWebContents(web_contents()),
287 Profile::FromBrowserContext(web_contents()->GetBrowserContext())-> 281 Profile::FromBrowserContext(web_contents()->GetBrowserContext())->
288 GetHostContentSettingsMap(), 282 GetHostContentSettingsMap(),
289 name, identifier); 283 name, identifier);
290 } 284 }
291 285
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 scoped_ptr<PluginMetadata> plugin; 398 scoped_ptr<PluginMetadata> plugin;
405 bool ret = PluginFinder::GetInstance()->FindPluginWithIdentifier( 399 bool ret = PluginFinder::GetInstance()->FindPluginWithIdentifier(
406 identifier, NULL, &plugin); 400 identifier, NULL, &plugin);
407 DCHECK(ret); 401 DCHECK(ret);
408 402
409 PluginMetroModeInfoBarDelegate::Create( 403 PluginMetroModeInfoBarDelegate::Create(
410 InfoBarService::FromWebContents(web_contents()), 404 InfoBarService::FromWebContents(web_contents()),
411 PluginMetroModeInfoBarDelegate::DESKTOP_MODE_REQUIRED, plugin->name()); 405 PluginMetroModeInfoBarDelegate::DESKTOP_MODE_REQUIRED, plugin->name());
412 #endif 406 #endif
413 } 407 }
OLDNEW
« no previous file with comments | « chrome/browser/plugins/plugin_observer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698