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

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

Issue 10823370: rename ExtensionProvider and PlatformAppProvider class (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 8 years, 4 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 | Annotate | Revision Log
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/content_settings/content_settings_platform_app_provider .h" 5 #include "chrome/browser/content_settings/content_settings_internal_extension_pr ovider.h"
6 6
7 #include "chrome/browser/content_settings/content_settings_rule.h" 7 #include "chrome/browser/content_settings/content_settings_rule.h"
8 #include "chrome/browser/extensions/extension_host.h" 8 #include "chrome/browser/extensions/extension_host.h"
9 #include "chrome/browser/extensions/extension_service.h" 9 #include "chrome/browser/extensions/extension_service.h"
10 #include "chrome/common/chrome_notification_types.h" 10 #include "chrome/common/chrome_notification_types.h"
11 #include "chrome/common/content_settings.h" 11 #include "chrome/common/content_settings.h"
12 #include "chrome/common/content_settings_pattern.h" 12 #include "chrome/common/content_settings_pattern.h"
13 #include "chrome/common/extensions/extension.h" 13 #include "chrome/common/extensions/extension.h"
14 #include "chrome/common/extensions/extension_set.h" 14 #include "chrome/common/extensions/extension_set.h"
15 #include "chrome/common/url_constants.h" 15 #include "chrome/common/url_constants.h"
16 #include "content/public/browser/browser_thread.h" 16 #include "content/public/browser/browser_thread.h"
17 #include "content/public/browser/notification_details.h" 17 #include "content/public/browser/notification_details.h"
18 #include "content/public/browser/notification_service.h" 18 #include "content/public/browser/notification_service.h"
19 19
20 using extensions::UnloadedExtensionInfo; 20 using extensions::UnloadedExtensionInfo;
21 21
22 namespace content_settings { 22 namespace content_settings {
23 23
24 PlatformAppProvider::PlatformAppProvider(ExtensionService* extension_service) 24 InternalExtensionProvider::InternalExtensionProvider(
25 ExtensionService* extension_service)
25 : registrar_(new content::NotificationRegistrar) { 26 : registrar_(new content::NotificationRegistrar) {
26 // Whitelist all extensions loaded so far. 27 // Whitelist all extensions loaded so far.
27 const ExtensionSet* extensions = extension_service->extensions(); 28 const ExtensionSet* extensions = extension_service->extensions();
28 for (ExtensionSet::const_iterator it = extensions->begin(); 29 for (ExtensionSet::const_iterator it = extensions->begin();
29 it != extensions->end(); ++it) { 30 it != extensions->end(); ++it) {
30 if ((*it)->plugins().size() > 0) 31 if ((*it)->plugins().size() > 0)
31 SetContentSettingForExtension(*it, CONTENT_SETTING_ALLOW); 32 SetContentSettingForExtension(*it, CONTENT_SETTING_ALLOW);
32 } 33 }
33 Profile* profile = extension_service->profile(); 34 Profile* profile = extension_service->profile();
34 registrar_->Add(this, chrome::NOTIFICATION_EXTENSION_HOST_CREATED, 35 registrar_->Add(this, chrome::NOTIFICATION_EXTENSION_HOST_CREATED,
35 content::Source<Profile>(profile)); 36 content::Source<Profile>(profile));
36 registrar_->Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, 37 registrar_->Add(this, chrome::NOTIFICATION_EXTENSION_LOADED,
37 content::Source<Profile>(profile)); 38 content::Source<Profile>(profile));
38 registrar_->Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, 39 registrar_->Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
39 content::Source<Profile>(profile)); 40 content::Source<Profile>(profile));
40 } 41 }
41 42
42 PlatformAppProvider::~PlatformAppProvider() { 43 InternalExtensionProvider::~InternalExtensionProvider() {
43 DCHECK(!registrar_.get()); 44 DCHECK(!registrar_.get());
44 } 45 }
45 46
46 RuleIterator* PlatformAppProvider::GetRuleIterator( 47 RuleIterator* InternalExtensionProvider::GetRuleIterator(
47 ContentSettingsType content_type, 48 ContentSettingsType content_type,
48 const ResourceIdentifier& resource_identifier, 49 const ResourceIdentifier& resource_identifier,
49 bool incognito) const { 50 bool incognito) const {
50 return value_map_.GetRuleIterator(content_type, resource_identifier, &lock_); 51 return value_map_.GetRuleIterator(content_type, resource_identifier, &lock_);
51 } 52 }
52 53
53 bool PlatformAppProvider::SetWebsiteSetting( 54 bool InternalExtensionProvider::SetWebsiteSetting(
54 const ContentSettingsPattern& primary_pattern, 55 const ContentSettingsPattern& primary_pattern,
55 const ContentSettingsPattern& secondary_pattern, 56 const ContentSettingsPattern& secondary_pattern,
56 ContentSettingsType content_type, 57 ContentSettingsType content_type,
57 const ResourceIdentifier& resource_identifier, 58 const ResourceIdentifier& resource_identifier,
58 Value* value) { 59 Value* value) {
59 return false; 60 return false;
60 } 61 }
61 62
62 void PlatformAppProvider::ClearAllContentSettingsRules( 63 void InternalExtensionProvider::ClearAllContentSettingsRules(
63 ContentSettingsType content_type) {} 64 ContentSettingsType content_type) {}
64 65
65 void PlatformAppProvider::Observe(int type, 66 void InternalExtensionProvider::Observe(int type,
66 const content::NotificationSource& source, 67 const content::NotificationSource& source,
67 const content::NotificationDetails& details) { 68 const content::NotificationDetails& details) {
68 switch (type) { 69 switch (type) {
69 case chrome::NOTIFICATION_EXTENSION_HOST_CREATED: { 70 case chrome::NOTIFICATION_EXTENSION_HOST_CREATED: {
70 const extensions::ExtensionHost* host = 71 const extensions::ExtensionHost* host =
71 content::Details<extensions::ExtensionHost>(details).ptr(); 72 content::Details<extensions::ExtensionHost>(details).ptr();
72 if (host->extension()->is_platform_app()) 73 if (host->extension()->is_platform_app())
73 SetContentSettingForExtension(host->extension(), CONTENT_SETTING_BLOCK); 74 SetContentSettingForExtension(host->extension(), CONTENT_SETTING_BLOCK);
74 break; 75 break;
75 } 76 }
76 case chrome::NOTIFICATION_EXTENSION_LOADED: { 77 case chrome::NOTIFICATION_EXTENSION_LOADED: {
77 const extensions::Extension* extension = 78 const extensions::Extension* extension =
78 content::Details<extensions::Extension>(details).ptr(); 79 content::Details<extensions::Extension>(details).ptr();
79 if (extension->plugins().size() > 0) 80 if (extension->plugins().size() > 0)
80 SetContentSettingForExtension(extension, CONTENT_SETTING_ALLOW); 81 SetContentSettingForExtension(extension, CONTENT_SETTING_ALLOW);
81 break; 82 break;
82 } 83 }
83 case chrome::NOTIFICATION_EXTENSION_UNLOADED: { 84 case chrome::NOTIFICATION_EXTENSION_UNLOADED: {
84 const UnloadedExtensionInfo& info = 85 const UnloadedExtensionInfo& info =
85 *(content::Details<UnloadedExtensionInfo>(details).ptr()); 86 *(content::Details<UnloadedExtensionInfo>(details).ptr());
86 if (info.extension->plugins().size() > 0) 87 if (info.extension->plugins().size() > 0)
87 SetContentSettingForExtension(info.extension, CONTENT_SETTING_DEFAULT); 88 SetContentSettingForExtension(info.extension, CONTENT_SETTING_DEFAULT);
88 break; 89 break;
89 } 90 }
90 default: 91 default:
91 NOTREACHED(); 92 NOTREACHED();
92 } 93 }
93 } 94 }
94 95
95 void PlatformAppProvider::ShutdownOnUIThread() { 96 void InternalExtensionProvider::ShutdownOnUIThread() {
96 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 97 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
97 RemoveAllObservers(); 98 RemoveAllObservers();
98 registrar_.reset(); 99 registrar_.reset();
99 } 100 }
100 101
101 void PlatformAppProvider::SetContentSettingForExtension( 102 void InternalExtensionProvider::SetContentSettingForExtension(
102 const extensions::Extension* extension, 103 const extensions::Extension* extension,
103 ContentSetting setting) { 104 ContentSetting setting) {
104 scoped_ptr<ContentSettingsPattern::BuilderInterface> pattern_builder( 105 scoped_ptr<ContentSettingsPattern::BuilderInterface> pattern_builder(
105 ContentSettingsPattern::CreateBuilder(false)); 106 ContentSettingsPattern::CreateBuilder(false));
106 pattern_builder->WithScheme(chrome::kExtensionScheme); 107 pattern_builder->WithScheme(chrome::kExtensionScheme);
107 pattern_builder->WithHost(extension->id()); 108 pattern_builder->WithHost(extension->id());
108 pattern_builder->WithPathWildcard(); 109 pattern_builder->WithPathWildcard();
109 110
110 ContentSettingsPattern primary_pattern = pattern_builder->Build(); 111 ContentSettingsPattern primary_pattern = pattern_builder->Build();
111 ContentSettingsPattern secondary_pattern = ContentSettingsPattern::Wildcard(); 112 ContentSettingsPattern secondary_pattern = ContentSettingsPattern::Wildcard();
(...skipping 12 matching lines...) Expand all
124 Value::CreateIntegerValue(setting)); 125 Value::CreateIntegerValue(setting));
125 } 126 }
126 } 127 }
127 NotifyObservers(primary_pattern, 128 NotifyObservers(primary_pattern,
128 secondary_pattern, 129 secondary_pattern,
129 CONTENT_SETTINGS_TYPE_PLUGINS, 130 CONTENT_SETTINGS_TYPE_PLUGINS,
130 ResourceIdentifier("")); 131 ResourceIdentifier(""));
131 } 132 }
132 133
133 } // namespace content_settings 134 } // namespace content_settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698