summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-09 00:33:04 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-09 00:33:04 +0000
commite7f5c6f8aede399fe896e8218d89087408011d18 (patch)
tree58ed75a2b1ae424a089a9a9fd8bb5724fed35ded /base
parent1188a6c0b9025c6ccb9eff833599b951fc778a9a (diff)
downloadchromium_src-e7f5c6f8aede399fe896e8218d89087408011d18.zip
chromium_src-e7f5c6f8aede399fe896e8218d89087408011d18.tar.gz
chromium_src-e7f5c6f8aede399fe896e8218d89087408011d18.tar.bz2
Implement the popup blocking whitelist pref. This makes the whitelist actually function.BUG=11440
Review URL: http://codereview.chromium.org/115149 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15702 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/values.cc28
-rw-r--r--base/values.h7
2 files changed, 17 insertions, 18 deletions
diff --git a/base/values.cc b/base/values.cc
index f8e3729..3b5bd38 100644
--- a/base/values.cc
+++ b/base/values.cc
@@ -497,11 +497,8 @@ ListValue::~ListValue() {
}
void ListValue::Clear() {
- ValueVector::iterator list_iterator = list_.begin();
- while (list_iterator != list_.end()) {
- delete *list_iterator;
- ++list_iterator;
- }
+ for (ValueVector::iterator i(list_.begin()); i != list_.end(); ++i)
+ delete *i;
list_.clear();
}
@@ -609,13 +606,19 @@ bool ListValue::Remove(size_t index, Value** out_value) {
else
delete list_[index];
- ValueVector::iterator entry = list_.begin();
- entry += index;
-
- list_.erase(entry);
+ list_.erase(list_.begin() + index);
return true;
}
+void ListValue::Remove(const Value& value) {
+ for (ValueVector::iterator i(list_.begin()); i != list_.end(); ++i) {
+ if ((*i)->Equals(&value)) {
+ list_.erase(i);
+ break;
+ }
+ }
+}
+
void ListValue::Append(Value* in_value) {
DCHECK(in_value);
list_.push_back(in_value);
@@ -624,11 +627,8 @@ void ListValue::Append(Value* in_value) {
Value* ListValue::DeepCopy() const {
ListValue* result = new ListValue;
- ValueVector::const_iterator current_entry = list_.begin();
- while (current_entry != list_.end()) {
- result->Append((*current_entry)->DeepCopy());
- ++current_entry;
- }
+ for (ValueVector::const_iterator i(list_.begin()); i != list_.end(); ++i)
+ result->Append((*i)->DeepCopy());
return result;
}
diff --git a/base/values.h b/base/values.h
index fa5b1017..cd68b10 100644
--- a/base/values.h
+++ b/base/values.h
@@ -334,6 +334,9 @@ class ListValue : public Value {
// it will return false and the ListValue object will be unchanged.
bool Remove(size_t index, Value** out_value);
+ // Removes the first instance of |value| found in the list, if any.
+ void Remove(const Value& value);
+
// Appends a Value to the end of the list.
void Append(Value* in_value);
@@ -347,10 +350,6 @@ class ListValue : public Value {
ListValue::const_iterator begin() const { return list_.begin(); }
ListValue::const_iterator end() const { return list_.end(); }
- ListValue::iterator Erase(iterator item) {
- return list_.erase(item);
- }
-
private:
DISALLOW_EVIL_CONSTRUCTORS(ListValue);