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

Side by Side Diff: chrome/browser/ui/views/bookmarks/bookmark_editor_view.cc

Issue 242823002: Extract GetNodeByID() method from BookmarkModel. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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 (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/views/bookmarks/bookmark_editor_view.h" 5 #include "chrome/browser/ui/views/bookmarks/bookmark_editor_view.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 201
202 void BookmarkEditorView::ExecuteCommand(int command_id, int event_flags) { 202 void BookmarkEditorView::ExecuteCommand(int command_id, int event_flags) {
203 DCHECK(tree_view_->GetSelectedNode()); 203 DCHECK(tree_view_->GetSelectedNode());
204 if (command_id == IDS_EDIT) { 204 if (command_id == IDS_EDIT) {
205 tree_view_->StartEditing(tree_view_->GetSelectedNode()); 205 tree_view_->StartEditing(tree_view_->GetSelectedNode());
206 } else if (command_id == IDS_DELETE) { 206 } else if (command_id == IDS_DELETE) {
207 EditorNode* node = tree_model_->AsNode(tree_view_->GetSelectedNode()); 207 EditorNode* node = tree_model_->AsNode(tree_view_->GetSelectedNode());
208 if (!node) 208 if (!node)
209 return; 209 return;
210 if (node->value != 0) { 210 if (node->value != 0) {
211 const BookmarkNode* b_node = bb_model_->GetNodeByID(node->value); 211 const BookmarkNode* b_node =
212 bookmark_utils::GetNodeByID(bb_model_, node->value);
212 if (!b_node->empty() && 213 if (!b_node->empty() &&
213 !chrome::ConfirmDeleteBookmarkNode(b_node, 214 !chrome::ConfirmDeleteBookmarkNode(b_node,
214 GetWidget()->GetNativeWindow())) { 215 GetWidget()->GetNativeWindow())) {
215 // The folder is not empty and the user didn't confirm. 216 // The folder is not empty and the user didn't confirm.
216 return; 217 return;
217 } 218 }
218 deletes_.push_back(node->value); 219 deletes_.push_back(node->value);
219 } 220 }
220 tree_model_->Remove(node->parent(), node); 221 tree_model_->Remove(node->parent(), node);
221 } else { 222 } else {
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 parent_b_node, parent_bb_node); 602 parent_b_node, parent_bb_node);
602 } 603 }
603 } 604 }
604 605
605 void BookmarkEditorView::UpdateExpandedNodes( 606 void BookmarkEditorView::UpdateExpandedNodes(
606 EditorNode* editor_node, 607 EditorNode* editor_node,
607 BookmarkExpandedStateTracker::Nodes* expanded_nodes) { 608 BookmarkExpandedStateTracker::Nodes* expanded_nodes) {
608 if (!tree_view_->IsExpanded(editor_node)) 609 if (!tree_view_->IsExpanded(editor_node))
609 return; 610 return;
610 611
611 if (editor_node->value != 0) // The root is 0 612 // The root is 0.
612 expanded_nodes->insert(bb_model_->GetNodeByID(editor_node->value)); 613 if (editor_node->value != 0) {
614 expanded_nodes->insert(
615 bookmark_utils::GetNodeByID(bb_model_, editor_node->value));
616 }
613 for (int i = 0; i < editor_node->child_count(); ++i) 617 for (int i = 0; i < editor_node->child_count(); ++i)
614 UpdateExpandedNodes(editor_node->GetChild(i), expanded_nodes); 618 UpdateExpandedNodes(editor_node->GetChild(i), expanded_nodes);
615 } 619 }
616 620
617 ui::SimpleMenuModel* BookmarkEditorView::GetMenuModel() { 621 ui::SimpleMenuModel* BookmarkEditorView::GetMenuModel() {
618 if (!context_menu_model_.get()) { 622 if (!context_menu_model_.get()) {
619 context_menu_model_.reset(new ui::SimpleMenuModel(this)); 623 context_menu_model_.reset(new ui::SimpleMenuModel(this));
620 context_menu_model_->AddItemWithStringId(IDS_EDIT, IDS_EDIT); 624 context_menu_model_->AddItemWithStringId(IDS_EDIT, IDS_EDIT);
621 context_menu_model_->AddItemWithStringId(IDS_DELETE, IDS_DELETE); 625 context_menu_model_->AddItemWithStringId(IDS_DELETE, IDS_DELETE);
622 context_menu_model_->AddItemWithStringId( 626 context_menu_model_->AddItemWithStringId(
623 IDS_BOOKMARK_EDITOR_NEW_FOLDER_MENU_ITEM, 627 IDS_BOOKMARK_EDITOR_NEW_FOLDER_MENU_ITEM,
624 IDS_BOOKMARK_EDITOR_NEW_FOLDER_MENU_ITEM); 628 IDS_BOOKMARK_EDITOR_NEW_FOLDER_MENU_ITEM);
625 } 629 }
626 return context_menu_model_.get(); 630 return context_menu_model_.get();
627 } 631 }
628 632
629 void BookmarkEditorView::EditorTreeModel::SetTitle( 633 void BookmarkEditorView::EditorTreeModel::SetTitle(
630 ui::TreeModelNode* node, 634 ui::TreeModelNode* node,
631 const base::string16& title) { 635 const base::string16& title) {
632 if (!title.empty()) 636 if (!title.empty())
633 ui::TreeNodeModel<EditorNode>::SetTitle(node, title); 637 ui::TreeNodeModel<EditorNode>::SetTitle(node, title);
634 } 638 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698