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

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

Issue 7837038: Address post commit comments for CL http://codereview.chromium.org/7828022/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/content_settings/host_content_settings_map.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/content_settings_policy_provider.h" 5 #include "chrome/browser/content_settings/content_settings_policy_provider.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 DCHECK_NE(content_type, CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE); 333 DCHECK_NE(content_type, CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE);
334 // If only one pattern was defined auto expand it to a pattern pair. 334 // If only one pattern was defined auto expand it to a pattern pair.
335 ContentSettingsPattern secondary_pattern = 335 ContentSettingsPattern secondary_pattern =
336 !pattern_pair.second.IsValid() ? ContentSettingsPattern::Wildcard() 336 !pattern_pair.second.IsValid() ? ContentSettingsPattern::Wildcard()
337 : pattern_pair.second; 337 : pattern_pair.second;
338 value_map->SetValue( 338 value_map->SetValue(
339 pattern_pair.first, 339 pattern_pair.first,
340 secondary_pattern, 340 secondary_pattern,
341 content_type, 341 content_type,
342 ResourceIdentifier(NO_RESOURCE_IDENTIFIER), 342 ResourceIdentifier(NO_RESOURCE_IDENTIFIER),
343 static_cast<Value*>(Value::CreateIntegerValue( 343 Value::CreateIntegerValue(
344 kPrefsForManagedContentSettingsMap[i].setting))); 344 kPrefsForManagedContentSettingsMap[i].setting));
345 } 345 }
346 } 346 }
347 } 347 }
348 348
349 void PolicyProvider::GetAutoSelectCertificateSettingsFromPreferences( 349 void PolicyProvider::GetAutoSelectCertificateSettingsFromPreferences(
350 OriginIdentifierValueMap* value_map) { 350 OriginIdentifierValueMap* value_map) {
351 const char* pref_name = prefs::kManagedAutoSelectCertificateForUrls; 351 const char* pref_name = prefs::kManagedAutoSelectCertificateForUrls;
352 352
353 if (!prefs_->HasPrefPath(pref_name)) { 353 if (!prefs_->HasPrefPath(pref_name)) {
354 VLOG(2) << "Skipping unset preference: " << pref_name; 354 VLOG(2) << "Skipping unset preference: " << pref_name;
(...skipping 26 matching lines...) Expand all
381 // "CN": "some name" 381 // "CN": "some name"
382 // } 382 // }
383 // } 383 // }
384 for (size_t j = 0; j < pattern_filter_str_list->GetSize(); ++j) { 384 for (size_t j = 0; j < pattern_filter_str_list->GetSize(); ++j) {
385 std::string pattern_filter_json; 385 std::string pattern_filter_json;
386 pattern_filter_str_list->GetString(j, &pattern_filter_json); 386 pattern_filter_str_list->GetString(j, &pattern_filter_json);
387 387
388 scoped_ptr<Value> value(base::JSONReader::Read(pattern_filter_json, true)); 388 scoped_ptr<Value> value(base::JSONReader::Read(pattern_filter_json, true));
389 if (!value.get()) { 389 if (!value.get()) {
390 VLOG(1) << "Ignoring invalid certificate auto select setting. Reason:" 390 VLOG(1) << "Ignoring invalid certificate auto select setting. Reason:"
391 << " Invalid JSON format: " << pattern_filter_json; 391 " Invalid JSON format: " << pattern_filter_json;
392 continue; 392 continue;
393 } 393 }
394 394
395 scoped_ptr<DictionaryValue> pattern_filter_pair( 395 scoped_ptr<DictionaryValue> pattern_filter_pair(
396 static_cast<DictionaryValue*>(value.release())); 396 static_cast<DictionaryValue*>(value.release()));
397 std::string pattern_str; 397 std::string pattern_str;
398 bool pattern_read = pattern_filter_pair->GetString("pattern", &pattern_str); 398 bool pattern_read = pattern_filter_pair->GetString("pattern", &pattern_str);
399 Value* cert_filter_ptr = NULL; 399 Value* cert_filter_ptr = NULL;
400 bool filter_read = pattern_filter_pair->Remove("filter", &cert_filter_ptr); 400 bool filter_read = pattern_filter_pair->Remove("filter", &cert_filter_ptr);
401 scoped_ptr<Value> cert_filter(cert_filter_ptr); 401 scoped_ptr<Value> cert_filter(cert_filter_ptr);
402 if (!pattern_read || !filter_read) { 402 if (!pattern_read || !filter_read) {
403 VLOG(1) << "Ignoring invalid certificate auto select setting. Reason:" 403 VLOG(1) << "Ignoring invalid certificate auto select setting. Reason:"
404 << " Missing pattern or filtern."; 404 " Missing pattern or filter.";
405 continue; 405 continue;
406 } 406 }
407 407
408 ContentSettingsPattern pattern = 408 ContentSettingsPattern pattern =
409 ContentSettingsPattern::FromString(pattern_str); 409 ContentSettingsPattern::FromString(pattern_str);
410 // Ignore invalid patterns. 410 // Ignore invalid patterns.
411 if (!pattern.IsValid()) { 411 if (!pattern.IsValid()) {
412 VLOG(1) << "Ignoring invalid certificate auto select setting:" 412 VLOG(1) << "Ignoring invalid certificate auto select setting:"
413 << " Invalid content settings pattern: " << pattern; 413 " Invalid content settings pattern: " << pattern;
414 continue; 414 continue;
415 } 415 }
416 416
417 DCHECK(cert_filter->IsType(Value::TYPE_DICTIONARY)); 417 DCHECK(cert_filter->IsType(Value::TYPE_DICTIONARY));
418 value_map->SetValue(pattern, 418 value_map->SetValue(pattern,
419 ContentSettingsPattern::Wildcard(), 419 ContentSettingsPattern::Wildcard(),
420 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, 420 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE,
421 std::string(), 421 std::string(),
422 cert_filter.release()); 422 cert_filter.release());
423 } 423 }
424 } 424 }
425 425
426 void PolicyProvider::ReadManagedContentSettings(bool overwrite) { 426 void PolicyProvider::ReadManagedContentSettings(bool overwrite) {
427 { 427 base::AutoLock auto_lock(lock_);
428 base::AutoLock auto_lock(lock_); 428 if (overwrite)
429 if (overwrite) 429 value_map_.clear();
430 value_map_.clear(); 430 GetContentSettingsFromPreferences(&value_map_);
431 GetContentSettingsFromPreferences(&value_map_); 431 GetAutoSelectCertificateSettingsFromPreferences(&value_map_);
432 GetAutoSelectCertificateSettingsFromPreferences(&value_map_);
433 }
434 } 432 }
435 433
436 // Since the PolicyProvider is a read only content settings provider, all 434 // Since the PolicyProvider is a read only content settings provider, all
437 // methodes of the ProviderInterface that set or delete any settings do nothing. 435 // methodes of the ProviderInterface that set or delete any settings do nothing.
438 void PolicyProvider::SetContentSetting( 436 void PolicyProvider::SetContentSetting(
439 const ContentSettingsPattern& primary_pattern, 437 const ContentSettingsPattern& primary_pattern,
440 const ContentSettingsPattern& secondary_pattern, 438 const ContentSettingsPattern& secondary_pattern,
441 ContentSettingsType content_type, 439 ContentSettingsType content_type,
442 const ResourceIdentifier& resource_identifier, 440 const ResourceIdentifier& resource_identifier,
443 ContentSetting content_setting) { 441 ContentSetting content_setting) {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 ContentSettingsPattern(), 540 ContentSettingsPattern(),
543 CONTENT_SETTINGS_TYPE_DEFAULT, 541 CONTENT_SETTINGS_TYPE_DEFAULT,
544 std::string()); 542 std::string());
545 } 543 }
546 } else { 544 } else {
547 NOTREACHED() << "Unexpected notification"; 545 NOTREACHED() << "Unexpected notification";
548 } 546 }
549 } 547 }
550 548
551 } // namespace content_settings 549 } // namespace content_settings
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/content_settings/host_content_settings_map.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698