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/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 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
488 if (!b_node) | 488 if (!b_node) |
489 b_node = tree_model_->GetRoot()->GetChild(0); // Bookmark bar node. | 489 b_node = tree_model_->GetRoot()->GetChild(0); // Bookmark bar node. |
490 | 490 |
491 tree_view_->SetSelectedNode(b_node); | 491 tree_view_->SetSelectedNode(b_node); |
492 } | 492 } |
493 | 493 |
494 BookmarkEditorView::EditorNode* BookmarkEditorView::CreateRootNode() { | 494 BookmarkEditorView::EditorNode* BookmarkEditorView::CreateRootNode() { |
495 EditorNode* root_node = new EditorNode(base::string16(), 0); | 495 EditorNode* root_node = new EditorNode(base::string16(), 0); |
496 const BookmarkNode* bb_root_node = bb_model_->root_node(); | 496 const BookmarkNode* bb_root_node = bb_model_->root_node(); |
497 CreateNodes(bb_root_node, root_node); | 497 CreateNodes(bb_root_node, root_node); |
498 DCHECK(root_node->child_count() >= 2 && root_node->child_count() <= 3); | 498 DCHECK(root_node->child_count() >= 2 && root_node->child_count() <= 4); |
499 DCHECK_EQ(BookmarkNode::BOOKMARK_BAR, bb_root_node->GetChild(0)->type()); | 499 DCHECK_EQ(BookmarkNode::BOOKMARK_BAR, bb_root_node->GetChild(0)->type()); |
500 DCHECK_EQ(BookmarkNode::OTHER_NODE, bb_root_node->GetChild(1)->type()); | 500 DCHECK_EQ(BookmarkNode::OTHER_NODE, bb_root_node->GetChild(1)->type()); |
501 if (root_node->child_count() == 3) | 501 if (root_node->child_count() >= 3) |
502 DCHECK_EQ(BookmarkNode::MOBILE, bb_root_node->GetChild(2)->type()); | 502 DCHECK_EQ(BookmarkNode::MOBILE, bb_root_node->GetChild(2)->type()); |
503 return root_node; | 503 return root_node; |
504 } | 504 } |
505 | 505 |
506 void BookmarkEditorView::CreateNodes(const BookmarkNode* bb_node, | 506 void BookmarkEditorView::CreateNodes(const BookmarkNode* bb_node, |
507 BookmarkEditorView::EditorNode* b_node) { | 507 BookmarkEditorView::EditorNode* b_node) { |
508 for (int i = 0; i < bb_node->child_count(); ++i) { | 508 for (int i = 0; i < bb_node->child_count(); ++i) { |
509 const BookmarkNode* child_bb_node = bb_node->GetChild(i); | 509 const BookmarkNode* child_bb_node = bb_node->GetChild(i); |
510 if (child_bb_node->IsVisible() && child_bb_node->is_folder()) { | 510 if (child_bb_node->IsVisible() && child_bb_node->is_folder()) { |
511 EditorNode* new_b_node = new EditorNode(child_bb_node->GetTitle(), | 511 EditorNode* new_b_node = new EditorNode(child_bb_node->GetTitle(), |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
635 } | 635 } |
636 return context_menu_model_.get(); | 636 return context_menu_model_.get(); |
637 } | 637 } |
638 | 638 |
639 void BookmarkEditorView::EditorTreeModel::SetTitle( | 639 void BookmarkEditorView::EditorTreeModel::SetTitle( |
640 ui::TreeModelNode* node, | 640 ui::TreeModelNode* node, |
641 const base::string16& title) { | 641 const base::string16& title) { |
642 if (!title.empty()) | 642 if (!title.empty()) |
643 ui::TreeNodeModel<EditorNode>::SetTitle(node, title); | 643 ui::TreeNodeModel<EditorNode>::SetTitle(node, title); |
644 } | 644 } |
OLD | NEW |