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

Side by Side Diff: chrome/browser/content_settings/host_content_settings_map.cc

Issue 7484072: Migrate geolocation settings to host content settings map. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: " Created 9 years, 4 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/content_settings/host_content_settings_map.h" 5 #include "chrome/browser/content_settings/host_content_settings_map.h"
6 6
7 #include <list> 7 #include <list>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 DefaultProviderIterator; 51 DefaultProviderIterator;
52 typedef std::vector<DefaultContentSettingsProviderPtr>::const_iterator 52 typedef std::vector<DefaultContentSettingsProviderPtr>::const_iterator
53 ConstDefaultProviderIterator; 53 ConstDefaultProviderIterator;
54 54
55 typedef linked_ptr<content_settings::ProviderInterface> ProviderPtr; 55 typedef linked_ptr<content_settings::ProviderInterface> ProviderPtr;
56 typedef std::vector<ProviderPtr>::iterator ProviderIterator; 56 typedef std::vector<ProviderPtr>::iterator ProviderIterator;
57 typedef std::vector<ProviderPtr>::const_iterator ConstProviderIterator; 57 typedef std::vector<ProviderPtr>::const_iterator ConstProviderIterator;
58 58
59 typedef content_settings::ProviderInterface::Rules Rules; 59 typedef content_settings::ProviderInterface::Rules Rules;
60 60
61 typedef std::pair<std::string, std::string> StringPair;
62
61 const char* kProviderNames[] = { 63 const char* kProviderNames[] = {
62 "policy", 64 "policy",
63 "extension", 65 "extension",
64 "preference" 66 "preference"
65 }; 67 };
66 68
67 } // namespace 69 } // namespace
68 70
69 HostContentSettingsMap::HostContentSettingsMap( 71 HostContentSettingsMap::HostContentSettingsMap(
70 PrefService* prefs, 72 PrefService* prefs,
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 resource_identifier.empty()); 306 resource_identifier.empty());
305 DCHECK(settings); 307 DCHECK(settings);
306 308
307 settings->clear(); 309 settings->clear();
308 for (size_t i = 0; i < content_settings_providers_.size(); ++i) { 310 for (size_t i = 0; i < content_settings_providers_.size(); ++i) {
309 // Get rules from the content settings provider. 311 // Get rules from the content settings provider.
310 Rules rules; 312 Rules rules;
311 content_settings_providers_[i]->GetAllContentSettingsRules( 313 content_settings_providers_[i]->GetAllContentSettingsRules(
312 content_type, resource_identifier, &rules); 314 content_type, resource_identifier, &rules);
313 315
314 // Sort rules according to their primary pattern string using a map. 316 // Sort rules according to their primary-secondary pattern string pairs
315 std::map<std::string, PatternSettingSourceTuple> settings_map; 317 // using a map.
318 std::map<StringPair, PatternSettingSourceTuple> settings_map;
316 for (Rules::iterator rule = rules.begin(); 319 for (Rules::iterator rule = rules.begin();
317 rule != rules.end(); 320 rule != rules.end();
318 ++rule) { 321 ++rule) {
319 // We do not support pattern pairs in the UI, so we only display the 322 StringPair sort_key(rule->primary_pattern.ToString(),
320 // primary pattern. 323 rule->secondary_pattern.ToString());
321 std::string sort_key = rule->primary_pattern.ToString();
322 settings_map[sort_key] = PatternSettingSourceTuple( 324 settings_map[sort_key] = PatternSettingSourceTuple(
323 rule->primary_pattern, 325 rule->primary_pattern,
324 rule->secondary_pattern, 326 rule->secondary_pattern,
325 rule->content_setting, 327 rule->content_setting,
326 kProviderNames[i]); 328 kProviderNames[i]);
327 } 329 }
328 330
329 // TODO(markusheintz): Only the rules that are applied should be added. 331 // TODO(markusheintz): Only the rules that are applied should be added.
330 for (std::map<std::string, PatternSettingSourceTuple>::iterator i( 332 for (std::map<StringPair, PatternSettingSourceTuple>::iterator i(
331 settings_map.begin()); 333 settings_map.begin());
332 i != settings_map.end(); 334 i != settings_map.end();
333 ++i) { 335 ++i) {
334 settings->push_back(i->second); 336 settings->push_back(i->second);
335 } 337 }
336 } 338 }
337 } 339 }
338 340
339 void HostContentSettingsMap::SetDefaultContentSetting( 341 void HostContentSettingsMap::SetDefaultContentSetting(
340 ContentSettingsType content_type, 342 ContentSettingsType content_type,
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_COOKIES, 536 SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_COOKIES,
535 (cookie_behavior == net::StaticCookiePolicy::BLOCK_ALL_COOKIES) ? 537 (cookie_behavior == net::StaticCookiePolicy::BLOCK_ALL_COOKIES) ?
536 CONTENT_SETTING_BLOCK : CONTENT_SETTING_ALLOW); 538 CONTENT_SETTING_BLOCK : CONTENT_SETTING_ALLOW);
537 } 539 }
538 if (!prefs_->HasPrefPath(prefs::kBlockThirdPartyCookies)) { 540 if (!prefs_->HasPrefPath(prefs::kBlockThirdPartyCookies)) {
539 SetBlockThirdPartyCookies(cookie_behavior == 541 SetBlockThirdPartyCookies(cookie_behavior ==
540 net::StaticCookiePolicy::BLOCK_SETTING_THIRD_PARTY_COOKIES); 542 net::StaticCookiePolicy::BLOCK_SETTING_THIRD_PARTY_COOKIES);
541 } 543 }
542 } 544 }
543 } 545 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698