| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this |
| 2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
| 3 // LICENSE file. | 3 // LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/blocked_popup_container.h" | 5 #include "chrome/browser/blocked_popup_container.h" |
| 6 | 6 |
| 7 #include "chrome/browser/profile.h" | 7 #include "chrome/browser/profile.h" |
| 8 #include "chrome/browser/tab_contents/tab_contents.h" | 8 #include "chrome/browser/tab_contents/tab_contents.h" |
| 9 #include "chrome/common/pref_names.h" | 9 #include "chrome/common/pref_names.h" |
| 10 #include "chrome/common/pref_service.h" | 10 #include "chrome/common/pref_service.h" |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 Profile* profile) | 384 Profile* profile) |
| 385 : owner_(owner), | 385 : owner_(owner), |
| 386 prefs_(profile->GetPrefs()), | 386 prefs_(profile->GetPrefs()), |
| 387 has_been_dismissed_(false), | 387 has_been_dismissed_(false), |
| 388 view_(NULL), | 388 view_(NULL), |
| 389 profile_(profile) { | 389 profile_(profile) { |
| 390 // Copy whitelist pref into local member that's easier to use. | 390 // Copy whitelist pref into local member that's easier to use. |
| 391 const ListValue* whitelist_pref = | 391 const ListValue* whitelist_pref = |
| 392 prefs_->GetList(prefs::kPopupWhitelistedHosts); | 392 prefs_->GetList(prefs::kPopupWhitelistedHosts); |
| 393 // Careful: The returned value could be NULL if the pref has never been set. | 393 // Careful: The returned value could be NULL if the pref has never been set. |
| 394 if (whitelist_pref != NULL) { | 394 if (whitelist_pref == NULL) |
| 395 for (ListValue::const_iterator i(whitelist_pref->begin()); | 395 return; |
| 396 i != whitelist_pref->end(); ++i) { | 396 for (ListValue::const_iterator i(whitelist_pref->begin()); |
| 397 std::string host; | 397 i != whitelist_pref->end(); ++i) { |
| 398 (*i)->GetAsString(&host); | 398 std::string host; |
| 399 whitelist_.insert(host); | 399 (*i)->GetAsString(&host); |
| 400 } | 400 whitelist_.insert(host); |
| 401 } | 401 } |
| 402 } | 402 } |
| 403 | 403 |
| 404 void BlockedPopupContainer::UpdateView() { | 404 void BlockedPopupContainer::UpdateView() { |
| 405 if (blocked_popups_.empty() && unblocked_popups_.empty() && | 405 if (blocked_popups_.empty() && unblocked_popups_.empty() && |
| 406 blocked_notices_.empty()) | 406 blocked_notices_.empty()) |
| 407 HideSelf(); | 407 HideSelf(); |
| 408 else | 408 else |
| 409 view_->UpdateLabel(); | 409 view_->UpdateLabel(); |
| 410 } | 410 } |
| 411 | 411 |
| 412 void BlockedPopupContainer::Observe(NotificationType type, | 412 void BlockedPopupContainer::Observe(NotificationType type, |
| 413 const NotificationSource& source, | 413 const NotificationSource& source, |
| 414 const NotificationDetails& details) { | 414 const NotificationDetails& details) { |
| 415 DCHECK(type == NotificationType::TAB_CONTENTS_DESTROYED); | 415 DCHECK(type == NotificationType::TAB_CONTENTS_DESTROYED); |
| 416 TabContents* tab_contents = Source<TabContents>(source).ptr(); | 416 TabContents* tab_contents = Source<TabContents>(source).ptr(); |
| 417 UnblockedPopups::iterator i(unblocked_popups_.find(tab_contents)); | 417 UnblockedPopups::iterator i(unblocked_popups_.find(tab_contents)); |
| 418 DCHECK(i != unblocked_popups_.end()); | 418 DCHECK(i != unblocked_popups_.end()); |
| 419 EraseDataForPopupAndUpdateUI(i); | 419 EraseDataForPopupAndUpdateUI(i); |
| 420 } | 420 } |
| OLD | NEW |