Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(211)

Side by Side Diff: chrome/browser/views/bookmark_editor_view.cc

Issue 1795007: Get rid of BookmarkEditor::Show()'s BookmarkEditor::Handler argument. (Closed)
Patch Set: baz Created 10 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/views/bookmark_editor_view.h" 5 #include "chrome/browser/views/bookmark_editor_view.h"
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 static const int kTreeWidth = 300; 44 static const int kTreeWidth = 300;
45 45
46 // ID for various children. 46 // ID for various children.
47 static const int kNewGroupButtonID = 1002; 47 static const int kNewGroupButtonID = 1002;
48 48
49 // static 49 // static
50 void BookmarkEditor::Show(HWND parent_hwnd, 50 void BookmarkEditor::Show(HWND parent_hwnd,
51 Profile* profile, 51 Profile* profile,
52 const BookmarkNode* parent, 52 const BookmarkNode* parent,
53 const EditDetails& details, 53 const EditDetails& details,
54 Configuration configuration, 54 Configuration configuration) {
55 Handler* handler) {
56 DCHECK(profile); 55 DCHECK(profile);
57 BookmarkEditorView* editor = 56 BookmarkEditorView* editor =
58 new BookmarkEditorView(profile, parent, details, configuration, handler); 57 new BookmarkEditorView(profile, parent, details, configuration);
59 editor->Show(parent_hwnd); 58 editor->Show(parent_hwnd);
60 } 59 }
61 60
62 BookmarkEditorView::BookmarkEditorView( 61 BookmarkEditorView::BookmarkEditorView(
63 Profile* profile, 62 Profile* profile,
64 const BookmarkNode* parent, 63 const BookmarkNode* parent,
65 const EditDetails& details, 64 const EditDetails& details,
66 BookmarkEditor::Configuration configuration, 65 BookmarkEditor::Configuration configuration)
67 BookmarkEditor::Handler* handler)
68 : profile_(profile), 66 : profile_(profile),
69 tree_view_(NULL), 67 tree_view_(NULL),
70 new_group_button_(NULL), 68 new_group_button_(NULL),
71 url_label_(NULL), 69 url_label_(NULL),
72 title_label_(NULL), 70 title_label_(NULL),
73 parent_(parent), 71 parent_(parent),
74 details_(details), 72 details_(details),
75 running_menu_for_root_(false), 73 running_menu_for_root_(false),
76 show_tree_(configuration == SHOW_TREE), 74 show_tree_(configuration == SHOW_TREE) {
77 handler_(handler) {
78 DCHECK(profile); 75 DCHECK(profile);
79 Init(); 76 Init();
80 } 77 }
81 78
82 BookmarkEditorView::~BookmarkEditorView() { 79 BookmarkEditorView::~BookmarkEditorView() {
83 // The tree model is deleted before the view. Reset the model otherwise the 80 // The tree model is deleted before the view. Reset the model otherwise the
84 // tree will reference a deleted model. 81 // tree will reference a deleted model.
85 if (tree_view_) 82 if (tree_view_)
86 tree_view_->SetModel(NULL); 83 tree_view_->SetModel(NULL);
87 bb_model_->RemoveObserver(this); 84 bb_model_->RemoveObserver(this);
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 // We're going to apply edits to the bookmark bar model, which will call us 525 // We're going to apply edits to the bookmark bar model, which will call us
529 // back. Normally when a structural edit occurs we reset the tree model. 526 // back. Normally when a structural edit occurs we reset the tree model.
530 // We don't want to do that here, so we remove ourselves as an observer. 527 // We don't want to do that here, so we remove ourselves as an observer.
531 bb_model_->RemoveObserver(this); 528 bb_model_->RemoveObserver(this);
532 529
533 GURL new_url(GetInputURL()); 530 GURL new_url(GetInputURL());
534 std::wstring new_title(GetInputTitle()); 531 std::wstring new_title(GetInputTitle());
535 532
536 if (!show_tree_) { 533 if (!show_tree_) {
537 bookmark_utils::ApplyEditsWithNoGroupChange( 534 bookmark_utils::ApplyEditsWithNoGroupChange(
538 bb_model_, parent_, details_, new_title, new_url, handler_.get()); 535 bb_model_, parent_, details_, new_title, new_url, NULL);
539 return; 536 return;
540 } 537 }
541 538
542 // Create the new groups and update the titles. 539 // Create the new groups and update the titles.
543 const BookmarkNode* new_parent = NULL; 540 const BookmarkNode* new_parent = NULL;
544 ApplyNameChangesAndCreateNewGroups( 541 ApplyNameChangesAndCreateNewGroups(
545 bb_model_->root_node(), tree_model_->GetRoot(), parent, &new_parent); 542 bb_model_->root_node(), tree_model_->GetRoot(), parent, &new_parent);
546 543
547 bookmark_utils::ApplyEditsWithPossibleGroupChange( 544 bookmark_utils::ApplyEditsWithPossibleGroupChange(
548 bb_model_, new_parent, details_, new_title, new_url, handler_.get()); 545 bb_model_, new_parent, details_, new_title, new_url, NULL);
549 } 546 }
550 547
551 void BookmarkEditorView::ApplyNameChangesAndCreateNewGroups( 548 void BookmarkEditorView::ApplyNameChangesAndCreateNewGroups(
552 const BookmarkNode* bb_node, 549 const BookmarkNode* bb_node,
553 BookmarkEditorView::EditorNode* b_node, 550 BookmarkEditorView::EditorNode* b_node,
554 BookmarkEditorView::EditorNode* parent_b_node, 551 BookmarkEditorView::EditorNode* parent_b_node,
555 const BookmarkNode** parent_bb_node) { 552 const BookmarkNode** parent_bb_node) {
556 if (parent_b_node == b_node) 553 if (parent_b_node == b_node)
557 *parent_bb_node = bb_node; 554 *parent_bb_node = bb_node;
558 for (int i = 0; i < b_node->GetChildCount(); ++i) { 555 for (int i = 0; i < b_node->GetChildCount(); ++i) {
(...skipping 13 matching lines...) Expand all
572 break; 569 break;
573 } 570 }
574 } 571 }
575 DCHECK(child_bb_node); 572 DCHECK(child_bb_node);
576 bb_model_->SetTitle(child_bb_node, child_b_node->GetTitle()); 573 bb_model_->SetTitle(child_bb_node, child_b_node->GetTitle());
577 } 574 }
578 ApplyNameChangesAndCreateNewGroups(child_bb_node, child_b_node, 575 ApplyNameChangesAndCreateNewGroups(child_bb_node, child_b_node,
579 parent_b_node, parent_bb_node); 576 parent_b_node, parent_bb_node);
580 } 577 }
581 } 578 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698