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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
67 : profile_(profile), | 67 : profile_(profile), |
68 tree_view_(NULL), | 68 tree_view_(NULL), |
69 url_label_(NULL), | 69 url_label_(NULL), |
70 url_tf_(NULL), | 70 url_tf_(NULL), |
71 title_label_(NULL), | 71 title_label_(NULL), |
72 title_tf_(NULL), | 72 title_tf_(NULL), |
73 parent_(parent), | 73 parent_(parent), |
74 details_(details), | 74 details_(details), |
75 running_menu_for_root_(false), | 75 running_menu_for_root_(false), |
76 show_tree_(configuration == SHOW_TREE) { | 76 show_tree_(configuration == SHOW_TREE) { |
77 DCHECK(profile); | 77 DCHECK(profile); |
sky
2014/06/06 19:34:04
Add a DCHECK here that parent is editable.
Joao da Silva
2014/06/06 20:06:11
Done.
| |
78 Init(); | 78 Init(); |
79 } | 79 } |
80 | 80 |
81 BookmarkEditorView::~BookmarkEditorView() { | 81 BookmarkEditorView::~BookmarkEditorView() { |
82 // The tree model is deleted before the view. Reset the model otherwise the | 82 // The tree model is deleted before the view. Reset the model otherwise the |
83 // tree will reference a deleted model. | 83 // tree will reference a deleted model. |
84 if (tree_view_) | 84 if (tree_view_) |
85 tree_view_->SetModel(NULL); | 85 tree_view_->SetModel(NULL); |
86 bb_model_->RemoveObserver(this); | 86 bb_model_->RemoveObserver(this); |
87 } | 87 } |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 bb_model_->client()->CanBeEditedByUser(child_bb_node)) { | |
511 EditorNode* new_b_node = new EditorNode(child_bb_node->GetTitle(), | 512 EditorNode* new_b_node = new EditorNode(child_bb_node->GetTitle(), |
512 child_bb_node->id()); | 513 child_bb_node->id()); |
513 b_node->Add(new_b_node, b_node->child_count()); | 514 b_node->Add(new_b_node, b_node->child_count()); |
514 CreateNodes(child_bb_node, new_b_node); | 515 CreateNodes(child_bb_node, new_b_node); |
515 } | 516 } |
516 } | 517 } |
517 } | 518 } |
518 | 519 |
519 BookmarkEditorView::EditorNode* BookmarkEditorView::FindNodeWithID( | 520 BookmarkEditorView::EditorNode* BookmarkEditorView::FindNodeWithID( |
520 BookmarkEditorView::EditorNode* node, | 521 BookmarkEditorView::EditorNode* node, |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
635 } | 636 } |
636 return context_menu_model_.get(); | 637 return context_menu_model_.get(); |
637 } | 638 } |
638 | 639 |
639 void BookmarkEditorView::EditorTreeModel::SetTitle( | 640 void BookmarkEditorView::EditorTreeModel::SetTitle( |
640 ui::TreeModelNode* node, | 641 ui::TreeModelNode* node, |
641 const base::string16& title) { | 642 const base::string16& title) { |
642 if (!title.empty()) | 643 if (!title.empty()) |
643 ui::TreeNodeModel<EditorNode>::SetTitle(node, title); | 644 ui::TreeNodeModel<EditorNode>::SetTitle(node, title); |
644 } | 645 } |
OLD | NEW |