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

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: NPAPI disabling removed, now blocks all plugins 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
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/browser/extensions/extension_host.h"
9 #include "chrome/common/chrome_notification_types.h"
10 #include "chrome/common/content_settings.h"
11 #include "chrome/common/content_settings_pattern.h"
12 #include "chrome/common/extensions/extension.h"
13 #include "chrome/common/url_constants.h"
14 #include "content/public/browser/browser_thread.h"
15 #include "content/public/browser/notification_details.h"
16 #include "content/public/browser/notification_service.h"
17
18 namespace content_settings {
19
20 PlatformAppProvider::PlatformAppProvider() {
21 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_CREATED,
22 content::NotificationService::AllSources());
23 }
24
25 PlatformAppProvider::~PlatformAppProvider() {}
26
27 RuleIterator* PlatformAppProvider::GetRuleIterator(
28 ContentSettingsType content_type,
29 const ResourceIdentifier& resource_identifier,
30 bool incognito) const {
31 return value_map_.GetRuleIterator(content_type, resource_identifier, &lock_);
32 }
33
34 bool PlatformAppProvider::SetWebsiteSetting(
35 const ContentSettingsPattern& primary_pattern,
36 const ContentSettingsPattern& secondary_pattern,
37 ContentSettingsType content_type,
38 const ResourceIdentifier& resource_identifier,
39 Value* value) {
40 return false;
41 }
42
43 void PlatformAppProvider::ClearAllContentSettingsRules(
44 ContentSettingsType content_type) {}
45
46 void PlatformAppProvider::Observe(int type,
47 const content::NotificationSource& source,
48 const content::NotificationDetails& details) {
49 DCHECK(type == chrome::NOTIFICATION_EXTENSION_HOST_CREATED);
50 const ExtensionHost* host = content::Details<ExtensionHost>(details).ptr();
51 if (!host->extension()->is_platform_app())
52 return;
53
54 base::AutoLock lock(lock_);
55 scoped_ptr<ContentSettingsPattern::BuilderInterface> pattern_builder(
56 ContentSettingsPattern::CreateBuilder(false));
57 pattern_builder->WithScheme(chrome::kExtensionScheme);
58 pattern_builder->WithHost(host->extension()->id());
59 pattern_builder->WithPathWildcard();
60
61 value_map_.SetValue(pattern_builder->Build(),
62 ContentSettingsPattern::Wildcard(),
63 CONTENT_SETTINGS_TYPE_PLUGINS,
64 ResourceIdentifier(""),
65 Value::CreateIntegerValue(CONTENT_SETTING_BLOCK));
66 }
67
68 void PlatformAppProvider::ShutdownOnUIThread() {
69 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
70 registrar_.RemoveAll();
71 }
72
73 } // namespace content_settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698