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 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
701 std::string group, setting; | 705 std::string group, setting; |
702 if (!(args->GetString(0, &group) && | 706 if (!(args->GetString(0, &group) && |
703 args->GetString(1, &setting))) { | 707 args->GetString(1, &setting))) { |
704 NOTREACHED(); | 708 NOTREACHED(); |
705 return; | 709 return; |
706 } | 710 } |
707 | 711 |
708 ContentSetting default_setting = ContentSettingFromString(setting); | 712 ContentSetting default_setting = ContentSettingFromString(setting); |
709 ContentSettingsType content_type = ContentSettingsTypeFromGroupName(group); | 713 ContentSettingsType content_type = ContentSettingsTypeFromGroupName(group); |
710 Profile* profile = Profile::FromWebUI(web_ui()); | 714 Profile* profile = Profile::FromWebUI(web_ui()); |
715 | |
716 #if defined(OS_CHROMEOS) | |
717 // ChromeOS special case : in Guest mode settings are opened in Incognito | |
718 // mode, so we need original profile to actually modify settings. | |
719 if (chromeos::UserManager::Get()->IsLoggedInAsGuest()) { | |
James Hawkins
2012/02/29 15:15:09
Optional nit: no braces for single-line blocks.
Denis Kuznetsov (DE-MUC)
2012/02/29 15:55:43
Done.
| |
720 profile = profile->GetOriginalProfile(); | |
721 } | |
722 #endif | |
723 | |
711 if (content_type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) { | 724 if (content_type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) { |
712 DesktopNotificationServiceFactory::GetForProfile(profile)-> | 725 DesktopNotificationServiceFactory::GetForProfile(profile)-> |
713 SetDefaultContentSetting(default_setting); | 726 SetDefaultContentSetting(default_setting); |
714 } else { | 727 } else { |
715 HostContentSettingsMap* map = GetContentSettingsMap(); | 728 HostContentSettingsMap* map = profile->GetHostContentSettingsMap(); |
716 map->SetDefaultContentSetting(content_type, default_setting); | 729 map->SetDefaultContentSetting(content_type, default_setting); |
717 ApplyWhitelist(content_type, default_setting); | 730 ApplyWhitelist(content_type, default_setting); |
718 } | 731 } |
719 switch (content_type) { | 732 switch (content_type) { |
720 case CONTENT_SETTINGS_TYPE_COOKIES: | 733 case CONTENT_SETTINGS_TYPE_COOKIES: |
721 content::RecordAction( | 734 content::RecordAction( |
722 UserMetricsAction("Options_DefaultCookieSettingChanged")); | 735 UserMetricsAction("Options_DefaultCookieSettingChanged")); |
723 break; | 736 break; |
724 case CONTENT_SETTINGS_TYPE_IMAGES: | 737 case CONTENT_SETTINGS_TYPE_IMAGES: |
725 content::RecordAction( | 738 content::RecordAction( |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
897 | 910 |
898 HostContentSettingsMap* | 911 HostContentSettingsMap* |
899 ContentSettingsHandler::GetOTRContentSettingsMap() { | 912 ContentSettingsHandler::GetOTRContentSettingsMap() { |
900 Profile* profile = Profile::FromWebUI(web_ui()); | 913 Profile* profile = Profile::FromWebUI(web_ui()); |
901 if (profile->HasOffTheRecordProfile()) | 914 if (profile->HasOffTheRecordProfile()) |
902 return profile->GetOffTheRecordProfile()->GetHostContentSettingsMap(); | 915 return profile->GetOffTheRecordProfile()->GetHostContentSettingsMap(); |
903 return NULL; | 916 return NULL; |
904 } | 917 } |
905 | 918 |
906 } // namespace options2 | 919 } // namespace options2 |
OLD | NEW |