OLD | NEW |
---|---|
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 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
103 int index, | 103 int index, |
104 std::unique_ptr<BookmarkNode> node) override {} | 104 std::unique_ptr<BookmarkNode> node) override {} |
105 | 105 |
106 DISALLOW_COPY_AND_ASSIGN(EmptyUndoDelegate); | 106 DISALLOW_COPY_AND_ASSIGN(EmptyUndoDelegate); |
107 }; | 107 }; |
108 | 108 |
109 } // namespace | 109 } // namespace |
110 | 110 |
111 // BookmarkModel -------------------------------------------------------------- | 111 // BookmarkModel -------------------------------------------------------------- |
112 | 112 |
113 const int64_t BookmarkModel::BOOKMARKS_BAR_NODE_ID = 1; | |
sky
2017/05/25 18:07:05
Rather than exposing these, how about using bookma
calamity
2017/05/26 03:33:34
Done.
| |
114 const int64_t BookmarkModel::OTHER_BOOKMARKS_NODE_ID = 2; | |
115 const int64_t BookmarkModel::MOBILE_BOOKMARKS_NODE_ID = 3; | |
116 | |
113 BookmarkModel::BookmarkModel(std::unique_ptr<BookmarkClient> client) | 117 BookmarkModel::BookmarkModel(std::unique_ptr<BookmarkClient> client) |
114 : client_(std::move(client)), | 118 : client_(std::move(client)), |
115 loaded_(false), | 119 loaded_(false), |
116 root_(GURL()), | 120 root_(GURL()), |
117 bookmark_bar_node_(NULL), | 121 bookmark_bar_node_(NULL), |
118 other_node_(NULL), | 122 other_node_(NULL), |
119 mobile_node_(NULL), | 123 mobile_node_(NULL), |
120 next_node_id_(1), | 124 next_node_id_(1), |
121 observers_( | 125 observers_( |
122 base::ObserverList<BookmarkModelObserver>::NOTIFY_EXISTING_ONLY), | 126 base::ObserverList<BookmarkModelObserver>::NOTIFY_EXISTING_ONLY), |
(...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1016 type == BookmarkNode::OTHER_NODE || | 1020 type == BookmarkNode::OTHER_NODE || |
1017 type == BookmarkNode::MOBILE); | 1021 type == BookmarkNode::MOBILE); |
1018 BookmarkPermanentNode* node = | 1022 BookmarkPermanentNode* node = |
1019 new BookmarkPermanentNode(generate_next_node_id()); | 1023 new BookmarkPermanentNode(generate_next_node_id()); |
1020 node->set_type(type); | 1024 node->set_type(type); |
1021 node->set_visible(client_->IsPermanentNodeVisible(node)); | 1025 node->set_visible(client_->IsPermanentNodeVisible(node)); |
1022 | 1026 |
1023 int title_id; | 1027 int title_id; |
1024 switch (type) { | 1028 switch (type) { |
1025 case BookmarkNode::BOOKMARK_BAR: | 1029 case BookmarkNode::BOOKMARK_BAR: |
1030 DCHECK_EQ(BOOKMARKS_BAR_NODE_ID, node->id()); | |
1026 title_id = IDS_BOOKMARK_BAR_FOLDER_NAME; | 1031 title_id = IDS_BOOKMARK_BAR_FOLDER_NAME; |
1027 break; | 1032 break; |
1028 case BookmarkNode::OTHER_NODE: | 1033 case BookmarkNode::OTHER_NODE: |
1034 DCHECK_EQ(OTHER_BOOKMARKS_NODE_ID, node->id()); | |
1029 title_id = IDS_BOOKMARK_BAR_OTHER_FOLDER_NAME; | 1035 title_id = IDS_BOOKMARK_BAR_OTHER_FOLDER_NAME; |
1030 break; | 1036 break; |
1031 case BookmarkNode::MOBILE: | 1037 case BookmarkNode::MOBILE: |
1038 DCHECK_EQ(MOBILE_BOOKMARKS_NODE_ID, node->id()); | |
1032 title_id = IDS_BOOKMARK_BAR_MOBILE_FOLDER_NAME; | 1039 title_id = IDS_BOOKMARK_BAR_MOBILE_FOLDER_NAME; |
1033 break; | 1040 break; |
1034 default: | 1041 default: |
1035 NOTREACHED(); | 1042 NOTREACHED(); |
1036 title_id = IDS_BOOKMARK_BAR_FOLDER_NAME; | 1043 title_id = IDS_BOOKMARK_BAR_FOLDER_NAME; |
1037 break; | 1044 break; |
1038 } | 1045 } |
1039 node->SetTitle(l10n_util::GetStringUTF16(title_id)); | 1046 node->SetTitle(l10n_util::GetStringUTF16(title_id)); |
1040 return node; | 1047 return node; |
1041 } | 1048 } |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1123 undo_delegate_ = undo_delegate; | 1130 undo_delegate_ = undo_delegate; |
1124 if (undo_delegate_) | 1131 if (undo_delegate_) |
1125 undo_delegate_->SetUndoProvider(this); | 1132 undo_delegate_->SetUndoProvider(this); |
1126 } | 1133 } |
1127 | 1134 |
1128 BookmarkUndoDelegate* BookmarkModel::undo_delegate() const { | 1135 BookmarkUndoDelegate* BookmarkModel::undo_delegate() const { |
1129 return undo_delegate_ ? undo_delegate_ : empty_undo_delegate_.get(); | 1136 return undo_delegate_ ? undo_delegate_ : empty_undo_delegate_.get(); |
1130 } | 1137 } |
1131 | 1138 |
1132 } // namespace bookmarks | 1139 } // namespace bookmarks |
OLD | NEW |