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 "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 if (!b_node) | 478 if (!b_node) |
479 b_node = tree_model_->GetRoot()->GetChild(0); // Bookmark bar node. | 479 b_node = tree_model_->GetRoot()->GetChild(0); // Bookmark bar node. |
480 | 480 |
481 tree_view_->SetSelectedNode(b_node); | 481 tree_view_->SetSelectedNode(b_node); |
482 } | 482 } |
483 | 483 |
484 BookmarkEditorView::EditorNode* BookmarkEditorView::CreateRootNode() { | 484 BookmarkEditorView::EditorNode* BookmarkEditorView::CreateRootNode() { |
485 EditorNode* root_node = new EditorNode(std::wstring(), 0); | 485 EditorNode* root_node = new EditorNode(std::wstring(), 0); |
486 const BookmarkNode* bb_root_node = bb_model_->root_node(); | 486 const BookmarkNode* bb_root_node = bb_model_->root_node(); |
487 CreateNodes(bb_root_node, root_node); | 487 CreateNodes(bb_root_node, root_node); |
488 DCHECK(root_node->child_count() == 2); | 488 DCHECK(root_node->child_count() >= 2 && root_node->child_count() <= 3); |
489 DCHECK(bb_root_node->GetChild(0)->type() == BookmarkNode::BOOKMARK_BAR); | 489 DCHECK(bb_root_node->GetChild(0)->type() == BookmarkNode::BOOKMARK_BAR); |
490 DCHECK(bb_root_node->GetChild(1)->type() == BookmarkNode::OTHER_NODE); | 490 DCHECK(bb_root_node->GetChild(1)->type() == BookmarkNode::OTHER_NODE); |
| 491 if (root_node->child_count() == 3) { |
| 492 DCHECK(bb_root_node->GetChild(2)->type() == BookmarkNode::SYNCED); |
| 493 } |
491 return root_node; | 494 return root_node; |
492 } | 495 } |
493 | 496 |
494 void BookmarkEditorView::CreateNodes(const BookmarkNode* bb_node, | 497 void BookmarkEditorView::CreateNodes(const BookmarkNode* bb_node, |
495 BookmarkEditorView::EditorNode* b_node) { | 498 BookmarkEditorView::EditorNode* b_node) { |
496 for (int i = 0; i < bb_node->child_count(); ++i) { | 499 for (int i = 0; i < bb_node->child_count(); ++i) { |
497 const BookmarkNode* child_bb_node = bb_node->GetChild(i); | 500 const BookmarkNode* child_bb_node = bb_node->GetChild(i); |
498 if (child_bb_node->is_folder()) { | 501 if (child_bb_node->IsVisible() && child_bb_node->is_folder()) { |
499 EditorNode* new_b_node = | 502 EditorNode* new_b_node = |
500 new EditorNode(WideToUTF16(child_bb_node->GetTitle()), | 503 new EditorNode(WideToUTF16(child_bb_node->GetTitle()), |
501 child_bb_node->id()); | 504 child_bb_node->id()); |
502 b_node->Add(new_b_node, b_node->child_count()); | 505 b_node->Add(new_b_node, b_node->child_count()); |
503 CreateNodes(child_bb_node, new_b_node); | 506 CreateNodes(child_bb_node, new_b_node); |
504 } | 507 } |
505 } | 508 } |
506 } | 509 } |
507 | 510 |
508 BookmarkEditorView::EditorNode* BookmarkEditorView::FindNodeWithID( | 511 BookmarkEditorView::EditorNode* BookmarkEditorView::FindNodeWithID( |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 break; | 583 break; |
581 } | 584 } |
582 } | 585 } |
583 DCHECK(child_bb_node); | 586 DCHECK(child_bb_node); |
584 bb_model_->SetTitle(child_bb_node, child_b_node->GetTitle()); | 587 bb_model_->SetTitle(child_bb_node, child_b_node->GetTitle()); |
585 } | 588 } |
586 ApplyNameChangesAndCreateNewFolders(child_bb_node, child_b_node, | 589 ApplyNameChangesAndCreateNewFolders(child_bb_node, child_b_node, |
587 parent_b_node, parent_bb_node); | 590 parent_b_node, parent_bb_node); |
588 } | 591 } |
589 } | 592 } |
OLD | NEW |