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

Side by Side Diff: chrome/browser/content_settings/content_settings_platform_app_provider.cc

Issue 9169042: Block plugins for platform apps (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 11 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/content_settings/content_settings_platform_app_provider .h"
6
7 #include "chrome/browser/content_settings/content_settings_rule.h"
8 #include "chrome/common/chrome_notification_types.h"
9 #include "chrome/common/content_settings.h"
10 #include "chrome/common/content_settings_pattern.h"
11 #include "chrome/common/extensions/extension.h"
12 #include "chrome/common/url_constants.h"
13 #include "content/public/browser/browser_thread.h"
14 #include "content/public/browser/notification_details.h"
15 #include "content/public/browser/notification_service.h"
16
17 namespace content_settings {
18
19 PlatformAppProvider::PlatformAppProvider() {
20 registrar_.Add(this, chrome::NOTIFICATION_PLATFORM_APP_STARTED,
21 content::NotificationService::AllSources());
22 }
23
24 RuleIterator* PlatformAppProvider::GetRuleIterator(
25 ContentSettingsType content_type,
26 const ResourceIdentifier& resource_identifier,
27 bool incognito) const {
28 return value_map_.GetRuleIterator(content_type, resource_identifier, &lock_);
29 }
30
31 void PlatformAppProvider::Observe(int type,
32 const content::NotificationSource& source,
33 const content::NotificationDetails& details) {
34 DCHECK(type == chrome::NOTIFICATION_PLATFORM_APP_STARTED);
35 const Extension* extension = content::Details<const Extension>(details).ptr();
36 DCHECK(extension->is_platform_app());
37
38 base::AutoLock lock(lock_);
39 scoped_ptr<ContentSettingsPattern::BuilderInterface> pattern_builder(
40 ContentSettingsPattern::CreateBuilder(false));
41 pattern_builder->WithScheme(chrome::kExtensionScheme);
42 pattern_builder->WithHost(extension->id());
43 pattern_builder->WithPathWildcard();
44
45 value_map_.SetValue(pattern_builder->Build(),
46 ContentSettingsPattern::Wildcard(),
47 CONTENT_SETTINGS_TYPE_PLUGINS,
48 ResourceIdentifier("adobe-flash-player"),
Bernhard Bauer 2012/01/25 13:59:04 Can't we just disallow all plug-ins already? ;-)
49 Value::CreateIntegerValue(CONTENT_SETTING_BLOCK));
50 }
51
52 void PlatformAppProvider::ShutdownOnUIThread() {
53 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
54 registrar_.RemoveAll();
55 }
56
57 } // namespace content_settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698