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

Side by Side Diff: chrome/browser/ui/webui/options/content_settings_handler.cc

Issue 1825173003: [Policy Experimental] Add "recommended" policies for URL exceptions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync. Created 4 years, 8 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
OLDNEW
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/options/content_settings_handler.h" 5 #include "chrome/browser/ui/webui/options/content_settings_handler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <algorithm> 8 #include <algorithm>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 // if they differ. 842 // if they differ.
843 if (type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC || 843 if (type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC ||
844 type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA) { 844 type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA) {
845 UpdateMediaSettingsFromPrefs(type); 845 UpdateMediaSettingsFromPrefs(type);
846 if (media_settings_->forType(type).policy_disable) { 846 if (media_settings_->forType(type).policy_disable) {
847 default_setting = CONTENT_SETTING_BLOCK; 847 default_setting = CONTENT_SETTING_BLOCK;
848 provider_id = site_settings::kPolicyProviderId; 848 provider_id = site_settings::kPolicyProviderId;
849 } 849 }
850 } 850 }
851 851
852 ContentSetting recommended_default_setting =
853 GetContentSettingsMap()->GetRecommendedDefaultContentSetting(type);
854
852 base::DictionaryValue filter_settings; 855 base::DictionaryValue filter_settings;
853 856
857 std::string group_name = ContentSettingsTypeToGroupName(type);
858
854 std::string setting_string = 859 std::string setting_string =
855 content_settings::ContentSettingToString(default_setting); 860 content_settings::ContentSettingToString(default_setting);
856 DCHECK(!setting_string.empty()); 861 DCHECK(!setting_string.empty());
857 862
858 filter_settings.SetString(ContentSettingsTypeToGroupName(type) + ".value", 863 filter_settings.SetString(group_name + ".value", setting_string);
859 setting_string); 864
860 filter_settings.SetString( 865 std::string recommended_setting_string =
861 ContentSettingsTypeToGroupName(type) + ".managedBy", provider_id); 866 content_settings::ContentSettingToString(recommended_default_setting);
867 DCHECK(!recommended_setting_string.empty());
868
869 filter_settings.SetString(group_name + ".recommendedValue",
870 recommended_setting_string);
871
872 filter_settings.SetString(group_name + ".managedBy", provider_id);
862 873
863 web_ui()->CallJavascriptFunction( 874 web_ui()->CallJavascriptFunction(
864 "ContentSettings.setContentFilterSettingsValue", filter_settings); 875 "ContentSettings.setContentFilterSettingsValue", filter_settings);
865 } 876 }
866 877
867 void ContentSettingsHandler::UpdateMediaSettingsFromPrefs( 878 void ContentSettingsHandler::UpdateMediaSettingsFromPrefs(
868 ContentSettingsType type) { 879 ContentSettingsType type) {
869 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); 880 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui()));
870 MediaSettingsInfo::ForOneType& settings = media_settings_->forType(type); 881 MediaSettingsInfo::ForOneType& settings = media_settings_->forType(type);
871 std::string policy_pref = (type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC) 882 std::string policy_pref = (type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC)
(...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after
1691 1702
1692 // Exceptions apply only when the feature is enabled. 1703 // Exceptions apply only when the feature is enabled.
1693 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); 1704 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui()));
1694 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); 1705 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM);
1695 web_ui()->CallJavascriptFunction( 1706 web_ui()->CallJavascriptFunction(
1696 "ContentSettings.enableProtectedContentExceptions", 1707 "ContentSettings.enableProtectedContentExceptions",
1697 base::FundamentalValue(enable_exceptions)); 1708 base::FundamentalValue(enable_exceptions));
1698 } 1709 }
1699 1710
1700 } // namespace options 1711 } // namespace options
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/browser_options_handler.cc ('k') | chrome/browser/ui/webui/policy_ui_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698