| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/bookmarks/recently_used_folders_combo_model.h" | 5 #include "chrome/browser/bookmarks/recently_used_folders_combo_model.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "chrome/browser/bookmarks/bookmark_utils.h" | 8 #include "chrome/browser/bookmarks/bookmark_utils.h" |
| 9 #include "grit/generated_resources.h" | 9 #include "grit/generated_resources.h" |
| 10 | 10 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 // And put the bookmark bar and other nodes at the end of the list. | 42 // And put the bookmark bar and other nodes at the end of the list. |
| 43 nodes_.push_back(model->GetBookmarkBarNode()); | 43 nodes_.push_back(model->GetBookmarkBarNode()); |
| 44 nodes_.push_back(model->other_node()); | 44 nodes_.push_back(model->other_node()); |
| 45 | 45 |
| 46 std::vector<const BookmarkNode*>::iterator it = std::find(nodes_.begin(), | 46 std::vector<const BookmarkNode*>::iterator it = std::find(nodes_.begin(), |
| 47 nodes_.end(), | 47 nodes_.end(), |
| 48 node->GetParent()); | 48 node->GetParent()); |
| 49 node_parent_index_ = static_cast<int>(it - nodes_.begin()); | 49 node_parent_index_ = static_cast<int>(it - nodes_.begin()); |
| 50 } | 50 } |
| 51 | 51 |
| 52 RecentlyUsedFoldersComboModel::~RecentlyUsedFoldersComboModel() {} |
| 53 |
| 52 int RecentlyUsedFoldersComboModel::GetItemCount() { | 54 int RecentlyUsedFoldersComboModel::GetItemCount() { |
| 53 return static_cast<int>(nodes_.size() + 1); | 55 return static_cast<int>(nodes_.size() + 1); |
| 54 } | 56 } |
| 55 | 57 |
| 56 string16 RecentlyUsedFoldersComboModel::GetItemAt(int index) { | 58 string16 RecentlyUsedFoldersComboModel::GetItemAt(int index) { |
| 57 if (index == static_cast<int>(nodes_.size())) | 59 if (index == static_cast<int>(nodes_.size())) |
| 58 return l10n_util::GetStringUTF16(IDS_BOOMARK_BUBBLE_CHOOSER_ANOTHER_FOLDER); | 60 return l10n_util::GetStringUTF16(IDS_BOOMARK_BUBBLE_CHOOSER_ANOTHER_FOLDER); |
| 59 return nodes_[index]->GetTitle(); | 61 return nodes_[index]->GetTitle(); |
| 60 } | 62 } |
| 61 | 63 |
| 62 const BookmarkNode* RecentlyUsedFoldersComboModel::GetNodeAt(int index) { | 64 const BookmarkNode* RecentlyUsedFoldersComboModel::GetNodeAt(int index) { |
| 63 if (index < 0 || index >= static_cast<int>(nodes_.size())) | 65 if (index < 0 || index >= static_cast<int>(nodes_.size())) |
| 64 return NULL; | 66 return NULL; |
| 65 return nodes_[index]; | 67 return nodes_[index]; |
| 66 } | 68 } |
| 67 | 69 |
| 68 void RecentlyUsedFoldersComboModel::RemoveNode(const BookmarkNode* node) { | 70 void RecentlyUsedFoldersComboModel::RemoveNode(const BookmarkNode* node) { |
| 69 std::vector<const BookmarkNode*>::iterator it = std::find(nodes_.begin(), | 71 std::vector<const BookmarkNode*>::iterator it = std::find(nodes_.begin(), |
| 70 nodes_.end(), | 72 nodes_.end(), |
| 71 node); | 73 node); |
| 72 if (it != nodes_.end()) | 74 if (it != nodes_.end()) |
| 73 nodes_.erase(it); | 75 nodes_.erase(it); |
| 74 } | 76 } |
| OLD | NEW |