Chromium Code Reviews| Index: chrome/browser/blocked_popup_container.cc |
| =================================================================== |
| --- chrome/browser/blocked_popup_container.cc (revision 33109) |
| +++ chrome/browser/blocked_popup_container.cc (working copy) |
| @@ -155,11 +155,8 @@ |
| bool should_whitelist = !i->second; |
| popup_hosts_[host] = should_whitelist; |
| - ListValue* whitelist_pref = |
| - prefs_->GetMutableList(prefs::kPopupWhitelistedHosts); |
| if (should_whitelist) { |
| whitelist_.insert(host); |
| - whitelist_pref->Append(new StringValue(host)); |
| // Open the popups in order. |
| for (size_t j = 0; j < blocked_popups_.size();) { |
| @@ -171,8 +168,6 @@ |
| } else { |
| // Remove from whitelist. |
| whitelist_.erase(host); |
| - StringValue host_as_string(host); |
| - whitelist_pref->Remove(host_as_string); |
| for (UnblockedPopups::iterator i(unblocked_popups_.begin()); |
| i != unblocked_popups_.end(); ) { |
| @@ -197,6 +192,21 @@ |
| } |
| } |
| } |
| + |
| + // Persist whitelisting state if we're not off the record. |
| + if (prefs_) { |
| + ListValue* whitelist_pref = |
| + prefs_->GetMutableList(prefs::kPopupWhitelistedHosts); |
| + if (should_whitelist) { |
| + whitelist_pref->Append(new StringValue(host)); |
| + } else { |
| + // Stupidly, gcc complains that you're accessing the (private) StringValue |
| + // copy constructor if you inline the temp creation into the Remove() |
| + // call. |
| + StringValue host_value(host); |
| + whitelist_pref->Remove(host_value); |
| + } |
| + } |
| } |
| void BlockedPopupContainer::CloseAll() { |
| @@ -391,14 +401,17 @@ |
| const ListValue* whitelist_pref = |
| prefs_->GetList(prefs::kPopupWhitelistedHosts); |
| // Careful: The returned value could be NULL if the pref has never been set. |
| - if (whitelist_pref == NULL) |
| - return; |
| - for (ListValue::const_iterator i(whitelist_pref->begin()); |
| - i != whitelist_pref->end(); ++i) { |
| - std::string host; |
| - (*i)->GetAsString(&host); |
| - whitelist_.insert(host); |
| + if (whitelist_pref != NULL) { |
| + for (ListValue::const_iterator i(whitelist_pref->begin()); |
| + i != whitelist_pref->end(); ++i) { |
| + std::string host; |
| + (*i)->GetAsString(&host); |
| + whitelist_.insert(host); |
| + } |
| } |
| + |
| + if (profile->IsOffTheRecord()) |
| + prefs_ = NULL; // Don't persist any zoom levels. |
|
Elliot Glaysher
2009/11/30 17:39:13
I assume this comment was copy/pasted?
|
| } |
| void BlockedPopupContainer::UpdateView() { |