OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #ifndef CHROME_BROWSER_VIEWS_BOOKMARK_EDITOR_VIEW_H_ | 5 #ifndef CHROME_BROWSER_VIEWS_BOOKMARK_EDITOR_VIEW_H_ |
6 #define CHROME_BROWSER_VIEWS_BOOKMARK_EDITOR_VIEW_H_ | 6 #define CHROME_BROWSER_VIEWS_BOOKMARK_EDITOR_VIEW_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 | 9 |
| 10 #include "chrome/browser/bookmarks/bookmark_editor.h" |
10 #include "chrome/browser/bookmarks/bookmark_model.h" | 11 #include "chrome/browser/bookmarks/bookmark_model.h" |
11 #include "chrome/views/controls/button/button.h" | 12 #include "chrome/views/controls/button/button.h" |
12 #include "chrome/views/controls/menu/menu.h" | 13 #include "chrome/views/controls/menu/menu.h" |
13 #include "chrome/views/controls/text_field.h" | 14 #include "chrome/views/controls/text_field.h" |
14 #include "chrome/views/controls/tree/tree_node_model.h" | 15 #include "chrome/views/controls/tree/tree_node_model.h" |
15 #include "chrome/views/controls/tree/tree_view.h" | 16 #include "chrome/views/controls/tree/tree_view.h" |
16 #include "chrome/views/window/dialog_delegate.h" | 17 #include "chrome/views/window/dialog_delegate.h" |
17 | 18 |
18 namespace views { | 19 namespace views { |
19 class NativeButton; | 20 class NativeButton; |
20 class Window; | 21 class Window; |
21 } | 22 } |
22 | 23 |
23 class GURL; | 24 class GURL; |
24 class Menu; | 25 class Menu; |
25 class Profile; | 26 class Profile; |
26 | 27 |
27 // View that allows the user to edit a bookmark/starred URL. The user can | 28 // View that allows the user to edit a bookmark/starred URL. The user can |
28 // change the URL, title and where the bookmark appears as well as adding | 29 // change the URL, title and where the bookmark appears as well as adding |
29 // new groups and changing the name of other groups. | 30 // new groups and changing the name of other groups. |
30 // | 31 // |
31 // Edits are applied to the BookmarkModel when the user presses 'OK'. | 32 // Edits are applied to the BookmarkModel when the user presses 'OK'. |
32 // | 33 // |
33 // To use BookmarkEditorView invoke the static show method. | 34 // To use BookmarkEditorView invoke the static show method. |
34 | 35 |
35 class BookmarkEditorView : public views::View, | 36 class BookmarkEditorView : public BookmarkEditor, |
| 37 public views::View, |
36 public views::ButtonListener, | 38 public views::ButtonListener, |
37 public views::TreeViewController, | 39 public views::TreeViewController, |
38 public views::DialogDelegate, | 40 public views::DialogDelegate, |
39 public views::TextField::Controller, | 41 public views::TextField::Controller, |
40 public views::ContextMenuController, | 42 public views::ContextMenuController, |
41 public Menu::Delegate, | 43 public Menu::Delegate, |
42 public BookmarkModelObserver { | 44 public BookmarkModelObserver { |
43 FRIEND_TEST(BookmarkEditorViewTest, ChangeParent); | 45 FRIEND_TEST(BookmarkEditorViewTest, ChangeParent); |
44 FRIEND_TEST(BookmarkEditorViewTest, ChangeParentAndURL); | 46 FRIEND_TEST(BookmarkEditorViewTest, ChangeParentAndURL); |
45 FRIEND_TEST(BookmarkEditorViewTest, ChangeURLToExistingURL); | 47 FRIEND_TEST(BookmarkEditorViewTest, ChangeURLToExistingURL); |
46 FRIEND_TEST(BookmarkEditorViewTest, EditTitleKeepsPosition); | 48 FRIEND_TEST(BookmarkEditorViewTest, EditTitleKeepsPosition); |
47 FRIEND_TEST(BookmarkEditorViewTest, EditURLKeepsPosition); | 49 FRIEND_TEST(BookmarkEditorViewTest, EditURLKeepsPosition); |
48 FRIEND_TEST(BookmarkEditorViewTest, ModelsMatch); | 50 FRIEND_TEST(BookmarkEditorViewTest, ModelsMatch); |
49 FRIEND_TEST(BookmarkEditorViewTest, MoveToNewParent); | 51 FRIEND_TEST(BookmarkEditorViewTest, MoveToNewParent); |
50 FRIEND_TEST(BookmarkEditorViewTest, NewURL); | 52 FRIEND_TEST(BookmarkEditorViewTest, NewURL); |
51 FRIEND_TEST(BookmarkEditorViewTest, ChangeURLNoTree); | 53 FRIEND_TEST(BookmarkEditorViewTest, ChangeURLNoTree); |
52 FRIEND_TEST(BookmarkEditorViewTest, ChangeTitleNoTree); | 54 FRIEND_TEST(BookmarkEditorViewTest, ChangeTitleNoTree); |
53 public: | 55 public: |
54 // Handler is notified when the BookmarkEditorView creates a new bookmark. | |
55 // Handler is owned by the BookmarkEditorView and deleted when it is deleted. | |
56 class Handler { | |
57 public: | |
58 virtual ~Handler() {} | |
59 virtual void NodeCreated(BookmarkNode* new_node) = 0; | |
60 }; | |
61 | |
62 // An enumeration of the possible configurations offered. | |
63 enum Configuration { | |
64 SHOW_TREE, | |
65 NO_TREE | |
66 }; | |
67 | |
68 BookmarkEditorView(Profile* profile, | 56 BookmarkEditorView(Profile* profile, |
69 BookmarkNode* parent, | 57 BookmarkNode* parent, |
70 BookmarkNode* node, | 58 BookmarkNode* node, |
71 Configuration configuration, | 59 BookmarkEditor::Configuration configuration, |
72 Handler* handler); | 60 BookmarkEditor::Handler* handler); |
73 | 61 |
74 virtual ~BookmarkEditorView(); | 62 virtual ~BookmarkEditorView(); |
75 | 63 |
76 // Shows the BookmarkEditorView editing |node|. If |node| is NULL a new entry | |
77 // is created initially parented to |parent|. If |show_tree| is false the | |
78 // tree is not shown. BookmarkEditorView takes ownership of |handler| and | |
79 // deletes it when done. |handler| may be null. See description of Handler | |
80 // for details. | |
81 static void Show(HWND parent_window, | |
82 Profile* profile, | |
83 BookmarkNode* parent, | |
84 BookmarkNode* node, | |
85 Configuration configuration, | |
86 Handler* handler); | |
87 | |
88 // DialogDelegate methods: | 64 // DialogDelegate methods: |
89 virtual bool IsDialogButtonEnabled( | 65 virtual bool IsDialogButtonEnabled( |
90 MessageBoxFlags::DialogButton button) const; | 66 MessageBoxFlags::DialogButton button) const; |
91 virtual bool IsModal() const; | 67 virtual bool IsModal() const; |
92 virtual std::wstring GetWindowTitle() const; | 68 virtual std::wstring GetWindowTitle() const; |
93 virtual bool Accept(); | 69 virtual bool Accept(); |
94 virtual bool AreAcceleratorsEnabled(MessageBoxFlags::DialogButton button); | 70 virtual bool AreAcceleratorsEnabled(MessageBoxFlags::DialogButton button); |
95 virtual views::View* GetContentsView(); | 71 virtual views::View* GetContentsView(); |
96 | 72 |
97 // View methods. | 73 // View methods. |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 // Mode used to create nodes from. | 249 // Mode used to create nodes from. |
274 BookmarkModel* bb_model_; | 250 BookmarkModel* bb_model_; |
275 | 251 |
276 // If true, we're running the menu for the bookmark bar or other bookmarks | 252 // If true, we're running the menu for the bookmark bar or other bookmarks |
277 // nodes. | 253 // nodes. |
278 bool running_menu_for_root_; | 254 bool running_menu_for_root_; |
279 | 255 |
280 // Is the tree shown? | 256 // Is the tree shown? |
281 bool show_tree_; | 257 bool show_tree_; |
282 | 258 |
283 scoped_ptr<Handler> handler_; | 259 scoped_ptr<BookmarkEditor::Handler> handler_; |
284 | 260 |
285 DISALLOW_COPY_AND_ASSIGN(BookmarkEditorView); | 261 DISALLOW_COPY_AND_ASSIGN(BookmarkEditorView); |
286 }; | 262 }; |
287 | 263 |
288 #endif // CHROME_BROWSER_VIEWS_BOOKMARK_EDITOR_VIEW_H_ | 264 #endif // CHROME_BROWSER_VIEWS_BOOKMARK_EDITOR_VIEW_H_ |
OLD | NEW |