Add notifications to allow desktop notification permissions to be synced.
Fix a bug where sites can be added to allow and deny lists multiple times.

BUG=none
TEST=Open two browsers with separate profiles.  Request permission for notifications on a site on one.  Check that the permissions are the same on the other browser.

Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=44234

Review URL: http://codereview.chromium.org/1578023

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44283 0039d316-1c4b-4281-b951-d872f2087c98


CrOS-Libchrome-Original-Commit: 84064220a7e5a37715aeb428a80b6474f9799cc2
diff --git a/base/values.cc b/base/values.cc
index f214ead..feff299 100644
--- a/base/values.cc
+++ b/base/values.cc
@@ -832,6 +832,16 @@
   list_.push_back(in_value);
 }
 
+bool ListValue::AppendIfNotPresent(Value* in_value) {
+  DCHECK(in_value);
+  for (ValueVector::iterator i(list_.begin()); i != list_.end(); ++i) {
+    if ((*i)->Equals(in_value))
+      return false;
+  }
+  list_.push_back(in_value);
+  return true;
+}
+
 bool ListValue::Insert(size_t index, Value* in_value) {
   DCHECK(in_value);
   if (index > list_.size())
diff --git a/base/values.h b/base/values.h
index 6c66345..248fc1d 100644
--- a/base/values.h
+++ b/base/values.h
@@ -401,6 +401,10 @@
   // Appends a Value to the end of the list.
   void Append(Value* in_value);
 
+  // Appends a Value if it's not already present.
+  // Returns true if successful, or false if the value was already present.
+  bool AppendIfNotPresent(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);