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

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

Issue 386283002: Move bookmark_utils into bookmarks namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 205
206 void BookmarkEditorView::ExecuteCommand(int command_id, int event_flags) { 206 void BookmarkEditorView::ExecuteCommand(int command_id, int event_flags) {
207 DCHECK(tree_view_->GetSelectedNode()); 207 DCHECK(tree_view_->GetSelectedNode());
208 if (command_id == IDS_EDIT) { 208 if (command_id == IDS_EDIT) {
209 tree_view_->StartEditing(tree_view_->GetSelectedNode()); 209 tree_view_->StartEditing(tree_view_->GetSelectedNode());
210 } else if (command_id == IDS_DELETE) { 210 } else if (command_id == IDS_DELETE) {
211 EditorNode* node = tree_model_->AsNode(tree_view_->GetSelectedNode()); 211 EditorNode* node = tree_model_->AsNode(tree_view_->GetSelectedNode());
212 if (!node) 212 if (!node)
213 return; 213 return;
214 if (node->value != 0) { 214 if (node->value != 0) {
215 const BookmarkNode* b_node = GetBookmarkNodeByID(bb_model_, node->value); 215 const BookmarkNode* b_node =
216 bookmarks::GetBookmarkNodeByID(bb_model_, node->value);
216 if (!b_node->empty() && 217 if (!b_node->empty() &&
217 !chrome::ConfirmDeleteBookmarkNode(b_node, 218 !chrome::ConfirmDeleteBookmarkNode(b_node,
218 GetWidget()->GetNativeWindow())) { 219 GetWidget()->GetNativeWindow())) {
219 // The folder is not empty and the user didn't confirm. 220 // The folder is not empty and the user didn't confirm.
220 return; 221 return;
221 } 222 }
222 deletes_.push_back(node->value); 223 deletes_.push_back(node->value);
223 } 224 }
224 tree_model_->Remove(node->parent(), node); 225 tree_model_->Remove(node->parent(), node);
225 } else { 226 } else {
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 571
571 BookmarkEditor::ApplyEditsWithPossibleFolderChange( 572 BookmarkEditor::ApplyEditsWithPossibleFolderChange(
572 bb_model_, new_parent, details_, new_title, new_url); 573 bb_model_, new_parent, details_, new_title, new_url);
573 574
574 BookmarkExpandedStateTracker::Nodes expanded_nodes; 575 BookmarkExpandedStateTracker::Nodes expanded_nodes;
575 UpdateExpandedNodes(tree_model_->GetRoot(), &expanded_nodes); 576 UpdateExpandedNodes(tree_model_->GetRoot(), &expanded_nodes);
576 bb_model_->expanded_state_tracker()->SetExpandedNodes(expanded_nodes); 577 bb_model_->expanded_state_tracker()->SetExpandedNodes(expanded_nodes);
577 578
578 // Remove the folders that were removed. This has to be done after all the 579 // Remove the folders that were removed. This has to be done after all the
579 // other changes have been committed. 580 // other changes have been committed.
580 bookmark_utils::DeleteBookmarkFolders(bb_model_, deletes_); 581 bookmarks::DeleteBookmarkFolders(bb_model_, deletes_);
581 } 582 }
582 583
583 void BookmarkEditorView::ApplyNameChangesAndCreateNewFolders( 584 void BookmarkEditorView::ApplyNameChangesAndCreateNewFolders(
584 const BookmarkNode* bb_node, 585 const BookmarkNode* bb_node,
585 BookmarkEditorView::EditorNode* b_node, 586 BookmarkEditorView::EditorNode* b_node,
586 BookmarkEditorView::EditorNode* parent_b_node, 587 BookmarkEditorView::EditorNode* parent_b_node,
587 const BookmarkNode** parent_bb_node) { 588 const BookmarkNode** parent_bb_node) {
588 if (parent_b_node == b_node) 589 if (parent_b_node == b_node)
589 *parent_bb_node = bb_node; 590 *parent_bb_node = bb_node;
590 for (int i = 0; i < b_node->child_count(); ++i) { 591 for (int i = 0; i < b_node->child_count(); ++i) {
(...skipping 21 matching lines...) Expand all
612 parent_b_node, parent_bb_node); 613 parent_b_node, parent_bb_node);
613 } 614 }
614 } 615 }
615 616
616 void BookmarkEditorView::UpdateExpandedNodes( 617 void BookmarkEditorView::UpdateExpandedNodes(
617 EditorNode* editor_node, 618 EditorNode* editor_node,
618 BookmarkExpandedStateTracker::Nodes* expanded_nodes) { 619 BookmarkExpandedStateTracker::Nodes* expanded_nodes) {
619 if (!tree_view_->IsExpanded(editor_node)) 620 if (!tree_view_->IsExpanded(editor_node))
620 return; 621 return;
621 622
622 if (editor_node->value != 0) // The root is 0. 623 // The root is 0.
623 expanded_nodes->insert(GetBookmarkNodeByID(bb_model_, editor_node->value)); 624 if (editor_node->value != 0) {
625 expanded_nodes->insert(
626 bookmarks::GetBookmarkNodeByID(bb_model_, editor_node->value));
627 }
624 628
625 for (int i = 0; i < editor_node->child_count(); ++i) 629 for (int i = 0; i < editor_node->child_count(); ++i)
626 UpdateExpandedNodes(editor_node->GetChild(i), expanded_nodes); 630 UpdateExpandedNodes(editor_node->GetChild(i), expanded_nodes);
627 } 631 }
628 632
629 ui::SimpleMenuModel* BookmarkEditorView::GetMenuModel() { 633 ui::SimpleMenuModel* BookmarkEditorView::GetMenuModel() {
630 if (!context_menu_model_.get()) { 634 if (!context_menu_model_.get()) {
631 context_menu_model_.reset(new ui::SimpleMenuModel(this)); 635 context_menu_model_.reset(new ui::SimpleMenuModel(this));
632 context_menu_model_->AddItemWithStringId(IDS_EDIT, IDS_EDIT); 636 context_menu_model_->AddItemWithStringId(IDS_EDIT, IDS_EDIT);
633 context_menu_model_->AddItemWithStringId(IDS_DELETE, IDS_DELETE); 637 context_menu_model_->AddItemWithStringId(IDS_DELETE, IDS_DELETE);
634 context_menu_model_->AddItemWithStringId( 638 context_menu_model_->AddItemWithStringId(
635 IDS_BOOKMARK_EDITOR_NEW_FOLDER_MENU_ITEM, 639 IDS_BOOKMARK_EDITOR_NEW_FOLDER_MENU_ITEM,
636 IDS_BOOKMARK_EDITOR_NEW_FOLDER_MENU_ITEM); 640 IDS_BOOKMARK_EDITOR_NEW_FOLDER_MENU_ITEM);
637 } 641 }
638 return context_menu_model_.get(); 642 return context_menu_model_.get();
639 } 643 }
640 644
641 void BookmarkEditorView::EditorTreeModel::SetTitle( 645 void BookmarkEditorView::EditorTreeModel::SetTitle(
642 ui::TreeModelNode* node, 646 ui::TreeModelNode* node,
643 const base::string16& title) { 647 const base::string16& title) {
644 if (!title.empty()) 648 if (!title.empty())
645 ui::TreeNodeModel<EditorNode>::SetTitle(node, title); 649 ui::TreeNodeModel<EditorNode>::SetTitle(node, title);
646 } 650 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698