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

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

Issue 10375021: Move Extension into extensions namespace (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Take 6 Created 8 years, 7 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
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_platform_app_provider .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/url_constants.h" 14 #include "chrome/common/url_constants.h"
15 #include "content/public/browser/browser_thread.h" 15 #include "content/public/browser/browser_thread.h"
16 #include "content/public/browser/notification_details.h" 16 #include "content/public/browser/notification_details.h"
17 #include "content/public/browser/notification_service.h" 17 #include "content/public/browser/notification_service.h"
18 18
19 using extensions::UnloadedExtensionInfo;
20
19 namespace content_settings { 21 namespace content_settings {
20 22
21 PlatformAppProvider::PlatformAppProvider(ExtensionService* extension_service) 23 PlatformAppProvider::PlatformAppProvider(ExtensionService* extension_service)
22 : registrar_(new content::NotificationRegistrar) { 24 : registrar_(new content::NotificationRegistrar) {
23 Profile* profile = extension_service->profile(); 25 Profile* profile = extension_service->profile();
24 registrar_->Add(this, chrome::NOTIFICATION_EXTENSION_HOST_CREATED, 26 registrar_->Add(this, chrome::NOTIFICATION_EXTENSION_HOST_CREATED,
25 content::Source<Profile>(profile)); 27 content::Source<Profile>(profile));
26 registrar_->Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, 28 registrar_->Add(this, chrome::NOTIFICATION_EXTENSION_LOADED,
27 content::Source<Profile>(profile)); 29 content::Source<Profile>(profile));
28 registrar_->Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, 30 registrar_->Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
(...skipping 28 matching lines...) Expand all
57 const content::NotificationDetails& details) { 59 const content::NotificationDetails& details) {
58 switch (type) { 60 switch (type) {
59 case chrome::NOTIFICATION_EXTENSION_HOST_CREATED: { 61 case chrome::NOTIFICATION_EXTENSION_HOST_CREATED: {
60 const ExtensionHost* host = 62 const ExtensionHost* host =
61 content::Details<ExtensionHost>(details).ptr(); 63 content::Details<ExtensionHost>(details).ptr();
62 if (host->extension()->is_platform_app()) 64 if (host->extension()->is_platform_app())
63 SetContentSettingForExtension(host->extension(), CONTENT_SETTING_BLOCK); 65 SetContentSettingForExtension(host->extension(), CONTENT_SETTING_BLOCK);
64 break; 66 break;
65 } 67 }
66 case chrome::NOTIFICATION_EXTENSION_LOADED: { 68 case chrome::NOTIFICATION_EXTENSION_LOADED: {
67 const Extension* extension = content::Details<Extension>(details).ptr(); 69 const extensions::Extension* extension =
70 content::Details<extensions::Extension>(details).ptr();
68 if (extension->plugins().size() > 0) 71 if (extension->plugins().size() > 0)
69 SetContentSettingForExtension(extension, CONTENT_SETTING_ALLOW); 72 SetContentSettingForExtension(extension, CONTENT_SETTING_ALLOW);
70 break; 73 break;
71 } 74 }
72 case chrome::NOTIFICATION_EXTENSION_UNLOADED: { 75 case chrome::NOTIFICATION_EXTENSION_UNLOADED: {
73 const UnloadedExtensionInfo& info = 76 const UnloadedExtensionInfo& info =
74 *(content::Details<UnloadedExtensionInfo>(details).ptr()); 77 *(content::Details<UnloadedExtensionInfo>(details).ptr());
75 if (info.extension->plugins().size() > 0) 78 if (info.extension->plugins().size() > 0)
76 SetContentSettingForExtension(info.extension, CONTENT_SETTING_DEFAULT); 79 SetContentSettingForExtension(info.extension, CONTENT_SETTING_DEFAULT);
77 break; 80 break;
78 } 81 }
79 default: 82 default:
80 NOTREACHED(); 83 NOTREACHED();
81 } 84 }
82 } 85 }
83 86
84 void PlatformAppProvider::ShutdownOnUIThread() { 87 void PlatformAppProvider::ShutdownOnUIThread() {
85 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 88 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
86 RemoveAllObservers(); 89 RemoveAllObservers();
87 registrar_.reset(); 90 registrar_.reset();
88 } 91 }
89 92
90 void PlatformAppProvider::SetContentSettingForExtension( 93 void PlatformAppProvider::SetContentSettingForExtension(
91 const Extension* extension, 94 const extensions::Extension* extension,
92 ContentSetting setting) { 95 ContentSetting setting) {
93 scoped_ptr<ContentSettingsPattern::BuilderInterface> pattern_builder( 96 scoped_ptr<ContentSettingsPattern::BuilderInterface> pattern_builder(
94 ContentSettingsPattern::CreateBuilder(false)); 97 ContentSettingsPattern::CreateBuilder(false));
95 pattern_builder->WithScheme(chrome::kExtensionScheme); 98 pattern_builder->WithScheme(chrome::kExtensionScheme);
96 pattern_builder->WithHost(extension->id()); 99 pattern_builder->WithHost(extension->id());
97 pattern_builder->WithPathWildcard(); 100 pattern_builder->WithPathWildcard();
98 101
99 ContentSettingsPattern primary_pattern = pattern_builder->Build(); 102 ContentSettingsPattern primary_pattern = pattern_builder->Build();
100 ContentSettingsPattern secondary_pattern = ContentSettingsPattern::Wildcard(); 103 ContentSettingsPattern secondary_pattern = ContentSettingsPattern::Wildcard();
101 { 104 {
(...skipping 11 matching lines...) Expand all
113 Value::CreateIntegerValue(setting)); 116 Value::CreateIntegerValue(setting));
114 } 117 }
115 } 118 }
116 NotifyObservers(primary_pattern, 119 NotifyObservers(primary_pattern,
117 secondary_pattern, 120 secondary_pattern,
118 CONTENT_SETTINGS_TYPE_PLUGINS, 121 CONTENT_SETTINGS_TYPE_PLUGINS,
119 ResourceIdentifier("")); 122 ResourceIdentifier(""));
120 } 123 }
121 124
122 } // namespace content_settings 125 } // namespace content_settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698