| 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" | |
| 33 #include "content/public/browser/notification_service.h" | 32 #include "content/public/browser/notification_service.h" |
| 34 #include "content/public/browser/notification_source.h" | 33 #include "content/public/browser/notification_source.h" |
| 35 #include "content/public/browser/notification_types.h" | 34 #include "content/public/browser/notification_types.h" |
| 35 #include "content/public/browser/user_metrics.h" |
| 36 #include "content/public/common/content_switches.h" | 36 #include "content/public/common/content_switches.h" |
| 37 #include "grit/generated_resources.h" | 37 #include "grit/generated_resources.h" |
| 38 #include "grit/locale_settings.h" | 38 #include "grit/locale_settings.h" |
| 39 #include "ui/base/l10n/l10n_util.h" | 39 #include "ui/base/l10n/l10n_util.h" |
| 40 | 40 |
| 41 using content::UserMetricsAction; |
| 42 |
| 41 namespace { | 43 namespace { |
| 42 | 44 |
| 43 struct ContentSettingsTypeNameEntry { | 45 struct ContentSettingsTypeNameEntry { |
| 44 ContentSettingsType type; | 46 ContentSettingsType type; |
| 45 const char* name; | 47 const char* name; |
| 46 }; | 48 }; |
| 47 | 49 |
| 48 typedef std::map<ContentSettingsPattern, ContentSetting> OnePatternSettings; | 50 typedef std::map<ContentSettingsPattern, ContentSetting> OnePatternSettings; |
| 49 typedef std::map<ContentSettingsPattern, OnePatternSettings> | 51 typedef std::map<ContentSettingsPattern, OnePatternSettings> |
| 50 AllPatternsSettings; | 52 AllPatternsSettings; |
| (...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 684 if (content_type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) { | 686 if (content_type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) { |
| 685 Profile* profile = Profile::FromWebUI(web_ui_); | 687 Profile* profile = Profile::FromWebUI(web_ui_); |
| 686 DesktopNotificationServiceFactory::GetForProfile(profile)-> | 688 DesktopNotificationServiceFactory::GetForProfile(profile)-> |
| 687 SetDefaultContentSetting(default_setting); | 689 SetDefaultContentSetting(default_setting); |
| 688 } else { | 690 } else { |
| 689 GetContentSettingsMap()-> | 691 GetContentSettingsMap()-> |
| 690 SetDefaultContentSetting(content_type, default_setting); | 692 SetDefaultContentSetting(content_type, default_setting); |
| 691 } | 693 } |
| 692 switch (content_type) { | 694 switch (content_type) { |
| 693 case CONTENT_SETTINGS_TYPE_COOKIES: | 695 case CONTENT_SETTINGS_TYPE_COOKIES: |
| 694 UserMetrics::RecordAction( | 696 content::RecordAction( |
| 695 UserMetricsAction("Options_DefaultCookieSettingChanged")); | 697 UserMetricsAction("Options_DefaultCookieSettingChanged")); |
| 696 break; | 698 break; |
| 697 case CONTENT_SETTINGS_TYPE_IMAGES: | 699 case CONTENT_SETTINGS_TYPE_IMAGES: |
| 698 UserMetrics::RecordAction( | 700 content::RecordAction( |
| 699 UserMetricsAction("Options_DefaultImagesSettingChanged")); | 701 UserMetricsAction("Options_DefaultImagesSettingChanged")); |
| 700 break; | 702 break; |
| 701 case CONTENT_SETTINGS_TYPE_JAVASCRIPT: | 703 case CONTENT_SETTINGS_TYPE_JAVASCRIPT: |
| 702 UserMetrics::RecordAction( | 704 content::RecordAction( |
| 703 UserMetricsAction("Options_DefaultJavaScriptSettingChanged")); | 705 UserMetricsAction("Options_DefaultJavaScriptSettingChanged")); |
| 704 break; | 706 break; |
| 705 case CONTENT_SETTINGS_TYPE_PLUGINS: | 707 case CONTENT_SETTINGS_TYPE_PLUGINS: |
| 706 UserMetrics::RecordAction( | 708 content::RecordAction( |
| 707 UserMetricsAction("Options_DefaultPluginsSettingChanged")); | 709 UserMetricsAction("Options_DefaultPluginsSettingChanged")); |
| 708 break; | 710 break; |
| 709 case CONTENT_SETTINGS_TYPE_POPUPS: | 711 case CONTENT_SETTINGS_TYPE_POPUPS: |
| 710 UserMetrics::RecordAction( | 712 content::RecordAction( |
| 711 UserMetricsAction("Options_DefaultPopupsSettingChanged")); | 713 UserMetricsAction("Options_DefaultPopupsSettingChanged")); |
| 712 break; | 714 break; |
| 713 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: | 715 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: |
| 714 UserMetrics::RecordAction( | 716 content::RecordAction( |
| 715 UserMetricsAction("Options_DefaultNotificationsSettingChanged")); | 717 UserMetricsAction("Options_DefaultNotificationsSettingChanged")); |
| 716 break; | 718 break; |
| 717 case CONTENT_SETTINGS_TYPE_GEOLOCATION: | 719 case CONTENT_SETTINGS_TYPE_GEOLOCATION: |
| 718 UserMetrics::RecordAction( | 720 content::RecordAction( |
| 719 UserMetricsAction("Options_DefaultGeolocationSettingChanged")); | 721 UserMetricsAction("Options_DefaultGeolocationSettingChanged")); |
| 720 break; | 722 break; |
| 721 case CONTENT_SETTINGS_TYPE_INTENTS: | 723 case CONTENT_SETTINGS_TYPE_INTENTS: |
| 722 UserMetrics::RecordAction( | 724 content::RecordAction( |
| 723 UserMetricsAction("Options_DefaultHandlersSettingChanged")); | 725 UserMetricsAction("Options_DefaultHandlersSettingChanged")); |
| 724 break; | 726 break; |
| 725 case CONTENT_SETTINGS_TYPE_MOUSELOCK: | 727 case CONTENT_SETTINGS_TYPE_MOUSELOCK: |
| 726 UserMetrics::RecordAction( | 728 content::RecordAction( |
| 727 UserMetricsAction("Options_DefaultMouseLockSettingChanged")); | 729 UserMetricsAction("Options_DefaultMouseLockSettingChanged")); |
| 728 break; | 730 break; |
| 729 default: | 731 default: |
| 730 break; | 732 break; |
| 731 } | 733 } |
| 732 } | 734 } |
| 733 | 735 |
| 734 void ContentSettingsHandler::RemoveException(const ListValue* args) { | 736 void ContentSettingsHandler::RemoveException(const ListValue* args) { |
| 735 size_t arg_i = 0; | 737 size_t arg_i = 0; |
| 736 std::string type_string; | 738 std::string type_string; |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 868 return Profile::FromWebUI(web_ui_)->GetProtocolHandlerRegistry(); | 870 return Profile::FromWebUI(web_ui_)->GetProtocolHandlerRegistry(); |
| 869 } | 871 } |
| 870 | 872 |
| 871 HostContentSettingsMap* | 873 HostContentSettingsMap* |
| 872 ContentSettingsHandler::GetOTRContentSettingsMap() { | 874 ContentSettingsHandler::GetOTRContentSettingsMap() { |
| 873 Profile* profile = Profile::FromWebUI(web_ui_); | 875 Profile* profile = Profile::FromWebUI(web_ui_); |
| 874 if (profile->HasOffTheRecordProfile()) | 876 if (profile->HasOffTheRecordProfile()) |
| 875 return profile->GetOffTheRecordProfile()->GetHostContentSettingsMap(); | 877 return profile->GetOffTheRecordProfile()->GetHostContentSettingsMap(); |
| 876 return NULL; | 878 return NULL; |
| 877 } | 879 } |
| OLD | NEW |