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

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: revert a change in bookmarks_helper.cc that colides with a wstring and cq does not like that 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 = GetBookmarkNodeByID(bb_model_, node->value);
212 if (!b_node->empty() && 212 if (!b_node->empty() &&
213 !chrome::ConfirmDeleteBookmarkNode(b_node, 213 !chrome::ConfirmDeleteBookmarkNode(b_node,
214 GetWidget()->GetNativeWindow())) { 214 GetWidget()->GetNativeWindow())) {
215 // The folder is not empty and the user didn't confirm. 215 // The folder is not empty and the user didn't confirm.
216 return; 216 return;
217 } 217 }
218 deletes_.push_back(node->value); 218 deletes_.push_back(node->value);
219 } 219 }
220 tree_model_->Remove(node->parent(), node); 220 tree_model_->Remove(node->parent(), node);
221 } else { 221 } else {
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 parent_b_node, parent_bb_node); 601 parent_b_node, parent_bb_node);
602 } 602 }
603 } 603 }
604 604
605 void BookmarkEditorView::UpdateExpandedNodes( 605 void BookmarkEditorView::UpdateExpandedNodes(
606 EditorNode* editor_node, 606 EditorNode* editor_node,
607 BookmarkExpandedStateTracker::Nodes* expanded_nodes) { 607 BookmarkExpandedStateTracker::Nodes* expanded_nodes) {
608 if (!tree_view_->IsExpanded(editor_node)) 608 if (!tree_view_->IsExpanded(editor_node))
609 return; 609 return;
610 610
611 if (editor_node->value != 0) // The root is 0 611 if (editor_node->value != 0) // The root is 0.
612 expanded_nodes->insert(bb_model_->GetNodeByID(editor_node->value)); 612 expanded_nodes->insert(GetBookmarkNodeByID(bb_model_, editor_node->value));
613
613 for (int i = 0; i < editor_node->child_count(); ++i) 614 for (int i = 0; i < editor_node->child_count(); ++i)
614 UpdateExpandedNodes(editor_node->GetChild(i), expanded_nodes); 615 UpdateExpandedNodes(editor_node->GetChild(i), expanded_nodes);
615 } 616 }
616 617
617 ui::SimpleMenuModel* BookmarkEditorView::GetMenuModel() { 618 ui::SimpleMenuModel* BookmarkEditorView::GetMenuModel() {
618 if (!context_menu_model_.get()) { 619 if (!context_menu_model_.get()) {
619 context_menu_model_.reset(new ui::SimpleMenuModel(this)); 620 context_menu_model_.reset(new ui::SimpleMenuModel(this));
620 context_menu_model_->AddItemWithStringId(IDS_EDIT, IDS_EDIT); 621 context_menu_model_->AddItemWithStringId(IDS_EDIT, IDS_EDIT);
621 context_menu_model_->AddItemWithStringId(IDS_DELETE, IDS_DELETE); 622 context_menu_model_->AddItemWithStringId(IDS_DELETE, IDS_DELETE);
622 context_menu_model_->AddItemWithStringId( 623 context_menu_model_->AddItemWithStringId(
623 IDS_BOOKMARK_EDITOR_NEW_FOLDER_MENU_ITEM, 624 IDS_BOOKMARK_EDITOR_NEW_FOLDER_MENU_ITEM,
624 IDS_BOOKMARK_EDITOR_NEW_FOLDER_MENU_ITEM); 625 IDS_BOOKMARK_EDITOR_NEW_FOLDER_MENU_ITEM);
625 } 626 }
626 return context_menu_model_.get(); 627 return context_menu_model_.get();
627 } 628 }
628 629
629 void BookmarkEditorView::EditorTreeModel::SetTitle( 630 void BookmarkEditorView::EditorTreeModel::SetTitle(
630 ui::TreeModelNode* node, 631 ui::TreeModelNode* node,
631 const base::string16& title) { 632 const base::string16& title) {
632 if (!title.empty()) 633 if (!title.empty())
633 ui::TreeNodeModel<EditorNode>::SetTitle(node, title); 634 ui::TreeNodeModel<EditorNode>::SetTitle(node, title);
634 } 635 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698