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

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

Issue 545413002: Detach the dependency from host_content_settings_map to extension. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove ProviderType Created 6 years, 3 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 <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 1063 matching lines...) Expand 10 before | Expand all | Expand 10 after
1074 if (map->is_off_the_record() && !i->incognito) 1074 if (map->is_off_the_record() && !i->incognito)
1075 continue; 1075 continue;
1076 1076
1077 all_patterns_settings[std::make_pair(i->primary_pattern, i->source)] 1077 all_patterns_settings[std::make_pair(i->primary_pattern, i->source)]
1078 [i->secondary_pattern] = i->setting; 1078 [i->secondary_pattern] = i->setting;
1079 } 1079 }
1080 1080
1081 // Keep the exceptions sorted by provider so they will be displayed in 1081 // Keep the exceptions sorted by provider so they will be displayed in
1082 // precedence order. 1082 // precedence order.
1083 std::vector<std::vector<base::Value*> > all_provider_exceptions; 1083 std::vector<std::vector<base::Value*> > all_provider_exceptions;
1084 all_provider_exceptions.resize(HostContentSettingsMap::NUM_PROVIDER_TYPES); 1084 all_provider_exceptions.resize(map->GetNumProviders());
1085 1085
1086 for (AllPatternsSettings::iterator i = all_patterns_settings.begin(); 1086 for (AllPatternsSettings::iterator i = all_patterns_settings.begin();
1087 i != all_patterns_settings.end(); 1087 i != all_patterns_settings.end();
1088 ++i) { 1088 ++i) {
1089 const ContentSettingsPattern& primary_pattern = i->first.first; 1089 const ContentSettingsPattern& primary_pattern = i->first.first;
1090 const OnePatternSettings& one_settings = i->second; 1090 const OnePatternSettings& one_settings = i->second;
1091 1091
1092 // The "parent" entry either has an identical primary and secondary pattern, 1092 // The "parent" entry either has an identical primary and secondary pattern,
1093 // or has a wildcard secondary. The two cases are indistinguishable in the 1093 // or has a wildcard secondary. The two cases are indistinguishable in the
1094 // UI. 1094 // UI.
1095 OnePatternSettings::const_iterator parent = 1095 OnePatternSettings::const_iterator parent =
1096 one_settings.find(primary_pattern); 1096 one_settings.find(primary_pattern);
1097 if (parent == one_settings.end()) 1097 if (parent == one_settings.end())
1098 parent = one_settings.find(ContentSettingsPattern::Wildcard()); 1098 parent = one_settings.find(ContentSettingsPattern::Wildcard());
1099 1099
1100 const std::string& source = i->first.second; 1100 const std::string& source = i->first.second;
1101 std::vector<base::Value*>* this_provider_exceptions = 1101 std::vector<base::Value*>* this_provider_exceptions = NULL;
1102 &all_provider_exceptions.at( 1102 for (size_t j = 0; j < map->GetNumProviders(); ++j) {
1103 HostContentSettingsMap::GetProviderTypeFromSource(source)); 1103 const content_settings::ProviderInterface* provider =
1104 map->GetProviderAt(j);
1105 if (provider->GetProviderName() == source) {
1106 this_provider_exceptions = &all_provider_exceptions.at(j);
1107 break;
1108 }
1109 }
1110 if (!this_provider_exceptions) {
1111 LOG(WARNING) << "Cannot find the provider for " << source;
1112 continue;
1113 }
1104 1114
1105 // Add the "parent" entry for the non-embedded setting. 1115 // Add the "parent" entry for the non-embedded setting.
1106 ContentSetting parent_setting = 1116 ContentSetting parent_setting =
1107 parent == one_settings.end() ? CONTENT_SETTING_DEFAULT : parent->second; 1117 parent == one_settings.end() ? CONTENT_SETTING_DEFAULT : parent->second;
1108 const ContentSettingsPattern& secondary_pattern = 1118 const ContentSettingsPattern& secondary_pattern =
1109 parent == one_settings.end() ? primary_pattern : parent->first; 1119 parent == one_settings.end() ? primary_pattern : parent->first;
1110 this_provider_exceptions->push_back(GetExceptionForPage(primary_pattern, 1120 this_provider_exceptions->push_back(GetExceptionForPage(primary_pattern,
1111 secondary_pattern, 1121 secondary_pattern,
1112 parent_setting, 1122 parent_setting,
1113 source)); 1123 source));
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
1492 void ContentSettingsHandler::UpdateProtectedContentExceptionsButton() { 1502 void ContentSettingsHandler::UpdateProtectedContentExceptionsButton() {
1493 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); 1503 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui()));
1494 // Exceptions apply only when the feature is enabled. 1504 // Exceptions apply only when the feature is enabled.
1495 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); 1505 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM);
1496 web_ui()->CallJavascriptFunction( 1506 web_ui()->CallJavascriptFunction(
1497 "ContentSettings.enableProtectedContentExceptions", 1507 "ContentSettings.enableProtectedContentExceptions",
1498 base::FundamentalValue(enable_exceptions)); 1508 base::FundamentalValue(enable_exceptions));
1499 } 1509 }
1500 1510
1501 } // namespace options 1511 } // namespace options
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698