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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 url_tf_(NULL), | 72 url_tf_(NULL), |
73 title_label_(NULL), | 73 title_label_(NULL), |
74 title_tf_(NULL), | 74 title_tf_(NULL), |
75 parent_(parent), | 75 parent_(parent), |
76 details_(details), | 76 details_(details), |
77 bb_model_(BookmarkModelFactory::GetForProfile(profile)), | 77 bb_model_(BookmarkModelFactory::GetForProfile(profile)), |
78 running_menu_for_root_(false), | 78 running_menu_for_root_(false), |
79 show_tree_(configuration == SHOW_TREE) { | 79 show_tree_(configuration == SHOW_TREE) { |
80 DCHECK(profile); | 80 DCHECK(profile); |
81 DCHECK(bb_model_); | 81 DCHECK(bb_model_); |
82 DCHECK(bb_model_->client()->CanBeEditedByUser(parent)); | 82 DCHECK(bb_model_->CanBeEditedByUser(parent)); |
83 Init(); | 83 Init(); |
84 } | 84 } |
85 | 85 |
86 BookmarkEditorView::~BookmarkEditorView() { | 86 BookmarkEditorView::~BookmarkEditorView() { |
87 // The tree model is deleted before the view. Reset the model otherwise the | 87 // The tree model is deleted before the view. Reset the model otherwise the |
88 // tree will reference a deleted model. | 88 // tree will reference a deleted model. |
89 if (tree_view_) | 89 if (tree_view_) |
90 tree_view_->SetModel(NULL); | 90 tree_view_->SetModel(NULL); |
91 bb_model_->RemoveObserver(this); | 91 bb_model_->RemoveObserver(this); |
92 } | 92 } |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 if (root_node->child_count() >= 3) | 508 if (root_node->child_count() >= 3) |
509 DCHECK_EQ(BookmarkNode::MOBILE, bb_root_node->GetChild(2)->type()); | 509 DCHECK_EQ(BookmarkNode::MOBILE, bb_root_node->GetChild(2)->type()); |
510 return root_node; | 510 return root_node; |
511 } | 511 } |
512 | 512 |
513 void BookmarkEditorView::CreateNodes(const BookmarkNode* bb_node, | 513 void BookmarkEditorView::CreateNodes(const BookmarkNode* bb_node, |
514 BookmarkEditorView::EditorNode* b_node) { | 514 BookmarkEditorView::EditorNode* b_node) { |
515 for (int i = 0; i < bb_node->child_count(); ++i) { | 515 for (int i = 0; i < bb_node->child_count(); ++i) { |
516 const BookmarkNode* child_bb_node = bb_node->GetChild(i); | 516 const BookmarkNode* child_bb_node = bb_node->GetChild(i); |
517 if (child_bb_node->IsVisible() && child_bb_node->is_folder() && | 517 if (child_bb_node->IsVisible() && child_bb_node->is_folder() && |
518 bb_model_->client()->CanBeEditedByUser(child_bb_node)) { | 518 bb_model_->CanBeEditedByUser(child_bb_node)) { |
519 EditorNode* new_b_node = new EditorNode(child_bb_node->GetTitle(), | 519 EditorNode* new_b_node = new EditorNode(child_bb_node->GetTitle(), |
520 child_bb_node->id()); | 520 child_bb_node->id()); |
521 b_node->Add(new_b_node, b_node->child_count()); | 521 b_node->Add(new_b_node, b_node->child_count()); |
522 CreateNodes(child_bb_node, new_b_node); | 522 CreateNodes(child_bb_node, new_b_node); |
523 } | 523 } |
524 } | 524 } |
525 } | 525 } |
526 | 526 |
527 BookmarkEditorView::EditorNode* BookmarkEditorView::FindNodeWithID( | 527 BookmarkEditorView::EditorNode* BookmarkEditorView::FindNodeWithID( |
528 BookmarkEditorView::EditorNode* node, | 528 BookmarkEditorView::EditorNode* node, |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 } | 646 } |
647 return context_menu_model_.get(); | 647 return context_menu_model_.get(); |
648 } | 648 } |
649 | 649 |
650 void BookmarkEditorView::EditorTreeModel::SetTitle( | 650 void BookmarkEditorView::EditorTreeModel::SetTitle( |
651 ui::TreeModelNode* node, | 651 ui::TreeModelNode* node, |
652 const base::string16& title) { | 652 const base::string16& title) { |
653 if (!title.empty()) | 653 if (!title.empty()) |
654 ui::TreeNodeModel<EditorNode>::SetTitle(node, title); | 654 ui::TreeNodeModel<EditorNode>::SetTitle(node, title); |
655 } | 655 } |
OLD | NEW |