OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/options/content_settings_handler.h" | 5 #include "chrome/browser/ui/webui/options/content_settings_handler.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "chrome/browser/notifications/desktop_notification_service_factory.h" | 22 #include "chrome/browser/notifications/desktop_notification_service_factory.h" |
23 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
24 #include "chrome/browser/ui/browser_list.h" | 24 #include "chrome/browser/ui/browser_list.h" |
25 #include "chrome/common/chrome_notification_types.h" | 25 #include "chrome/common/chrome_notification_types.h" |
26 #include "chrome/common/chrome_switches.h" | 26 #include "chrome/common/chrome_switches.h" |
27 #include "chrome/common/content_settings.h" | 27 #include "chrome/common/content_settings.h" |
28 #include "chrome/common/content_settings_pattern.h" | 28 #include "chrome/common/content_settings_pattern.h" |
29 #include "chrome/common/pref_names.h" | 29 #include "chrome/common/pref_names.h" |
30 #include "chrome/common/url_constants.h" | 30 #include "chrome/common/url_constants.h" |
31 #include "content/browser/tab_contents/tab_contents.h" | 31 #include "content/browser/tab_contents/tab_contents.h" |
| 32 #include "content/browser/user_metrics.h" |
32 #include "content/public/browser/notification_service.h" | 33 #include "content/public/browser/notification_service.h" |
33 #include "content/public/browser/notification_source.h" | 34 #include "content/public/browser/notification_source.h" |
34 #include "content/public/browser/notification_types.h" | 35 #include "content/public/browser/notification_types.h" |
35 #include "content/public/common/content_switches.h" | 36 #include "content/public/common/content_switches.h" |
36 #include "grit/generated_resources.h" | 37 #include "grit/generated_resources.h" |
37 #include "grit/locale_settings.h" | 38 #include "grit/locale_settings.h" |
38 #include "ui/base/l10n/l10n_util.h" | 39 #include "ui/base/l10n/l10n_util.h" |
39 | 40 |
40 namespace { | 41 namespace { |
41 | 42 |
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 ContentSetting default_setting = ContentSettingFromString(setting); | 682 ContentSetting default_setting = ContentSettingFromString(setting); |
682 ContentSettingsType content_type = ContentSettingsTypeFromGroupName(group); | 683 ContentSettingsType content_type = ContentSettingsTypeFromGroupName(group); |
683 if (content_type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) { | 684 if (content_type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) { |
684 Profile* profile = Profile::FromWebUI(web_ui_); | 685 Profile* profile = Profile::FromWebUI(web_ui_); |
685 DesktopNotificationServiceFactory::GetForProfile(profile)-> | 686 DesktopNotificationServiceFactory::GetForProfile(profile)-> |
686 SetDefaultContentSetting(default_setting); | 687 SetDefaultContentSetting(default_setting); |
687 } else { | 688 } else { |
688 GetContentSettingsMap()-> | 689 GetContentSettingsMap()-> |
689 SetDefaultContentSetting(content_type, default_setting); | 690 SetDefaultContentSetting(content_type, default_setting); |
690 } | 691 } |
| 692 switch (content_type) { |
| 693 case CONTENT_SETTINGS_TYPE_COOKIES: |
| 694 UserMetrics::RecordAction(UserMetricsAction( |
| 695 "ContentSetting_DefaultCookieSettingChanged")); |
| 696 break; |
| 697 case CONTENT_SETTINGS_TYPE_IMAGES: |
| 698 UserMetrics::RecordAction(UserMetricsAction( |
| 699 "ContentSetting_DefaultImagesSettingChanged")); |
| 700 break; |
| 701 case CONTENT_SETTINGS_TYPE_JAVASCRIPT: |
| 702 UserMetrics::RecordAction(UserMetricsAction( |
| 703 "ContentSetting_DefaultJavaScriptSettingChanged")); |
| 704 break; |
| 705 case CONTENT_SETTINGS_TYPE_PLUGINS: |
| 706 UserMetrics::RecordAction(UserMetricsAction( |
| 707 "ContentSetting_DefaultPluginsSettingChanged")); |
| 708 break; |
| 709 case CONTENT_SETTINGS_TYPE_POPUPS: |
| 710 UserMetrics::RecordAction(UserMetricsAction( |
| 711 "ContentSettings_DefaultPopupsSettingChanged")); |
| 712 break; |
| 713 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: |
| 714 UserMetrics::RecordAction(UserMetricsAction( |
| 715 "ContentSettings_DefaultNotificationsSettingChanged")); |
| 716 break; |
| 717 case CONTENT_SETTINGS_TYPE_GEOLOCATION: |
| 718 UserMetrics::RecordAction(UserMetricsAction( |
| 719 "ContentSetting_DefaultGeolocationSettingChanged")); |
| 720 break; |
| 721 case CONTENT_SETTINGS_TYPE_INTENTS: |
| 722 UserMetrics::RecordAction(UserMetricsAction( |
| 723 "ContentSetting_DefaultHandlersSettingChanged")); |
| 724 break; |
| 725 case CONTENT_SETTINGS_TYPE_MOUSELOCK: |
| 726 UserMetrics::RecordAction(UserMetricsAction( |
| 727 "ContentSettings_DefaultMouseLockSettingChanged")); |
| 728 break; |
| 729 default: |
| 730 break; |
| 731 } |
691 } | 732 } |
692 | 733 |
693 void ContentSettingsHandler::RemoveException(const ListValue* args) { | 734 void ContentSettingsHandler::RemoveException(const ListValue* args) { |
694 size_t arg_i = 0; | 735 size_t arg_i = 0; |
695 std::string type_string; | 736 std::string type_string; |
696 CHECK(args->GetString(arg_i++, &type_string)); | 737 CHECK(args->GetString(arg_i++, &type_string)); |
697 | 738 |
698 Profile* profile = Profile::FromWebUI(web_ui_); | 739 Profile* profile = Profile::FromWebUI(web_ui_); |
699 ContentSettingsType type = ContentSettingsTypeFromGroupName(type_string); | 740 ContentSettingsType type = ContentSettingsTypeFromGroupName(type_string); |
700 if (type == CONTENT_SETTINGS_TYPE_GEOLOCATION) { | 741 if (type == CONTENT_SETTINGS_TYPE_GEOLOCATION) { |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
827 return Profile::FromWebUI(web_ui_)->GetProtocolHandlerRegistry(); | 868 return Profile::FromWebUI(web_ui_)->GetProtocolHandlerRegistry(); |
828 } | 869 } |
829 | 870 |
830 HostContentSettingsMap* | 871 HostContentSettingsMap* |
831 ContentSettingsHandler::GetOTRContentSettingsMap() { | 872 ContentSettingsHandler::GetOTRContentSettingsMap() { |
832 Profile* profile = Profile::FromWebUI(web_ui_); | 873 Profile* profile = Profile::FromWebUI(web_ui_); |
833 if (profile->HasOffTheRecordProfile()) | 874 if (profile->HasOffTheRecordProfile()) |
834 return profile->GetOffTheRecordProfile()->GetHostContentSettingsMap(); | 875 return profile->GetOffTheRecordProfile()->GetHostContentSettingsMap(); |
835 return NULL; | 876 return NULL; |
836 } | 877 } |
OLD | NEW |