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

Side by Side Diff: chrome/browser/ui/extensions/shell_window.cc

Issue 9169042: Block plugins for platform apps (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix plugin_tests on linux Created 8 years, 10 months 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
« no previous file with comments | « chrome/browser/ui/extensions/shell_window.h ('k') | chrome/chrome_browser.gypi » ('j') | 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/ui/extensions/shell_window.h" 5 #include "chrome/browser/ui/extensions/shell_window.h"
6 6
7 #include "chrome/browser/chrome_plugin_service_filter.h"
8 #include "chrome/browser/extensions/extension_process_manager.h" 7 #include "chrome/browser/extensions/extension_process_manager.h"
9 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/common/chrome_notification_types.h" 9 #include "chrome/common/chrome_notification_types.h"
11 #include "chrome/common/extensions/extension.h" 10 #include "chrome/common/extensions/extension.h"
12 #include "content/browser/renderer_host/render_view_host.h"
13 #include "content/public/browser/notification_details.h" 11 #include "content/public/browser/notification_details.h"
14 #include "content/public/browser/notification_service.h" 12 #include "content/public/browser/notification_service.h"
15 #include "content/public/browser/notification_source.h" 13 #include "content/public/browser/notification_source.h"
16 #include "content/public/browser/notification_types.h" 14 #include "content/public/browser/notification_types.h"
17 #include "content/public/browser/render_process_host.h"
18 15
19 ShellWindow* ShellWindow::Create(Profile* profile, 16 ShellWindow* ShellWindow::Create(Profile* profile,
20 const Extension* extension, 17 const Extension* extension,
21 const GURL& url) { 18 const GURL& url) {
22 ExtensionProcessManager* manager = profile->GetExtensionProcessManager(); 19 ExtensionProcessManager* manager = profile->GetExtensionProcessManager();
23 DCHECK(manager); 20 DCHECK(manager);
24 if (!manager) 21 if (!manager)
25 return NULL; 22 return NULL;
26 23
27 ExtensionHost* host = manager->CreateShellHost(extension, url); 24 ExtensionHost* host = manager->CreateShellHost(extension, url);
(...skipping 30 matching lines...) Expand all
58 break; 55 break;
59 } 56 }
60 case content::NOTIFICATION_APP_TERMINATING: 57 case content::NOTIFICATION_APP_TERMINATING:
61 Close(); 58 Close();
62 break; 59 break;
63 default: 60 default:
64 NOTREACHED() << "Received unexpected notification"; 61 NOTREACHED() << "Received unexpected notification";
65 } 62 }
66 } 63 }
67 64
68 void ShellWindow::RenderViewCreated(RenderViewHost* render_view_host) {
69 DisableNPAPIPlugins();
70 }
71
72 ShellWindow::ShellWindow(ExtensionHost* host) 65 ShellWindow::ShellWindow(ExtensionHost* host)
73 : host_(host) { 66 : host_(host) {
74 // Close the window in response to window.close() and the like. 67 // Close the window in response to window.close() and the like.
75 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE, 68 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE,
76 content::Source<Profile>(host->profile())); 69 content::Source<Profile>(host->profile()));
77 // Also close if the window if the extension has been unloaded (parallels 70 // Also close if the window if the extension has been unloaded (parallels
78 // NOTIFICATION_EXTENSION_UNLOADED closing the app's tabs in TabStripModel). 71 // NOTIFICATION_EXTENSION_UNLOADED closing the app's tabs in TabStripModel).
79 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, 72 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
80 content::Source<Profile>(host->profile())); 73 content::Source<Profile>(host->profile()));
81 // Close when the browser is exiting. 74 // Close when the browser is exiting.
82 // TODO(mihaip): we probably don't want this in the long run (when platform 75 // TODO(mihaip): we probably don't want this in the long run (when platform
83 // apps are no longer tied to the browser process). 76 // apps are no longer tied to the browser process).
84 registrar_.Add(this, content::NOTIFICATION_APP_TERMINATING, 77 registrar_.Add(this, content::NOTIFICATION_APP_TERMINATING,
85 content::NotificationService::AllSources()); 78 content::NotificationService::AllSources());
86 content::WebContentsObserver::Observe(web_contents());
87 } 79 }
88 80
89 ShellWindow::~ShellWindow() { 81 ShellWindow::~ShellWindow() {
90 ClearDisabledNPAPIPlugins();
91 } 82 }
92
93 void ShellWindow::DisableNPAPIPlugins() {
94 int render_process_id = host_->render_process_host()->GetID();
95 int render_view_id = host_->render_view_host()->routing_id();
96 ChromePluginServiceFilter* filter =
97 ChromePluginServiceFilter::GetInstance();
98 filter->DisableNPAPIForRenderView(render_process_id,
99 render_view_id);
100 }
101
102 void ShellWindow::ClearDisabledNPAPIPlugins() {
103 int render_process_id = host_->render_process_host()->GetID();
104 int render_view_id = host_->render_view_host()->routing_id();
105 ChromePluginServiceFilter* filter =
106 ChromePluginServiceFilter::GetInstance();
107 filter->ClearDisabledNPAPIForRenderView(render_process_id,
108 render_view_id);
109 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/extensions/shell_window.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698