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

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

Issue 99131: Create a bookmark editor dialog interface and implement a GTK version. (Closed)
Patch Set: fixes for tony Created 11 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "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 "chrome/browser/history/history.h" 10 #include "chrome/browser/history/history.h"
(...skipping 24 matching lines...) Expand all
35 35
36 // Background color of text field when URL is invalid. 36 // Background color of text field when URL is invalid.
37 static const SkColor kErrorColor = SkColorSetRGB(0xFF, 0xBC, 0xBC); 37 static const SkColor kErrorColor = SkColorSetRGB(0xFF, 0xBC, 0xBC);
38 38
39 // Preferred width of the tree. 39 // Preferred width of the tree.
40 static const int kTreeWidth = 300; 40 static const int kTreeWidth = 300;
41 41
42 // ID for various children. 42 // ID for various children.
43 static const int kNewGroupButtonID = 1002; 43 static const int kNewGroupButtonID = 1002;
44 44
45 BookmarkEditorView::BookmarkEditorView(Profile* profile, 45 // static
46 BookmarkNode* parent, 46 void BookmarkEditor::Show(HWND parent_hwnd,
47 BookmarkNode* node, 47 Profile* profile,
48 Configuration configuration, 48 BookmarkNode* parent,
49 Handler* handler) 49 BookmarkNode* node,
50 Configuration configuration,
51 Handler* handler) {
52 DCHECK(profile);
53 BookmarkEditorView* editor =
54 new BookmarkEditorView(profile, parent, node, configuration, handler);
55 editor->Show(parent_hwnd);
56 }
57
58 BookmarkEditorView::BookmarkEditorView(
59 Profile* profile,
60 BookmarkNode* parent,
61 BookmarkNode* node,
62 BookmarkEditor::Configuration configuration,
63 BookmarkEditor::Handler* handler)
50 : profile_(profile), 64 : profile_(profile),
51 tree_view_(NULL), 65 tree_view_(NULL),
52 new_group_button_(NULL), 66 new_group_button_(NULL),
53 parent_(parent), 67 parent_(parent),
54 node_(node), 68 node_(node),
55 running_menu_for_root_(false), 69 running_menu_for_root_(false),
56 show_tree_(configuration == SHOW_TREE), 70 show_tree_(configuration == SHOW_TREE),
57 handler_(handler) { 71 handler_(handler) {
58 DCHECK(profile); 72 DCHECK(profile);
59 Init(); 73 Init();
60 } 74 }
61 75
62 BookmarkEditorView::~BookmarkEditorView() { 76 BookmarkEditorView::~BookmarkEditorView() {
63 // The tree model is deleted before the view. Reset the model otherwise the 77 // The tree model is deleted before the view. Reset the model otherwise the
64 // tree will reference a deleted model. 78 // tree will reference a deleted model.
65 if (tree_view_) 79 if (tree_view_)
66 tree_view_->SetModel(NULL); 80 tree_view_->SetModel(NULL);
67 bb_model_->RemoveObserver(this); 81 bb_model_->RemoveObserver(this);
68 } 82 }
69 83
70 // static
71 void BookmarkEditorView::Show(HWND parent_hwnd,
72 Profile* profile,
73 BookmarkNode* parent,
74 BookmarkNode* node,
75 Configuration configuration,
76 Handler* handler) {
77 DCHECK(profile);
78 BookmarkEditorView* editor =
79 new BookmarkEditorView(profile, parent, node, configuration, handler);
80 editor->Show(parent_hwnd);
81 }
82
83 bool BookmarkEditorView::IsDialogButtonEnabled( 84 bool BookmarkEditorView::IsDialogButtonEnabled(
84 MessageBoxFlags::DialogButton button) const { 85 MessageBoxFlags::DialogButton button) const {
85 if (button == MessageBoxFlags::DIALOGBUTTON_OK) { 86 if (button == MessageBoxFlags::DIALOGBUTTON_OK) {
86 const GURL url(GetInputURL()); 87 const GURL url(GetInputURL());
87 return bb_model_->IsLoaded() && url.is_valid(); 88 return bb_model_->IsLoaded() && url.is_valid();
88 } 89 }
89 return true; 90 return true;
90 } 91 }
91 bool BookmarkEditorView::IsModal() const { 92 bool BookmarkEditorView::IsModal() const {
92 return true; 93 return true;
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 // back. Normally when a structural edit occurs we reset the tree model. 483 // back. Normally when a structural edit occurs we reset the tree model.
483 // We don't want to do that here, so we remove ourselves as an observer. 484 // We don't want to do that here, so we remove ourselves as an observer.
484 bb_model_->RemoveObserver(this); 485 bb_model_->RemoveObserver(this);
485 486
486 GURL new_url(GetInputURL()); 487 GURL new_url(GetInputURL());
487 std::wstring new_title(GetInputTitle()); 488 std::wstring new_title(GetInputTitle());
488 489
489 BookmarkNode* old_parent = node_ ? node_->GetParent() : NULL; 490 BookmarkNode* old_parent = node_ ? node_->GetParent() : NULL;
490 const int old_index = old_parent ? old_parent->IndexOfChild(node_) : -1; 491 const int old_index = old_parent ? old_parent->IndexOfChild(node_) : -1;
491 492
492 if (!show_tree_ ) { 493 if (!show_tree_) {
493 if (!node_) { 494 if (!node_) {
494 BookmarkNode* node = 495 BookmarkNode* node =
495 bb_model_->AddURL(parent_, parent_->GetChildCount(), new_title, 496 bb_model_->AddURL(parent_, parent_->GetChildCount(), new_title,
496 new_url); 497 new_url);
497 if (handler_.get()) 498 if (handler_.get())
498 handler_->NodeCreated(node); 499 handler_->NodeCreated(node);
499 return; 500 return;
500 } 501 }
501 // If we're not showing the tree we only need to modify the node. 502 // If we're not showing the tree we only need to modify the node.
502 if (old_index == -1) { 503 if (old_index == -1) {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 break; 583 break;
583 } 584 }
584 } 585 }
585 DCHECK(child_bb_node); 586 DCHECK(child_bb_node);
586 bb_model_->SetTitle(child_bb_node, child_b_node->GetTitle()); 587 bb_model_->SetTitle(child_bb_node, child_b_node->GetTitle());
587 } 588 }
588 ApplyNameChangesAndCreateNewGroups(child_bb_node, child_b_node, 589 ApplyNameChangesAndCreateNewGroups(child_bb_node, child_b_node,
589 parent_b_node, parent_bb_node); 590 parent_b_node, parent_bb_node);
590 } 591 }
591 } 592 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698