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

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

Issue 3068005: Flesh out the content settings exceptions lists a bit more. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: reduce instance vars Created 10 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/host_content_settings_map.h" 5 #include "chrome/browser/host_content_settings_map.h"
6 6
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/chrome_thread.h" 9 #include "chrome/browser/chrome_thread.h"
10 #include "chrome/browser/pref_service.h" 10 #include "chrome/browser/pref_service.h"
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 default_settings_dictionary->RemoveWithoutPathExpansion(dictionary_path, 331 default_settings_dictionary->RemoveWithoutPathExpansion(dictionary_path,
332 NULL); 332 NULL);
333 } else { 333 } else {
334 default_content_settings_.settings[content_type] = setting; 334 default_content_settings_.settings[content_type] = setting;
335 default_settings_dictionary->SetWithoutPathExpansion( 335 default_settings_dictionary->SetWithoutPathExpansion(
336 dictionary_path, Value::CreateIntegerValue(setting)); 336 dictionary_path, Value::CreateIntegerValue(setting));
337 } 337 }
338 } 338 }
339 updating_preferences_ = false; 339 updating_preferences_ = false;
340 340
341 NotifyObservers(ContentSettingsDetails(true)); 341 NotifyObservers(ContentSettingsDetails(content_type));
342 } 342 }
343 343
344 void HostContentSettingsMap::SetContentSetting(const Pattern& pattern, 344 void HostContentSettingsMap::SetContentSetting(const Pattern& pattern,
345 ContentSettingsType content_type, 345 ContentSettingsType content_type,
346 ContentSetting setting) { 346 ContentSetting setting) {
347 DCHECK(kTypeNames[content_type] != NULL); // Don't call this for Geolocation. 347 DCHECK(kTypeNames[content_type] != NULL); // Don't call this for Geolocation.
348 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); 348 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
349 349
350 bool early_exit = false; 350 bool early_exit = false;
351 std::wstring wide_pattern(UTF8ToWide(pattern.AsString())); 351 std::wstring wide_pattern(UTF8ToWide(pattern.AsString()));
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 host_settings_dictionary->SetWithoutPathExpansion( 396 host_settings_dictionary->SetWithoutPathExpansion(
397 dictionary_path, Value::CreateIntegerValue(setting)); 397 dictionary_path, Value::CreateIntegerValue(setting));
398 } 398 }
399 } 399 }
400 400
401 updating_preferences_ = true; 401 updating_preferences_ = true;
402 if (!is_off_the_record_) 402 if (!is_off_the_record_)
403 ScopedPrefUpdate update(prefs, prefs::kContentSettingsPatterns); 403 ScopedPrefUpdate update(prefs, prefs::kContentSettingsPatterns);
404 updating_preferences_ = false; 404 updating_preferences_ = false;
405 405
406 NotifyObservers(ContentSettingsDetails(pattern)); 406 NotifyObservers(ContentSettingsDetails(pattern, content_type));
407 } 407 }
408 408
409 void HostContentSettingsMap::AddExceptionForURL( 409 void HostContentSettingsMap::AddExceptionForURL(
410 const GURL& url, 410 const GURL& url,
411 ContentSettingsType content_type, 411 ContentSettingsType content_type,
412 ContentSetting setting) { 412 ContentSetting setting) {
413 // Make sure there is no entry that would override the pattern we are about 413 // Make sure there is no entry that would override the pattern we are about
414 // to insert for exactly this URL. 414 // to insert for exactly this URL.
415 SetContentSetting(Pattern::FromURLNoWildcard(url), 415 SetContentSetting(Pattern::FromURLNoWildcard(url),
416 content_type, 416 content_type,
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 ++i; 459 ++i;
460 } 460 }
461 } 461 }
462 } 462 }
463 463
464 updating_preferences_ = true; 464 updating_preferences_ = true;
465 if (!is_off_the_record_) 465 if (!is_off_the_record_)
466 ScopedPrefUpdate update(prefs, prefs::kContentSettingsPatterns); 466 ScopedPrefUpdate update(prefs, prefs::kContentSettingsPatterns);
467 updating_preferences_ = false; 467 updating_preferences_ = false;
468 468
469 NotifyObservers(ContentSettingsDetails(true)); 469 NotifyObservers(ContentSettingsDetails(content_type));
470 } 470 }
471 471
472 void HostContentSettingsMap::SetBlockThirdPartyCookies(bool block) { 472 void HostContentSettingsMap::SetBlockThirdPartyCookies(bool block) {
473 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); 473 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
474 474
475 // This setting may not be directly modified for OTR sessions. Instead, it 475 // This setting may not be directly modified for OTR sessions. Instead, it
476 // is synced to the main profile's setting. 476 // is synced to the main profile's setting.
477 if (is_off_the_record_) { 477 if (is_off_the_record_) {
478 NOTREACHED(); 478 NOTREACHED();
479 return; 479 return;
(...skipping 23 matching lines...) Expand all
503 block_third_party_cookies_ = false; 503 block_third_party_cookies_ = false;
504 } 504 }
505 505
506 if (!is_off_the_record_) { 506 if (!is_off_the_record_) {
507 PrefService* prefs = profile_->GetPrefs(); 507 PrefService* prefs = profile_->GetPrefs();
508 updating_preferences_ = true; 508 updating_preferences_ = true;
509 prefs->ClearPref(prefs::kDefaultContentSettings); 509 prefs->ClearPref(prefs::kDefaultContentSettings);
510 prefs->ClearPref(prefs::kContentSettingsPatterns); 510 prefs->ClearPref(prefs::kContentSettingsPatterns);
511 prefs->ClearPref(prefs::kBlockThirdPartyCookies); 511 prefs->ClearPref(prefs::kBlockThirdPartyCookies);
512 updating_preferences_ = false; 512 updating_preferences_ = false;
513 NotifyObservers(ContentSettingsDetails(true)); 513 NotifyObservers(ContentSettingsDetails());
514 } 514 }
515 } 515 }
516 516
517 bool HostContentSettingsMap::IsOffTheRecord() { 517 bool HostContentSettingsMap::IsOffTheRecord() {
518 return profile_->IsOffTheRecord(); 518 return profile_->IsOffTheRecord();
519 } 519 }
520 520
521 void HostContentSettingsMap::Observe(NotificationType type, 521 void HostContentSettingsMap::Observe(NotificationType type,
522 const NotificationSource& source, 522 const NotificationSource& source,
523 const NotificationDetails& details) { 523 const NotificationDetails& details) {
(...skipping 11 matching lines...) Expand all
535 } else if (prefs::kBlockThirdPartyCookies == *name) { 535 } else if (prefs::kBlockThirdPartyCookies == *name) {
536 AutoLock auto_lock(lock_); 536 AutoLock auto_lock(lock_);
537 block_third_party_cookies_ = profile_->GetPrefs()->GetBoolean( 537 block_third_party_cookies_ = profile_->GetPrefs()->GetBoolean(
538 prefs::kBlockThirdPartyCookies); 538 prefs::kBlockThirdPartyCookies);
539 } else { 539 } else {
540 NOTREACHED() << "Unexpected preference observed"; 540 NOTREACHED() << "Unexpected preference observed";
541 return; 541 return;
542 } 542 }
543 543
544 if (!is_off_the_record_) 544 if (!is_off_the_record_)
545 NotifyObservers(ContentSettingsDetails(true)); 545 NotifyObservers(ContentSettingsDetails());
546 } else if (NotificationType::PROFILE_DESTROYED == type) { 546 } else if (NotificationType::PROFILE_DESTROYED == type) {
547 UnregisterObservers(); 547 UnregisterObservers();
548 } else { 548 } else {
549 NOTREACHED() << "Unexpected notification"; 549 NOTREACHED() << "Unexpected notification";
550 } 550 }
551 } 551 }
552 552
553 HostContentSettingsMap::~HostContentSettingsMap() { 553 HostContentSettingsMap::~HostContentSettingsMap() {
554 UnregisterObservers(); 554 UnregisterObservers();
555 } 555 }
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 if (!profile_) 655 if (!profile_)
656 return; 656 return;
657 PrefService* prefs = profile_->GetPrefs(); 657 PrefService* prefs = profile_->GetPrefs();
658 prefs->RemovePrefObserver(prefs::kDefaultContentSettings, this); 658 prefs->RemovePrefObserver(prefs::kDefaultContentSettings, this);
659 prefs->RemovePrefObserver(prefs::kContentSettingsPatterns, this); 659 prefs->RemovePrefObserver(prefs::kContentSettingsPatterns, this);
660 prefs->RemovePrefObserver(prefs::kBlockThirdPartyCookies, this); 660 prefs->RemovePrefObserver(prefs::kBlockThirdPartyCookies, this);
661 notification_registrar_.Remove(this, NotificationType::PROFILE_DESTROYED, 661 notification_registrar_.Remove(this, NotificationType::PROFILE_DESTROYED,
662 Source<Profile>(profile_)); 662 Source<Profile>(profile_));
663 profile_ = NULL; 663 profile_ = NULL;
664 } 664 }
OLDNEW
« no previous file with comments | « chrome/browser/host_content_settings_map.h ('k') | chrome/browser/host_content_settings_map_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698