summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorerikkay@chromium.org <erikkay@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-28 20:26:05 +0000
committererikkay@chromium.org <erikkay@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-28 20:26:05 +0000
commit86c008e8a7da9c00c5a676eb201ba5d0c976748e (patch)
tree8e58aeeab8564a396ccf67807d5bddfcdaa05807 /base
parent5ec8d59c7e79d1a7aae4137051ffc184ec51096c (diff)
downloadchromium_src-86c008e8a7da9c00c5a676eb201ba5d0c976748e.zip
chromium_src-86c008e8a7da9c00c5a676eb201ba5d0c976748e.tar.gz
chromium_src-86c008e8a7da9c00c5a676eb201ba5d0c976748e.tar.bz2
override chrome:// URLs via extensions.
Overrides are declared in an extension's manifest. The last one installed wins. However, we keep a list of those installed per page so that priority is preserved and so that uninstall will revert to a previous state. Review URL: http://codereview.chromium.org/174277 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@24791 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/values.cc15
-rw-r--r--base/values.h9
2 files changed, 20 insertions, 4 deletions
diff --git a/base/values.cc b/base/values.cc
index 3b5bd38..716fdf3 100644
--- a/base/values.cc
+++ b/base/values.cc
@@ -610,13 +610,15 @@ bool ListValue::Remove(size_t index, Value** out_value) {
return true;
}
-void ListValue::Remove(const Value& value) {
+int ListValue::Remove(const Value& value) {
for (ValueVector::iterator i(list_.begin()); i != list_.end(); ++i) {
if ((*i)->Equals(&value)) {
+ size_t index = i - list_.begin();
list_.erase(i);
- break;
+ return index;
}
}
+ return -1;
}
void ListValue::Append(Value* in_value) {
@@ -624,6 +626,15 @@ void ListValue::Append(Value* in_value) {
list_.push_back(in_value);
}
+bool ListValue::Insert(size_t index, Value* in_value) {
+ DCHECK(in_value);
+ if (index < 0 || index > list_.size())
+ return false;
+
+ list_.insert(list_.begin() + index, in_value);
+ return true;
+}
+
Value* ListValue::DeepCopy() const {
ListValue* result = new ListValue;
diff --git a/base/values.h b/base/values.h
index cd68b10..482ffa0 100644
--- a/base/values.h
+++ b/base/values.h
@@ -334,12 +334,17 @@ 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);
+ // Removes the first instance of |value| found in the list, if any, returning
+ // the index that it was located at (-1 for not present).
+ int Remove(const Value& value);
// Appends a Value to the end of the list.
void Append(Value* in_value);
+ // Insert a Value at index.
+ // Returns true if successful, or false if the index was out of range.
+ bool Insert(size_t index, Value* in_value);
+
// Iteration
typedef ValueVector::iterator iterator;
typedef ValueVector::const_iterator const_iterator;