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 <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 22 matching lines...) Expand all Loading... |
33 #include "content/public/browser/notification_service.h" | 33 #include "content/public/browser/notification_service.h" |
34 #include "content/public/browser/notification_source.h" | 34 #include "content/public/browser/notification_source.h" |
35 #include "content/public/browser/notification_types.h" | 35 #include "content/public/browser/notification_types.h" |
36 #include "content/public/browser/user_metrics.h" | 36 #include "content/public/browser/user_metrics.h" |
37 #include "content/public/browser/web_ui.h" | 37 #include "content/public/browser/web_ui.h" |
38 #include "content/public/common/content_switches.h" | 38 #include "content/public/common/content_switches.h" |
39 #include "grit/generated_resources.h" | 39 #include "grit/generated_resources.h" |
40 #include "grit/locale_settings.h" | 40 #include "grit/locale_settings.h" |
41 #include "ui/base/l10n/l10n_util.h" | 41 #include "ui/base/l10n/l10n_util.h" |
42 | 42 |
| 43 #if defined(OS_CHROMEOS) |
| 44 #include "chrome/browser/chromeos/login/user_manager.h" |
| 45 #endif |
| 46 |
43 using content::UserMetricsAction; | 47 using content::UserMetricsAction; |
44 | 48 |
45 namespace { | 49 namespace { |
46 | 50 |
47 struct ContentSettingsTypeNameEntry { | 51 struct ContentSettingsTypeNameEntry { |
48 ContentSettingsType type; | 52 ContentSettingsType type; |
49 const char* name; | 53 const char* name; |
50 }; | 54 }; |
51 | 55 |
52 typedef std::map<ContentSettingsPattern, ContentSetting> OnePatternSettings; | 56 typedef std::map<ContentSettingsPattern, ContentSetting> OnePatternSettings; |
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
704 std::string group, setting; | 708 std::string group, setting; |
705 if (!(args->GetString(0, &group) && | 709 if (!(args->GetString(0, &group) && |
706 args->GetString(1, &setting))) { | 710 args->GetString(1, &setting))) { |
707 NOTREACHED(); | 711 NOTREACHED(); |
708 return; | 712 return; |
709 } | 713 } |
710 | 714 |
711 ContentSetting default_setting = ContentSettingFromString(setting); | 715 ContentSetting default_setting = ContentSettingFromString(setting); |
712 ContentSettingsType content_type = ContentSettingsTypeFromGroupName(group); | 716 ContentSettingsType content_type = ContentSettingsTypeFromGroupName(group); |
713 Profile* profile = Profile::FromWebUI(web_ui()); | 717 Profile* profile = Profile::FromWebUI(web_ui()); |
| 718 |
| 719 #if defined(OS_CHROMEOS) |
| 720 // ChromeOS special case : in Guest mode settings are opened in Incognito |
| 721 // mode, so we need original profile to actually modify settings. |
| 722 if (chromeos::UserManager::Get()->IsLoggedInAsGuest()) |
| 723 profile = profile->GetOriginalProfile(); |
| 724 #endif |
| 725 |
714 if (content_type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) { | 726 if (content_type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) { |
715 DesktopNotificationServiceFactory::GetForProfile(profile)-> | 727 DesktopNotificationServiceFactory::GetForProfile(profile)-> |
716 SetDefaultContentSetting(default_setting); | 728 SetDefaultContentSetting(default_setting); |
717 } else { | 729 } else { |
718 HostContentSettingsMap* map = GetContentSettingsMap(); | 730 HostContentSettingsMap* map = profile->GetHostContentSettingsMap(); |
719 ApplyWhitelist(content_type, default_setting); | 731 ApplyWhitelist(content_type, default_setting); |
720 map->SetDefaultContentSetting(content_type, default_setting); | 732 map->SetDefaultContentSetting(content_type, default_setting); |
721 } | 733 } |
722 switch (content_type) { | 734 switch (content_type) { |
723 case CONTENT_SETTINGS_TYPE_COOKIES: | 735 case CONTENT_SETTINGS_TYPE_COOKIES: |
724 content::RecordAction( | 736 content::RecordAction( |
725 UserMetricsAction("Options_DefaultCookieSettingChanged")); | 737 UserMetricsAction("Options_DefaultCookieSettingChanged")); |
726 break; | 738 break; |
727 case CONTENT_SETTINGS_TYPE_IMAGES: | 739 case CONTENT_SETTINGS_TYPE_IMAGES: |
728 content::RecordAction( | 740 content::RecordAction( |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
900 | 912 |
901 HostContentSettingsMap* | 913 HostContentSettingsMap* |
902 ContentSettingsHandler::GetOTRContentSettingsMap() { | 914 ContentSettingsHandler::GetOTRContentSettingsMap() { |
903 Profile* profile = Profile::FromWebUI(web_ui()); | 915 Profile* profile = Profile::FromWebUI(web_ui()); |
904 if (profile->HasOffTheRecordProfile()) | 916 if (profile->HasOffTheRecordProfile()) |
905 return profile->GetOffTheRecordProfile()->GetHostContentSettingsMap(); | 917 return profile->GetOffTheRecordProfile()->GetHostContentSettingsMap(); |
906 return NULL; | 918 return NULL; |
907 } | 919 } |
908 | 920 |
909 } // namespace options2 | 921 } // namespace options2 |
OLD | NEW |