Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(827)

Side by Side Diff: chrome/browser/ui/webui/options2/content_settings_handler2.cc

Issue 9537014: Merge a bunch of CLs to whitelist the Google Talk plug-in when turning on click-to-play. (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1025/src
Patch Set: sync Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/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
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/bind_helpers.h" 12 #include "base/bind_helpers.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/utf_string_conversions.h" 14 #include "base/utf_string_conversions.h"
15 #include "base/values.h" 15 #include "base/values.h"
16 #include "chrome/browser/browser_process.h" 16 #include "chrome/browser/browser_process.h"
17 #include "chrome/browser/content_settings/content_settings_details.h" 17 #include "chrome/browser/content_settings/content_settings_details.h"
18 #include "chrome/browser/content_settings/content_settings_utils.h" 18 #include "chrome/browser/content_settings/content_settings_utils.h"
19 #include "chrome/browser/content_settings/host_content_settings_map.h" 19 #include "chrome/browser/content_settings/host_content_settings_map.h"
20 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" 20 #include "chrome/browser/custom_handlers/protocol_handler_registry.h"
21 #include "chrome/browser/notifications/desktop_notification_service.h" 21 #include "chrome/browser/notifications/desktop_notification_service.h"
22 #include "chrome/browser/notifications/desktop_notification_service_factory.h" 22 #include "chrome/browser/notifications/desktop_notification_service_factory.h"
23 #include "chrome/browser/prefs/pref_service.h"
23 #include "chrome/browser/profiles/profile.h" 24 #include "chrome/browser/profiles/profile.h"
24 #include "chrome/browser/ui/browser_list.h" 25 #include "chrome/browser/ui/browser_list.h"
25 #include "chrome/common/chrome_notification_types.h" 26 #include "chrome/common/chrome_notification_types.h"
26 #include "chrome/common/chrome_switches.h" 27 #include "chrome/common/chrome_switches.h"
27 #include "chrome/common/content_settings.h" 28 #include "chrome/common/content_settings.h"
28 #include "chrome/common/content_settings_pattern.h" 29 #include "chrome/common/content_settings_pattern.h"
29 #include "chrome/common/pref_names.h" 30 #include "chrome/common/pref_names.h"
30 #include "chrome/common/url_constants.h" 31 #include "chrome/common/url_constants.h"
31 #include "content/public/browser/notification_service.h" 32 #include "content/public/browser/notification_service.h"
32 #include "content/public/browser/notification_source.h" 33 #include "content/public/browser/notification_source.h"
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 base::Bind(&ContentSettingsHandler::RemoveException, 665 base::Bind(&ContentSettingsHandler::RemoveException,
665 base::Unretained(this))); 666 base::Unretained(this)));
666 web_ui()->RegisterMessageCallback("setException", 667 web_ui()->RegisterMessageCallback("setException",
667 base::Bind(&ContentSettingsHandler::SetException, 668 base::Bind(&ContentSettingsHandler::SetException,
668 base::Unretained(this))); 669 base::Unretained(this)));
669 web_ui()->RegisterMessageCallback("checkExceptionPatternValidity", 670 web_ui()->RegisterMessageCallback("checkExceptionPatternValidity",
670 base::Bind(&ContentSettingsHandler::CheckExceptionPatternValidity, 671 base::Bind(&ContentSettingsHandler::CheckExceptionPatternValidity,
671 base::Unretained(this))); 672 base::Unretained(this)));
672 } 673 }
673 674
675 void ContentSettingsHandler::ApplyWhitelist(ContentSettingsType content_type,
676 ContentSetting default_setting) {
677 Profile* profile = Profile::FromWebUI(web_ui());
678 HostContentSettingsMap* map = GetContentSettingsMap();
679 if (content_type != CONTENT_SETTINGS_TYPE_PLUGINS)
680 return;
681 const int kDefaultWhitelistVersion = 1;
682 PrefService* prefs = profile->GetPrefs();
683 int version = prefs->GetInteger(
684 prefs::kContentSettingsDefaultWhitelistVersion);
685 if (version >= kDefaultWhitelistVersion)
686 return;
687 ContentSetting old_setting =
688 map->GetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS, NULL);
689 if (old_setting == CONTENT_SETTING_ALLOW &&
690 default_setting == CONTENT_SETTING_ASK) {
691 map->SetWebsiteSetting(
692 ContentSettingsPattern::Wildcard(),
693 ContentSettingsPattern::Wildcard(),
694 CONTENT_SETTINGS_TYPE_PLUGINS,
695 "google-talk",
696 Value::CreateIntegerValue(CONTENT_SETTING_ALLOW));
697 }
698 prefs->SetInteger(prefs::kContentSettingsDefaultWhitelistVersion,
699 kDefaultWhitelistVersion);
700 }
701
674 void ContentSettingsHandler::SetContentFilter(const ListValue* args) { 702 void ContentSettingsHandler::SetContentFilter(const ListValue* args) {
675 DCHECK_EQ(2U, args->GetSize()); 703 DCHECK_EQ(2U, args->GetSize());
676 std::string group, setting; 704 std::string group, setting;
677 if (!(args->GetString(0, &group) && 705 if (!(args->GetString(0, &group) &&
678 args->GetString(1, &setting))) { 706 args->GetString(1, &setting))) {
679 NOTREACHED(); 707 NOTREACHED();
680 return; 708 return;
681 } 709 }
682 710
683 ContentSetting default_setting = ContentSettingFromString(setting); 711 ContentSetting default_setting = ContentSettingFromString(setting);
684 ContentSettingsType content_type = ContentSettingsTypeFromGroupName(group); 712 ContentSettingsType content_type = ContentSettingsTypeFromGroupName(group);
685 if (content_type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) { 713 if (content_type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) {
686 Profile* profile = Profile::FromWebUI(web_ui()); 714 Profile* profile = Profile::FromWebUI(web_ui());
687 DesktopNotificationServiceFactory::GetForProfile(profile)-> 715 DesktopNotificationServiceFactory::GetForProfile(profile)->
688 SetDefaultContentSetting(default_setting); 716 SetDefaultContentSetting(default_setting);
689 } else { 717 } else {
690 GetContentSettingsMap()-> 718 HostContentSettingsMap* map = GetContentSettingsMap();
691 SetDefaultContentSetting(content_type, default_setting); 719 ApplyWhitelist(content_type, default_setting);
720 map->SetDefaultContentSetting(content_type, default_setting);
692 } 721 }
693 switch (content_type) { 722 switch (content_type) {
694 case CONTENT_SETTINGS_TYPE_COOKIES: 723 case CONTENT_SETTINGS_TYPE_COOKIES:
695 content::RecordAction( 724 content::RecordAction(
696 UserMetricsAction("Options_DefaultCookieSettingChanged")); 725 UserMetricsAction("Options_DefaultCookieSettingChanged"));
697 break; 726 break;
698 case CONTENT_SETTINGS_TYPE_IMAGES: 727 case CONTENT_SETTINGS_TYPE_IMAGES:
699 content::RecordAction( 728 content::RecordAction(
700 UserMetricsAction("Options_DefaultImagesSettingChanged")); 729 UserMetricsAction("Options_DefaultImagesSettingChanged"));
701 break; 730 break;
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
871 900
872 HostContentSettingsMap* 901 HostContentSettingsMap*
873 ContentSettingsHandler::GetOTRContentSettingsMap() { 902 ContentSettingsHandler::GetOTRContentSettingsMap() {
874 Profile* profile = Profile::FromWebUI(web_ui()); 903 Profile* profile = Profile::FromWebUI(web_ui());
875 if (profile->HasOffTheRecordProfile()) 904 if (profile->HasOffTheRecordProfile())
876 return profile->GetOffTheRecordProfile()->GetHostContentSettingsMap(); 905 return profile->GetOffTheRecordProfile()->GetHostContentSettingsMap();
877 return NULL; 906 return NULL;
878 } 907 }
879 908
880 } // namespace options2 909 } // namespace options2
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options2/content_settings_handler2.h ('k') | chrome/browser/ui/webui/plugins_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698