Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: base/values.cc

Issue 174277: override chrome:// URLs via extensions. (Closed)
Patch Set: fix linux errors Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/values.h ('k') | chrome/browser/browser_about_handler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/logging.h" 5 #include "base/logging.h"
6 #include "base/string_util.h" 6 #include "base/string_util.h"
7 #include "base/values.h" 7 #include "base/values.h"
8 8
9 ///////////////////// Value //////////////////// 9 ///////////////////// Value ////////////////////
10 10
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 603
604 if (out_value) 604 if (out_value)
605 *out_value = list_[index]; 605 *out_value = list_[index];
606 else 606 else
607 delete list_[index]; 607 delete list_[index];
608 608
609 list_.erase(list_.begin() + index); 609 list_.erase(list_.begin() + index);
610 return true; 610 return true;
611 } 611 }
612 612
613 void ListValue::Remove(const Value& value) { 613 int ListValue::Remove(const Value& value) {
614 for (ValueVector::iterator i(list_.begin()); i != list_.end(); ++i) { 614 for (ValueVector::iterator i(list_.begin()); i != list_.end(); ++i) {
615 if ((*i)->Equals(&value)) { 615 if ((*i)->Equals(&value)) {
616 size_t index = i - list_.begin();
616 list_.erase(i); 617 list_.erase(i);
617 break; 618 return index;
618 } 619 }
619 } 620 }
621 return -1;
620 } 622 }
621 623
622 void ListValue::Append(Value* in_value) { 624 void ListValue::Append(Value* in_value) {
623 DCHECK(in_value); 625 DCHECK(in_value);
624 list_.push_back(in_value); 626 list_.push_back(in_value);
625 } 627 }
626 628
629 bool ListValue::Insert(size_t index, Value* in_value) {
630 DCHECK(in_value);
631 if (index < 0 || index > list_.size())
632 return false;
633
634 list_.insert(list_.begin() + index, in_value);
635 return true;
636 }
637
627 Value* ListValue::DeepCopy() const { 638 Value* ListValue::DeepCopy() const {
628 ListValue* result = new ListValue; 639 ListValue* result = new ListValue;
629 640
630 for (ValueVector::const_iterator i(list_.begin()); i != list_.end(); ++i) 641 for (ValueVector::const_iterator i(list_.begin()); i != list_.end(); ++i)
631 result->Append((*i)->DeepCopy()); 642 result->Append((*i)->DeepCopy());
632 643
633 return result; 644 return result;
634 } 645 }
635 646
636 bool ListValue::Equals(const Value* other) const { 647 bool ListValue::Equals(const Value* other) const {
637 if (other->GetType() != GetType()) 648 if (other->GetType() != GetType())
638 return false; 649 return false;
639 650
640 const ListValue* other_list = 651 const ListValue* other_list =
641 static_cast<const ListValue*>(other); 652 static_cast<const ListValue*>(other);
642 const_iterator lhs_it, rhs_it; 653 const_iterator lhs_it, rhs_it;
643 for (lhs_it = begin(), rhs_it = other_list->begin(); 654 for (lhs_it = begin(), rhs_it = other_list->begin();
644 lhs_it != end() && rhs_it != other_list->end(); 655 lhs_it != end() && rhs_it != other_list->end();
645 ++lhs_it, ++rhs_it) { 656 ++lhs_it, ++rhs_it) {
646 if (!(*lhs_it)->Equals(*rhs_it)) 657 if (!(*lhs_it)->Equals(*rhs_it))
647 return false; 658 return false;
648 } 659 }
649 if (lhs_it != end() || rhs_it != other_list->end()) 660 if (lhs_it != end() || rhs_it != other_list->end())
650 return false; 661 return false;
651 662
652 return true; 663 return true;
653 } 664 }
OLDNEW
« no previous file with comments | « base/values.h ('k') | chrome/browser/browser_about_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698