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

Side by Side Diff: components/bookmarks/browser/bookmark_model.cc

Issue 305973004: BookmarkClient can add extra nodes to BookmarkModel. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/bookmarks/browser/bookmark_model.h" 5 #include "components/bookmarks/browser/bookmark_model.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/bind_helpers.h" 11 #include "base/bind_helpers.h"
12 #include "base/i18n/string_compare.h" 12 #include "base/i18n/string_compare.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
16 #include "base/values.h"
16 #include "components/bookmarks/browser/bookmark_expanded_state_tracker.h" 17 #include "components/bookmarks/browser/bookmark_expanded_state_tracker.h"
17 #include "components/bookmarks/browser/bookmark_index.h" 18 #include "components/bookmarks/browser/bookmark_index.h"
18 #include "components/bookmarks/browser/bookmark_match.h" 19 #include "components/bookmarks/browser/bookmark_match.h"
19 #include "components/bookmarks/browser/bookmark_model_observer.h" 20 #include "components/bookmarks/browser/bookmark_model_observer.h"
20 #include "components/bookmarks/browser/bookmark_node_data.h" 21 #include "components/bookmarks/browser/bookmark_node_data.h"
21 #include "components/bookmarks/browser/bookmark_storage.h" 22 #include "components/bookmarks/browser/bookmark_storage.h"
22 #include "components/bookmarks/browser/bookmark_utils.h" 23 #include "components/bookmarks/browser/bookmark_utils.h"
24 #include "components/bookmarks/browser/managed_bookmarks_tracker.h"
23 #include "components/favicon_base/favicon_types.h" 25 #include "components/favicon_base/favicon_types.h"
24 #include "grit/components_strings.h" 26 #include "grit/components_strings.h"
25 #include "ui/base/l10n/l10n_util.h" 27 #include "ui/base/l10n/l10n_util.h"
26 #include "ui/gfx/favicon_size.h" 28 #include "ui/gfx/favicon_size.h"
27 29
28 using base::Time; 30 using base::Time;
29 using bookmarks::BookmarkLoadDetails; 31 using bookmarks::BookmarkLoadDetails;
30 using bookmarks::BookmarkStorage; 32 using bookmarks::BookmarkStorage;
31 33
32 namespace { 34 namespace {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 93
92 // BookmarkModel -------------------------------------------------------------- 94 // BookmarkModel --------------------------------------------------------------
93 95
94 BookmarkModel::BookmarkModel(BookmarkClient* client, bool index_urls) 96 BookmarkModel::BookmarkModel(BookmarkClient* client, bool index_urls)
95 : client_(client), 97 : client_(client),
96 loaded_(false), 98 loaded_(false),
97 root_(GURL()), 99 root_(GURL()),
98 bookmark_bar_node_(NULL), 100 bookmark_bar_node_(NULL),
99 other_node_(NULL), 101 other_node_(NULL),
100 mobile_node_(NULL), 102 mobile_node_(NULL),
103 managed_node_(NULL),
101 next_node_id_(1), 104 next_node_id_(1),
102 observers_(ObserverList<BookmarkModelObserver>::NOTIFY_EXISTING_ONLY), 105 observers_(ObserverList<BookmarkModelObserver>::NOTIFY_EXISTING_ONLY),
103 index_urls_(index_urls), 106 index_urls_(index_urls),
104 loaded_signal_(true, false), 107 loaded_signal_(true, false),
105 extensive_changes_(0) { 108 extensive_changes_(0) {
106 DCHECK(client_); 109 DCHECK(client_);
107 } 110 }
108 111
109 BookmarkModel::~BookmarkModel() { 112 BookmarkModel::~BookmarkModel() {
110 FOR_EACH_OBSERVER(BookmarkModelObserver, observers_, 113 FOR_EACH_OBSERVER(BookmarkModelObserver, observers_,
(...skipping 23 matching lines...) Expand all
134 const scoped_refptr<base::SequencedTaskRunner>& ui_task_runner) { 137 const scoped_refptr<base::SequencedTaskRunner>& ui_task_runner) {
135 if (store_.get()) { 138 if (store_.get()) {
136 // If the store is non-null, it means Load was already invoked. Load should 139 // If the store is non-null, it means Load was already invoked. Load should
137 // only be invoked once. 140 // only be invoked once.
138 NOTREACHED(); 141 NOTREACHED();
139 return; 142 return;
140 } 143 }
141 144
142 expanded_state_tracker_.reset( 145 expanded_state_tracker_.reset(
143 new BookmarkExpandedStateTracker(this, pref_service)); 146 new BookmarkExpandedStateTracker(this, pref_service));
147 managed_bookmarks_tracker_.reset(
148 new ManagedBookmarksTracker(this, pref_service));
144 149
145 // Load the bookmarks. BookmarkStorage notifies us when done. 150 // Load the bookmarks. BookmarkStorage notifies us when done.
146 store_ = new BookmarkStorage(this, profile_path, io_task_runner.get()); 151 store_ = new BookmarkStorage(this, profile_path, io_task_runner.get());
147 store_->LoadBookmarks(CreateLoadDetails(accept_languages), ui_task_runner); 152 store_->LoadBookmarks(
153 CreateLoadDetails(accept_languages),
154 managed_bookmarks_tracker_->GetInitialManagedBookmarks(),
155 ui_task_runner);
156 }
157
158 bool BookmarkModel::IsManaged(const BookmarkNode* node) const {
159 DCHECK(loaded_);
160 while (node && node != managed_node())
161 node = node->parent();
162 return node == managed_node();
148 } 163 }
149 164
150 const BookmarkNode* BookmarkModel::GetParentForNewNodes() { 165 const BookmarkNode* BookmarkModel::GetParentForNewNodes() {
151 std::vector<const BookmarkNode*> nodes = 166 std::vector<const BookmarkNode*> nodes =
152 bookmark_utils::GetMostRecentlyModifiedFolders(this, 1); 167 bookmark_utils::GetMostRecentlyModifiedFolders(this, 1);
153 DCHECK(!nodes.empty()); // This list is always padded with default folders. 168 DCHECK(!nodes.empty()); // This list is always padded with default folders.
154 return nodes[0]; 169 return nodes[0];
155 } 170 }
156 171
157 void BookmarkModel::AddObserver(BookmarkModelObserver* observer) { 172 void BookmarkModel::AddObserver(BookmarkModelObserver* observer) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 OnWillRemoveAllBookmarks(this)); 219 OnWillRemoveAllBookmarks(this));
205 220
206 BeginExtensiveChanges(); 221 BeginExtensiveChanges();
207 // Skip deleting permanent nodes. Permanent bookmark nodes are the root and 222 // Skip deleting permanent nodes. Permanent bookmark nodes are the root and
208 // its immediate children. For removing all non permanent nodes just remove 223 // its immediate children. For removing all non permanent nodes just remove
209 // all children of non-root permanent nodes. 224 // all children of non-root permanent nodes.
210 { 225 {
211 base::AutoLock url_lock(url_lock_); 226 base::AutoLock url_lock(url_lock_);
212 for (int i = 0; i < root_.child_count(); ++i) { 227 for (int i = 0; i < root_.child_count(); ++i) {
213 BookmarkNode* permanent_node = root_.GetChild(i); 228 BookmarkNode* permanent_node = root_.GetChild(i);
229
230 // The managed bookmarks can't be removed.
sky 2014/05/30 22:31:37 Not removing managed bookmarks makes this function
Joao da Silva 2014/06/01 13:32:07 Agreed, I'll rename in a subsequent CL.
231 if (permanent_node == managed_node())
232 continue;
233
214 for (int j = permanent_node->child_count() - 1; j >= 0; --j) { 234 for (int j = permanent_node->child_count() - 1; j >= 0; --j) {
215 BookmarkNode* child_node = permanent_node->GetChild(j); 235 BookmarkNode* child_node = permanent_node->GetChild(j);
216 removed_nodes.push_back(child_node); 236 removed_nodes.push_back(child_node);
217 RemoveNodeAndGetRemovedUrls(child_node, &removed_urls); 237 RemoveNodeAndGetRemovedUrls(child_node, &removed_urls);
218 } 238 }
219 } 239 }
220 } 240 }
221 EndExtensiveChanges(); 241 EndExtensiveChanges();
222 if (store_.get()) 242 if (store_.get())
223 store_->ScheduleSave(); 243 store_->ScheduleSave();
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 331
312 void BookmarkModel::SetTitle(const BookmarkNode* node, 332 void BookmarkModel::SetTitle(const BookmarkNode* node,
313 const base::string16& title) { 333 const base::string16& title) {
314 if (!node) { 334 if (!node) {
315 NOTREACHED(); 335 NOTREACHED();
316 return; 336 return;
317 } 337 }
318 if (node->GetTitle() == title) 338 if (node->GetTitle() == title)
319 return; 339 return;
320 340
321 if (is_permanent_node(node)) { 341 // The managed node can change its title.
sky 2014/05/30 22:31:37 Why do we want to allow the managed nodes title to
Joao da Silva 2014/06/01 13:32:07 This was the UX decision when we first introduced
342 if (is_permanent_node(node) && node != managed_node()) {
322 NOTREACHED(); 343 NOTREACHED();
323 return; 344 return;
324 } 345 }
325 346
326 FOR_EACH_OBSERVER(BookmarkModelObserver, observers_, 347 FOR_EACH_OBSERVER(BookmarkModelObserver, observers_,
327 OnWillChangeBookmarkNode(this, node)); 348 OnWillChangeBookmarkNode(this, node));
328 349
329 // The title index doesn't support changing the title, instead we remove then 350 // The title index doesn't support changing the title, instead we remove then
330 // add it back. 351 // add it back.
331 index_->Remove(node); 352 index_->Remove(node);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 if (AsMutable(node)->DeleteMetaInfo(key) && store_.get()) 444 if (AsMutable(node)->DeleteMetaInfo(key) && store_.get())
424 store_->ScheduleSave(); 445 store_->ScheduleSave();
425 446
426 FOR_EACH_OBSERVER(BookmarkModelObserver, observers_, 447 FOR_EACH_OBSERVER(BookmarkModelObserver, observers_,
427 BookmarkMetaInfoChanged(this, node)); 448 BookmarkMetaInfoChanged(this, node));
428 } 449 }
429 450
430 void BookmarkModel::SetNodeSyncTransactionVersion( 451 void BookmarkModel::SetNodeSyncTransactionVersion(
431 const BookmarkNode* node, 452 const BookmarkNode* node,
432 int64 sync_transaction_version) { 453 int64 sync_transaction_version) {
454 if (IsManaged(node)) {
455 NOTREACHED();
456 return;
457 }
433 if (sync_transaction_version == node->sync_transaction_version()) 458 if (sync_transaction_version == node->sync_transaction_version())
434 return; 459 return;
435 460
436 AsMutable(node)->set_sync_transaction_version(sync_transaction_version); 461 AsMutable(node)->set_sync_transaction_version(sync_transaction_version);
437 if (store_.get()) 462 if (store_.get())
438 store_->ScheduleSave(); 463 store_->ScheduleSave();
439 } 464 }
440 465
441 void BookmarkModel::OnFaviconChanged(const std::set<GURL>& urls) { 466 void BookmarkModel::OnFaviconChanged(const std::set<GURL>& urls) {
442 // Ignore events if |Load| has not been called yet. 467 // Ignore events if |Load| has not been called yet.
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 636
612 return AddNode(AsMutable(parent), index, new_node); 637 return AddNode(AsMutable(parent), index, new_node);
613 } 638 }
614 639
615 void BookmarkModel::SortChildren(const BookmarkNode* parent) { 640 void BookmarkModel::SortChildren(const BookmarkNode* parent) {
616 if (!parent || !parent->is_folder() || is_root_node(parent) || 641 if (!parent || !parent->is_folder() || is_root_node(parent) ||
617 parent->child_count() <= 1) { 642 parent->child_count() <= 1) {
618 return; 643 return;
619 } 644 }
620 645
646 if (IsManaged(parent)) {
sky 2014/05/30 22:31:37 Should this be a DCHECK? Same with 673 and 454.
Joao da Silva 2014/06/01 13:32:07 Done.
647 NOTREACHED();
648 return;
649 }
650
621 FOR_EACH_OBSERVER(BookmarkModelObserver, observers_, 651 FOR_EACH_OBSERVER(BookmarkModelObserver, observers_,
622 OnWillReorderBookmarkNode(this, parent)); 652 OnWillReorderBookmarkNode(this, parent));
623 653
624 UErrorCode error = U_ZERO_ERROR; 654 UErrorCode error = U_ZERO_ERROR;
625 scoped_ptr<icu::Collator> collator(icu::Collator::createInstance(error)); 655 scoped_ptr<icu::Collator> collator(icu::Collator::createInstance(error));
626 if (U_FAILURE(error)) 656 if (U_FAILURE(error))
627 collator.reset(NULL); 657 collator.reset(NULL);
628 BookmarkNode* mutable_parent = AsMutable(parent); 658 BookmarkNode* mutable_parent = AsMutable(parent);
629 std::sort(mutable_parent->children().begin(), 659 std::sort(mutable_parent->children().begin(),
630 mutable_parent->children().end(), 660 mutable_parent->children().end(),
631 SortComparator(collator.get())); 661 SortComparator(collator.get()));
632 662
633 if (store_.get()) 663 if (store_.get())
634 store_->ScheduleSave(); 664 store_->ScheduleSave();
635 665
636 FOR_EACH_OBSERVER(BookmarkModelObserver, observers_, 666 FOR_EACH_OBSERVER(BookmarkModelObserver, observers_,
637 BookmarkNodeChildrenReordered(this, parent)); 667 BookmarkNodeChildrenReordered(this, parent));
638 } 668 }
639 669
640 void BookmarkModel::ReorderChildren( 670 void BookmarkModel::ReorderChildren(
641 const BookmarkNode* parent, 671 const BookmarkNode* parent,
642 const std::vector<const BookmarkNode*>& ordered_nodes) { 672 const std::vector<const BookmarkNode*>& ordered_nodes) {
673 if (IsManaged(parent)) {
674 NOTREACHED();
675 return;
676 }
677
643 // Ensure that all children in |parent| are in |ordered_nodes|. 678 // Ensure that all children in |parent| are in |ordered_nodes|.
644 DCHECK_EQ(static_cast<size_t>(parent->child_count()), ordered_nodes.size()); 679 DCHECK_EQ(static_cast<size_t>(parent->child_count()), ordered_nodes.size());
645 for (size_t i = 0; i < ordered_nodes.size(); ++i) 680 for (size_t i = 0; i < ordered_nodes.size(); ++i)
646 DCHECK_EQ(parent, ordered_nodes[i]->parent()); 681 DCHECK_EQ(parent, ordered_nodes[i]->parent());
647 682
648 FOR_EACH_OBSERVER(BookmarkModelObserver, observers_, 683 FOR_EACH_OBSERVER(BookmarkModelObserver, observers_,
649 OnWillReorderBookmarkNode(this, parent)); 684 OnWillReorderBookmarkNode(this, parent));
650 685
651 AsMutable(parent)->SetChildren( 686 AsMutable(parent)->SetChildren(
652 *(reinterpret_cast<const std::vector<BookmarkNode*>*>(&ordered_nodes))); 687 *(reinterpret_cast<const std::vector<BookmarkNode*>*>(&ordered_nodes)));
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 const BookmarkPermanentNode* BookmarkModel::PermanentNode( 729 const BookmarkPermanentNode* BookmarkModel::PermanentNode(
695 BookmarkNode::Type type) { 730 BookmarkNode::Type type) {
696 DCHECK(loaded_); 731 DCHECK(loaded_);
697 switch (type) { 732 switch (type) {
698 case BookmarkNode::BOOKMARK_BAR: 733 case BookmarkNode::BOOKMARK_BAR:
699 return bookmark_bar_node_; 734 return bookmark_bar_node_;
700 case BookmarkNode::OTHER_NODE: 735 case BookmarkNode::OTHER_NODE:
701 return other_node_; 736 return other_node_;
702 case BookmarkNode::MOBILE: 737 case BookmarkNode::MOBILE:
703 return mobile_node_; 738 return mobile_node_;
739 case BookmarkNode::MANAGED:
740 return managed_node_;
704 default: 741 default:
705 NOTREACHED(); 742 NOTREACHED();
706 return NULL; 743 return NULL;
707 } 744 }
708 } 745 }
709 746
710 bool BookmarkModel::IsBookmarkedNoLock(const GURL& url) { 747 bool BookmarkModel::IsBookmarkedNoLock(const GURL& url) {
711 BookmarkNode tmp_node(url); 748 BookmarkNode tmp_node(url);
712 return (nodes_ordered_by_url_set_.find(&tmp_node) != 749 return (nodes_ordered_by_url_set_.find(&tmp_node) !=
713 nodes_ordered_by_url_set_.end()); 750 nodes_ordered_by_url_set_.end());
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 // If bookmarks file changed externally, the IDs may have changed 785 // If bookmarks file changed externally, the IDs may have changed
749 // externally. In that case, the decoder may have reassigned IDs to make 786 // externally. In that case, the decoder may have reassigned IDs to make
750 // them unique. So when the file has changed externally, we should save the 787 // them unique. So when the file has changed externally, we should save the
751 // bookmarks file to persist new IDs. 788 // bookmarks file to persist new IDs.
752 if (store_.get()) 789 if (store_.get())
753 store_->ScheduleSave(); 790 store_->ScheduleSave();
754 } 791 }
755 bookmark_bar_node_ = details->release_bb_node(); 792 bookmark_bar_node_ = details->release_bb_node();
756 other_node_ = details->release_other_folder_node(); 793 other_node_ = details->release_other_folder_node();
757 mobile_node_ = details->release_mobile_folder_node(); 794 mobile_node_ = details->release_mobile_folder_node();
795 managed_node_ = details->release_managed_node();
758 index_.reset(details->release_index()); 796 index_.reset(details->release_index());
759 797
760 // WARNING: order is important here, various places assume the order is 798 // WARNING: order is important here, various places assume the order is
761 // constant (but can vary between embedders with the initial visibility 799 // constant (but can vary between embedders with the initial visibility
762 // of permanent nodes). 800 // of permanent nodes).
763 BookmarkPermanentNode* root_children[] = { 801 BookmarkPermanentNode* root_children[] = {
764 bookmark_bar_node_, other_node_, mobile_node_, 802 bookmark_bar_node_, other_node_, mobile_node_, managed_node_,
765 }; 803 };
766 std::stable_sort(root_children, 804 std::stable_sort(root_children,
767 root_children + arraysize(root_children), 805 root_children + arraysize(root_children),
768 VisibilityComparator(client_)); 806 VisibilityComparator(client_));
769 for (size_t i = 0; i < arraysize(root_children); ++i) { 807 for (size_t i = 0; i < arraysize(root_children); ++i) {
770 root_.Add(root_children[i], static_cast<int>(i)); 808 root_.Add(root_children[i], static_cast<int>(i));
771 } 809 }
772 810
773 root_.SetMetaInfoMap(details->model_meta_info_map()); 811 root_.SetMetaInfoMap(details->model_meta_info_map());
774 root_.set_sync_transaction_version(details->model_sync_transaction_version()); 812 root_.set_sync_transaction_version(details->model_sync_transaction_version());
775 813
776 { 814 {
777 base::AutoLock url_lock(url_lock_); 815 base::AutoLock url_lock(url_lock_);
778 // Update nodes_ordered_by_url_set_ from the nodes. 816 // Update nodes_ordered_by_url_set_ from the nodes.
779 PopulateNodesByURL(&root_); 817 PopulateNodesByURL(&root_);
780 } 818 }
781 819
782 loaded_ = true; 820 loaded_ = true;
783 821
784 loaded_signal_.Signal(); 822 loaded_signal_.Signal();
785 823
786 // Notify our direct observers. 824 // Notify our direct observers.
787 FOR_EACH_OBSERVER(BookmarkModelObserver, observers_, 825 FOR_EACH_OBSERVER(BookmarkModelObserver, observers_,
788 BookmarkModelLoaded(this, details->ids_reassigned())); 826 BookmarkModelLoaded(this, details->ids_reassigned()));
827
828 // Start tracking the managed bookmarks. This will detect any changes that
829 // may have occurred while the |store_| loaded the initial managed bookmarks.
830 // May be NULL in unit tests.
831 if (managed_bookmarks_tracker_)
832 managed_bookmarks_tracker_->Init();
789 } 833 }
790 834
791 void BookmarkModel::RemoveAndDeleteNode(BookmarkNode* delete_me) { 835 void BookmarkModel::RemoveAndDeleteNode(BookmarkNode* delete_me) {
792 scoped_ptr<BookmarkNode> node(delete_me); 836 scoped_ptr<BookmarkNode> node(delete_me);
793 837
794 const BookmarkNode* parent = node->parent(); 838 const BookmarkNode* parent = node->parent();
795 DCHECK(parent); 839 DCHECK(parent);
796 int index = parent->GetIndexOf(node.get()); 840 int index = parent->GetIndexOf(node.get());
797 841
798 FOR_EACH_OBSERVER(BookmarkModelObserver, observers_, 842 FOR_EACH_OBSERVER(BookmarkModelObserver, observers_,
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 bool allow_end) { 916 bool allow_end) {
873 return (parent && parent->is_folder() && 917 return (parent && parent->is_folder() &&
874 (index >= 0 && (index < parent->child_count() || 918 (index >= 0 && (index < parent->child_count() ||
875 (allow_end && index == parent->child_count())))); 919 (allow_end && index == parent->child_count()))));
876 } 920 }
877 921
878 BookmarkPermanentNode* BookmarkModel::CreatePermanentNode( 922 BookmarkPermanentNode* BookmarkModel::CreatePermanentNode(
879 BookmarkNode::Type type) { 923 BookmarkNode::Type type) {
880 DCHECK(type == BookmarkNode::BOOKMARK_BAR || 924 DCHECK(type == BookmarkNode::BOOKMARK_BAR ||
881 type == BookmarkNode::OTHER_NODE || 925 type == BookmarkNode::OTHER_NODE ||
882 type == BookmarkNode::MOBILE); 926 type == BookmarkNode::MOBILE ||
927 type == BookmarkNode::MANAGED);
883 BookmarkPermanentNode* node = 928 BookmarkPermanentNode* node =
884 new BookmarkPermanentNode(generate_next_node_id()); 929 new BookmarkPermanentNode(generate_next_node_id());
885 node->set_visible(client_->IsPermanentNodeVisible(type)); 930 node->set_visible(client_->IsPermanentNodeVisible(type));
886 931
887 int title_id; 932 int title_id;
888 switch (type) { 933 switch (type) {
889 case BookmarkNode::BOOKMARK_BAR: 934 case BookmarkNode::BOOKMARK_BAR:
890 title_id = IDS_BOOKMARK_BAR_FOLDER_NAME; 935 title_id = IDS_BOOKMARK_BAR_FOLDER_NAME;
891 break; 936 break;
892 case BookmarkNode::OTHER_NODE: 937 case BookmarkNode::OTHER_NODE:
893 title_id = IDS_BOOKMARK_BAR_OTHER_FOLDER_NAME; 938 title_id = IDS_BOOKMARK_BAR_OTHER_FOLDER_NAME;
894 break; 939 break;
895 case BookmarkNode::MOBILE: 940 case BookmarkNode::MOBILE:
896 title_id = IDS_BOOKMARK_BAR_MOBILE_FOLDER_NAME; 941 title_id = IDS_BOOKMARK_BAR_MOBILE_FOLDER_NAME;
897 break; 942 break;
943 case BookmarkNode::MANAGED:
944 title_id = IDS_BOOKMARK_BAR_MANAGED_FOLDER_DEFAULT_NAME;
945 break;
898 default: 946 default:
899 NOTREACHED(); 947 NOTREACHED();
900 title_id = IDS_BOOKMARK_BAR_FOLDER_NAME; 948 title_id = IDS_BOOKMARK_BAR_FOLDER_NAME;
901 break; 949 break;
902 } 950 }
903 node->SetTitle(l10n_util::GetStringUTF16(title_id)); 951 node->SetTitle(l10n_util::GetStringUTF16(title_id));
904 node->set_type(type); 952 node->set_type(type);
905 return node; 953 return node;
906 } 954 }
907 955
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
972 } 1020 }
973 1021
974 scoped_ptr<BookmarkLoadDetails> BookmarkModel::CreateLoadDetails( 1022 scoped_ptr<BookmarkLoadDetails> BookmarkModel::CreateLoadDetails(
975 const std::string& accept_languages) { 1023 const std::string& accept_languages) {
976 BookmarkPermanentNode* bb_node = 1024 BookmarkPermanentNode* bb_node =
977 CreatePermanentNode(BookmarkNode::BOOKMARK_BAR); 1025 CreatePermanentNode(BookmarkNode::BOOKMARK_BAR);
978 BookmarkPermanentNode* other_node = 1026 BookmarkPermanentNode* other_node =
979 CreatePermanentNode(BookmarkNode::OTHER_NODE); 1027 CreatePermanentNode(BookmarkNode::OTHER_NODE);
980 BookmarkPermanentNode* mobile_node = 1028 BookmarkPermanentNode* mobile_node =
981 CreatePermanentNode(BookmarkNode::MOBILE); 1029 CreatePermanentNode(BookmarkNode::MOBILE);
1030 BookmarkPermanentNode* managed_node =
1031 CreatePermanentNode(BookmarkNode::MANAGED);
982 return scoped_ptr<BookmarkLoadDetails>(new BookmarkLoadDetails( 1032 return scoped_ptr<BookmarkLoadDetails>(new BookmarkLoadDetails(
983 bb_node, 1033 bb_node,
984 other_node, 1034 other_node,
985 mobile_node, 1035 mobile_node,
1036 managed_node,
986 new BookmarkIndex(client_, index_urls_, accept_languages), 1037 new BookmarkIndex(client_, index_urls_, accept_languages),
987 next_node_id_)); 1038 next_node_id_));
988 } 1039 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698