OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/bookmarks/recently_used_folders_combo_model.h" | 5 #include "chrome/browser/ui/bookmarks/recently_used_folders_combo_model.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
| 9 #include "base/metrics/user_metrics.h" |
9 #include "chrome/grit/generated_resources.h" | 10 #include "chrome/grit/generated_resources.h" |
10 #include "components/bookmarks/browser/bookmark_model.h" | 11 #include "components/bookmarks/browser/bookmark_model.h" |
11 #include "components/bookmarks/browser/bookmark_utils.h" | 12 #include "components/bookmarks/browser/bookmark_utils.h" |
12 #include "content/public/browser/user_metrics.h" | |
13 #include "ui/base/l10n/l10n_util.h" | 13 #include "ui/base/l10n/l10n_util.h" |
14 #include "ui/base/models/combobox_model_observer.h" | 14 #include "ui/base/models/combobox_model_observer.h" |
15 | 15 |
16 using bookmarks::BookmarkModel; | 16 using bookmarks::BookmarkModel; |
17 using bookmarks::BookmarkNode; | 17 using bookmarks::BookmarkNode; |
18 | 18 |
19 namespace { | 19 namespace { |
20 | 20 |
21 // Max number of most recently used folders. | 21 // Max number of most recently used folders. |
22 const size_t kMaxMRUFolders = 5; | 22 const size_t kMaxMRUFolders = 5; |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 } | 226 } |
227 | 227 |
228 void RecentlyUsedFoldersComboModel::MaybeChangeParent( | 228 void RecentlyUsedFoldersComboModel::MaybeChangeParent( |
229 const BookmarkNode* node, | 229 const BookmarkNode* node, |
230 int selected_index) { | 230 int selected_index) { |
231 if (items_[selected_index].type != Item::TYPE_NODE) | 231 if (items_[selected_index].type != Item::TYPE_NODE) |
232 return; | 232 return; |
233 | 233 |
234 const BookmarkNode* new_parent = GetNodeAt(selected_index); | 234 const BookmarkNode* new_parent = GetNodeAt(selected_index); |
235 if (new_parent != node->parent()) { | 235 if (new_parent != node->parent()) { |
236 content::RecordAction( | 236 base::RecordAction(base::UserMetricsAction("BookmarkBubble_ChangeParent")); |
237 base::UserMetricsAction("BookmarkBubble_ChangeParent")); | |
238 bookmark_model_->Move(node, new_parent, new_parent->child_count()); | 237 bookmark_model_->Move(node, new_parent, new_parent->child_count()); |
239 } | 238 } |
240 } | 239 } |
241 | 240 |
242 const BookmarkNode* RecentlyUsedFoldersComboModel::GetNodeAt(int index) { | 241 const BookmarkNode* RecentlyUsedFoldersComboModel::GetNodeAt(int index) { |
243 if (index < 0 || index >= static_cast<int>(items_.size())) | 242 if (index < 0 || index >= static_cast<int>(items_.size())) |
244 return NULL; | 243 return NULL; |
245 return items_[index].node; | 244 return items_[index].node; |
246 } | 245 } |
247 | 246 |
248 void RecentlyUsedFoldersComboModel::RemoveNode(const BookmarkNode* node) { | 247 void RecentlyUsedFoldersComboModel::RemoveNode(const BookmarkNode* node) { |
249 std::vector<Item>::iterator it = std::find(items_.begin(), | 248 std::vector<Item>::iterator it = std::find(items_.begin(), |
250 items_.end(), | 249 items_.end(), |
251 Item(node, Item::TYPE_NODE)); | 250 Item(node, Item::TYPE_NODE)); |
252 if (it != items_.end()) | 251 if (it != items_.end()) |
253 items_.erase(it); | 252 items_.erase(it); |
254 } | 253 } |
OLD | NEW |