OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 if (!b_node) | 528 if (!b_node) |
529 b_node = tree_model_->GetRoot()->GetChild(0); // Bookmark bar node. | 529 b_node = tree_model_->GetRoot()->GetChild(0); // Bookmark bar node. |
530 | 530 |
531 tree_view_->SetSelectedNode(b_node); | 531 tree_view_->SetSelectedNode(b_node); |
532 } | 532 } |
533 | 533 |
534 BookmarkEditorView::EditorNode* BookmarkEditorView::CreateRootNode() { | 534 BookmarkEditorView::EditorNode* BookmarkEditorView::CreateRootNode() { |
535 EditorNode* root_node = new EditorNode(string16(), 0); | 535 EditorNode* root_node = new EditorNode(string16(), 0); |
536 const BookmarkNode* bb_root_node = bb_model_->root_node(); | 536 const BookmarkNode* bb_root_node = bb_model_->root_node(); |
537 CreateNodes(bb_root_node, root_node); | 537 CreateNodes(bb_root_node, root_node); |
538 DCHECK(root_node->child_count() >= 2 && root_node->child_count() <= 3); | 538 DCHECK_EQ(3, root_node->child_count()); |
539 DCHECK(bb_root_node->GetChild(0)->type() == BookmarkNode::BOOKMARK_BAR); | 539 DCHECK(bb_root_node->GetChild(0)->type() == BookmarkNode::BOOKMARK_BAR); |
540 DCHECK(bb_root_node->GetChild(1)->type() == BookmarkNode::OTHER_NODE); | 540 DCHECK(bb_root_node->GetChild(1)->type() == BookmarkNode::OTHER_NODE); |
541 if (root_node->child_count() == 3) { | 541 DCHECK(bb_root_node->GetChild(2)->type() == BookmarkNode::MOBILE); |
542 DCHECK(bb_root_node->GetChild(2)->type() == BookmarkNode::SYNCED); | |
543 } | |
544 return root_node; | 542 return root_node; |
545 } | 543 } |
546 | 544 |
547 void BookmarkEditorView::CreateNodes(const BookmarkNode* bb_node, | 545 void BookmarkEditorView::CreateNodes(const BookmarkNode* bb_node, |
548 BookmarkEditorView::EditorNode* b_node) { | 546 BookmarkEditorView::EditorNode* b_node) { |
549 for (int i = 0; i < bb_node->child_count(); ++i) { | 547 for (int i = 0; i < bb_node->child_count(); ++i) { |
550 const BookmarkNode* child_bb_node = bb_node->GetChild(i); | 548 const BookmarkNode* child_bb_node = bb_node->GetChild(i); |
551 if (child_bb_node->IsVisible() && child_bb_node->is_folder()) { | 549 if (child_bb_node->is_folder()) { |
552 EditorNode* new_b_node = new EditorNode(child_bb_node->GetTitle(), | 550 EditorNode* new_b_node = new EditorNode(child_bb_node->GetTitle(), |
553 child_bb_node->id()); | 551 child_bb_node->id()); |
554 b_node->Add(new_b_node, b_node->child_count()); | 552 b_node->Add(new_b_node, b_node->child_count()); |
555 CreateNodes(child_bb_node, new_b_node); | 553 CreateNodes(child_bb_node, new_b_node); |
556 } | 554 } |
557 } | 555 } |
558 } | 556 } |
559 | 557 |
560 BookmarkEditorView::EditorNode* BookmarkEditorView::FindNodeWithID( | 558 BookmarkEditorView::EditorNode* BookmarkEditorView::FindNodeWithID( |
561 BookmarkEditorView::EditorNode* node, | 559 BookmarkEditorView::EditorNode* node, |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
653 EditorNode* editor_node, | 651 EditorNode* editor_node, |
654 BookmarkExpandedStateTracker::Nodes* expanded_nodes) { | 652 BookmarkExpandedStateTracker::Nodes* expanded_nodes) { |
655 if (!tree_view_->IsExpanded(editor_node)) | 653 if (!tree_view_->IsExpanded(editor_node)) |
656 return; | 654 return; |
657 | 655 |
658 if (editor_node->value != 0) // The root is 0 | 656 if (editor_node->value != 0) // The root is 0 |
659 expanded_nodes->insert(bb_model_->GetNodeByID(editor_node->value)); | 657 expanded_nodes->insert(bb_model_->GetNodeByID(editor_node->value)); |
660 for (int i = 0; i < editor_node->child_count(); ++i) | 658 for (int i = 0; i < editor_node->child_count(); ++i) |
661 UpdateExpandedNodes(editor_node->GetChild(i), expanded_nodes); | 659 UpdateExpandedNodes(editor_node->GetChild(i), expanded_nodes); |
662 } | 660 } |
OLD | NEW |