OLD | NEW |
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/webui/options2/content_settings_handler2.h" | 5 #include "chrome/browser/ui/webui/options2/content_settings_handler2.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "chrome/browser/intents/web_intents_util.h" | 21 #include "chrome/browser/intents/web_intents_util.h" |
22 #include "chrome/browser/notifications/desktop_notification_service.h" | 22 #include "chrome/browser/notifications/desktop_notification_service.h" |
23 #include "chrome/browser/notifications/desktop_notification_service_factory.h" | 23 #include "chrome/browser/notifications/desktop_notification_service_factory.h" |
24 #include "chrome/browser/prefs/pref_service.h" | 24 #include "chrome/browser/prefs/pref_service.h" |
25 #include "chrome/browser/profiles/profile.h" | 25 #include "chrome/browser/profiles/profile.h" |
26 #include "chrome/browser/ui/browser_list.h" | 26 #include "chrome/browser/ui/browser_list.h" |
27 #include "chrome/common/chrome_notification_types.h" | 27 #include "chrome/common/chrome_notification_types.h" |
28 #include "chrome/common/chrome_switches.h" | 28 #include "chrome/common/chrome_switches.h" |
29 #include "chrome/common/content_settings.h" | 29 #include "chrome/common/content_settings.h" |
30 #include "chrome/common/content_settings_pattern.h" | 30 #include "chrome/common/content_settings_pattern.h" |
31 #include "chrome/common/extensions/extension_permission_set.h" | 31 #include "chrome/common/extensions/permissions/api_permission.h" |
32 #include "chrome/common/extensions/extension_set.h" | 32 #include "chrome/common/extensions/extension_set.h" |
33 #include "chrome/common/pref_names.h" | 33 #include "chrome/common/pref_names.h" |
34 #include "chrome/common/url_constants.h" | 34 #include "chrome/common/url_constants.h" |
35 #include "content/public/browser/notification_service.h" | 35 #include "content/public/browser/notification_service.h" |
36 #include "content/public/browser/notification_source.h" | 36 #include "content/public/browser/notification_source.h" |
37 #include "content/public/browser/notification_types.h" | 37 #include "content/public/browser/notification_types.h" |
38 #include "content/public/browser/user_metrics.h" | 38 #include "content/public/browser/user_metrics.h" |
39 #include "content/public/browser/web_ui.h" | 39 #include "content/public/browser/web_ui.h" |
40 #include "content/public/common/content_switches.h" | 40 #include "content/public/common/content_switches.h" |
41 #include "grit/generated_resources.h" | 41 #include "grit/generated_resources.h" |
42 #include "grit/locale_settings.h" | 42 #include "grit/locale_settings.h" |
43 #include "net/base/net_util.h" | 43 #include "net/base/net_util.h" |
44 #include "ui/base/l10n/l10n_util.h" | 44 #include "ui/base/l10n/l10n_util.h" |
45 | 45 |
46 #if defined(OS_CHROMEOS) | 46 #if defined(OS_CHROMEOS) |
47 #include "chrome/browser/chromeos/login/user_manager.h" | 47 #include "chrome/browser/chromeos/login/user_manager.h" |
48 #endif | 48 #endif |
49 | 49 |
50 using content::UserMetricsAction; | 50 using content::UserMetricsAction; |
| 51 using extensions::APIPermission; |
51 | 52 |
52 namespace { | 53 namespace { |
53 | 54 |
54 enum ExContentSettingsTypeEnum { | 55 enum ExContentSettingsTypeEnum { |
55 EX_CONTENT_SETTINGS_TYPE_PEPPER_FLASH_CAMERAMIC = | 56 EX_CONTENT_SETTINGS_TYPE_PEPPER_FLASH_CAMERAMIC = |
56 CONTENT_SETTINGS_NUM_TYPES, | 57 CONTENT_SETTINGS_NUM_TYPES, |
57 EX_CONTENT_SETTINGS_NUM_TYPES | 58 EX_CONTENT_SETTINGS_NUM_TYPES |
58 }; | 59 }; |
59 | 60 |
60 typedef std::map<ContentSettingsPattern, ContentSetting> OnePatternSettings; | 61 typedef std::map<ContentSettingsPattern, ContentSetting> OnePatternSettings; |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 // under the current |profile|. | 182 // under the current |profile|. |
182 // Must have the AppFilter signature. | 183 // Must have the AppFilter signature. |
183 bool HasProtectedStorage(const extensions::Extension& app, Profile* profile) { | 184 bool HasProtectedStorage(const extensions::Extension& app, Profile* profile) { |
184 ExtensionSpecialStoragePolicy* policy = | 185 ExtensionSpecialStoragePolicy* policy = |
185 profile->GetExtensionSpecialStoragePolicy(); | 186 profile->GetExtensionSpecialStoragePolicy(); |
186 return policy->NeedsProtection(&app); | 187 return policy->NeedsProtection(&app); |
187 } | 188 } |
188 | 189 |
189 // Returns true whenever the |extension| is hosted and has |permission|. | 190 // Returns true whenever the |extension| is hosted and has |permission|. |
190 // Must have the AppFilter signature. | 191 // Must have the AppFilter signature. |
191 template <ExtensionAPIPermission::ID permission> | 192 template <APIPermission::ID permission> |
192 bool HostedAppHasPermission( | 193 bool HostedAppHasPermission( |
193 const extensions::Extension& extension, Profile* /*profile*/) { | 194 const extensions::Extension& extension, Profile* /*profile*/) { |
194 return extension.is_hosted_app() && extension.HasAPIPermission(permission); | 195 return extension.is_hosted_app() && extension.HasAPIPermission(permission); |
195 } | 196 } |
196 | 197 |
197 // Add an "Allow"-entry to the list of |exceptions| for a |url_pattern| from | 198 // Add an "Allow"-entry to the list of |exceptions| for a |url_pattern| from |
198 // the web extent of a hosted |app|. | 199 // the web extent of a hosted |app|. |
199 void AddExceptionForHostedApp(const std::string& url_pattern, | 200 void AddExceptionForHostedApp(const std::string& url_pattern, |
200 const extensions::Extension& app, ListValue* exceptions) { | 201 const extensions::Extension& app, ListValue* exceptions) { |
201 DictionaryValue* exception = new DictionaryValue(); | 202 DictionaryValue* exception = new DictionaryValue(); |
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
736 i->source != kPreferencesSource) { | 737 i->source != kPreferencesSource) { |
737 continue; | 738 continue; |
738 } | 739 } |
739 all_patterns_settings[i->primary_pattern][i->secondary_pattern] = | 740 all_patterns_settings[i->primary_pattern][i->secondary_pattern] = |
740 i->setting; | 741 i->setting; |
741 } | 742 } |
742 | 743 |
743 ListValue exceptions; | 744 ListValue exceptions; |
744 AddExceptionsGrantedByHostedApps( | 745 AddExceptionsGrantedByHostedApps( |
745 profile, | 746 profile, |
746 HostedAppHasPermission<ExtensionAPIPermission::kGeolocation>, | 747 HostedAppHasPermission<APIPermission::kGeolocation>, |
747 &exceptions); | 748 &exceptions); |
748 | 749 |
749 for (AllPatternsSettings::iterator i = all_patterns_settings.begin(); | 750 for (AllPatternsSettings::iterator i = all_patterns_settings.begin(); |
750 i != all_patterns_settings.end(); | 751 i != all_patterns_settings.end(); |
751 ++i) { | 752 ++i) { |
752 const ContentSettingsPattern& primary_pattern = i->first; | 753 const ContentSettingsPattern& primary_pattern = i->first; |
753 const OnePatternSettings& one_settings = i->second; | 754 const OnePatternSettings& one_settings = i->second; |
754 | 755 |
755 OnePatternSettings::const_iterator parent = | 756 OnePatternSettings::const_iterator parent = |
756 one_settings.find(primary_pattern); | 757 one_settings.find(primary_pattern); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
789 void ContentSettingsHandler::UpdateNotificationExceptionsView() { | 790 void ContentSettingsHandler::UpdateNotificationExceptionsView() { |
790 Profile* profile = Profile::FromWebUI(web_ui()); | 791 Profile* profile = Profile::FromWebUI(web_ui()); |
791 DesktopNotificationService* service = | 792 DesktopNotificationService* service = |
792 DesktopNotificationServiceFactory::GetForProfile(profile); | 793 DesktopNotificationServiceFactory::GetForProfile(profile); |
793 | 794 |
794 ContentSettingsForOneType settings; | 795 ContentSettingsForOneType settings; |
795 service->GetNotificationsSettings(&settings); | 796 service->GetNotificationsSettings(&settings); |
796 | 797 |
797 ListValue exceptions; | 798 ListValue exceptions; |
798 AddExceptionsGrantedByHostedApps(profile, | 799 AddExceptionsGrantedByHostedApps(profile, |
799 HostedAppHasPermission<ExtensionAPIPermission::kNotification>, | 800 HostedAppHasPermission<APIPermission::kNotification>, |
800 &exceptions); | 801 &exceptions); |
801 | 802 |
802 for (ContentSettingsForOneType::const_iterator i = | 803 for (ContentSettingsForOneType::const_iterator i = |
803 settings.begin(); | 804 settings.begin(); |
804 i != settings.end(); | 805 i != settings.end(); |
805 ++i) { | 806 ++i) { |
806 // Don't add default settings. | 807 // Don't add default settings. |
807 if (i->primary_pattern == ContentSettingsPattern::Wildcard() && | 808 if (i->primary_pattern == ContentSettingsPattern::Wildcard() && |
808 i->secondary_pattern == ContentSettingsPattern::Wildcard() && | 809 i->secondary_pattern == ContentSettingsPattern::Wildcard() && |
809 i->source != kPreferencesSource) { | 810 i->source != kPreferencesSource) { |
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1327 for (size_t i = 0; i < arraysize(kExContentSettingsTypeGroupNames); ++i) { | 1328 for (size_t i = 0; i < arraysize(kExContentSettingsTypeGroupNames); ++i) { |
1328 if (type == kExContentSettingsTypeGroupNames[i].type) | 1329 if (type == kExContentSettingsTypeGroupNames[i].type) |
1329 return kExContentSettingsTypeGroupNames[i].name; | 1330 return kExContentSettingsTypeGroupNames[i].name; |
1330 } | 1331 } |
1331 | 1332 |
1332 NOTREACHED(); | 1333 NOTREACHED(); |
1333 return std::string(); | 1334 return std::string(); |
1334 } | 1335 } |
1335 | 1336 |
1336 } // namespace options2 | 1337 } // namespace options2 |
OLD | NEW |