| 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 "app/tree_node_model.h" | 10 #include "app/tree_node_model.h" |
| 11 #include "chrome/browser/bookmarks/bookmark_editor.h" | 11 #include "chrome/browser/bookmarks/bookmark_editor.h" |
| 12 #include "chrome/browser/bookmarks/bookmark_model.h" | 12 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 13 #include "views/controls/button/button.h" | 13 #include "views/controls/button/button.h" |
| 14 #include "views/controls/menu/menu.h" | 14 #include "views/controls/menu/simple_menu_model.h" |
| 15 #include "views/controls/textfield/textfield.h" | 15 #include "views/controls/textfield/textfield.h" |
| 16 #include "views/controls/tree/tree_view.h" | 16 #include "views/controls/tree/tree_view.h" |
| 17 #include "views/window/dialog_delegate.h" | 17 #include "views/window/dialog_delegate.h" |
| 18 | 18 |
| 19 namespace views { | 19 namespace views { |
| 20 class NativeButton; | 20 class NativeButton; |
| 21 class Window; | 21 class Window; |
| 22 } | 22 } |
| 23 | 23 |
| 24 class GURL; | 24 class GURL; |
| 25 class Menu; | 25 class Menu; |
| 26 class Profile; | 26 class Profile; |
| 27 | 27 |
| 28 // 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 |
| 29 // 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 |
| 30 // new groups and changing the name of other groups. | 30 // new groups and changing the name of other groups. |
| 31 // | 31 // |
| 32 // Edits are applied to the BookmarkModel when the user presses 'OK'. | 32 // Edits are applied to the BookmarkModel when the user presses 'OK'. |
| 33 // | 33 // |
| 34 // To use BookmarkEditorView invoke the static show method. | 34 // To use BookmarkEditorView invoke the static show method. |
| 35 | 35 |
| 36 class BookmarkEditorView : public BookmarkEditor, | 36 class BookmarkEditorView : public BookmarkEditor, |
| 37 public views::View, | 37 public views::View, |
| 38 public views::ButtonListener, | 38 public views::ButtonListener, |
| 39 public views::TreeViewController, | 39 public views::TreeViewController, |
| 40 public views::DialogDelegate, | 40 public views::DialogDelegate, |
| 41 public views::Textfield::Controller, | 41 public views::Textfield::Controller, |
| 42 public views::ContextMenuController, | 42 public views::ContextMenuController, |
| 43 public views::Menu::Delegate, | 43 public views::SimpleMenuModel::Delegate, |
| 44 public BookmarkModelObserver { | 44 public BookmarkModelObserver { |
| 45 FRIEND_TEST(BookmarkEditorViewTest, ChangeParent); | 45 FRIEND_TEST(BookmarkEditorViewTest, ChangeParent); |
| 46 FRIEND_TEST(BookmarkEditorViewTest, ChangeParentAndURL); | 46 FRIEND_TEST(BookmarkEditorViewTest, ChangeParentAndURL); |
| 47 FRIEND_TEST(BookmarkEditorViewTest, ChangeURLToExistingURL); | 47 FRIEND_TEST(BookmarkEditorViewTest, ChangeURLToExistingURL); |
| 48 FRIEND_TEST(BookmarkEditorViewTest, EditTitleKeepsPosition); | 48 FRIEND_TEST(BookmarkEditorViewTest, EditTitleKeepsPosition); |
| 49 FRIEND_TEST(BookmarkEditorViewTest, EditURLKeepsPosition); | 49 FRIEND_TEST(BookmarkEditorViewTest, EditURLKeepsPosition); |
| 50 FRIEND_TEST(BookmarkEditorViewTest, ModelsMatch); | 50 FRIEND_TEST(BookmarkEditorViewTest, ModelsMatch); |
| 51 FRIEND_TEST(BookmarkEditorViewTest, MoveToNewParent); | 51 FRIEND_TEST(BookmarkEditorViewTest, MoveToNewParent); |
| 52 FRIEND_TEST(BookmarkEditorViewTest, NewURL); | 52 FRIEND_TEST(BookmarkEditorViewTest, NewURL); |
| 53 FRIEND_TEST(BookmarkEditorViewTest, ChangeURLNoTree); | 53 FRIEND_TEST(BookmarkEditorViewTest, ChangeURLNoTree); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 84 virtual void ContentsChanged(views::Textfield* sender, | 84 virtual void ContentsChanged(views::Textfield* sender, |
| 85 const std::wstring& new_contents); | 85 const std::wstring& new_contents); |
| 86 virtual bool HandleKeystroke(views::Textfield* sender, | 86 virtual bool HandleKeystroke(views::Textfield* sender, |
| 87 const views::Textfield::Keystroke&) { | 87 const views::Textfield::Keystroke&) { |
| 88 return false; | 88 return false; |
| 89 } | 89 } |
| 90 | 90 |
| 91 // NativeButton. | 91 // NativeButton. |
| 92 virtual void ButtonPressed(views::Button* sender); | 92 virtual void ButtonPressed(views::Button* sender); |
| 93 | 93 |
| 94 // Menu::Delegate method. | 94 // SimpleMenuModel::Delegate. |
| 95 virtual void ExecuteCommand(int id); | 95 virtual bool IsCommandIdChecked(int command_id) const; |
| 96 | 96 virtual bool IsCommandIdEnabled(int command_id) const; |
| 97 // Menu::Delegate method, return false if id is edit and the bookmark node | 97 virtual bool GetAcceleratorForCommandId(int command_id, |
| 98 // was selected, true otherwise. | 98 views::Accelerator* accelerator); |
| 99 virtual bool IsCommandEnabled(int id) const; | 99 virtual void ExecuteCommand(int command_id); |
| 100 | 100 |
| 101 // Creates a Window and adds the BookmarkEditorView to it. When the window is | 101 // Creates a Window and adds the BookmarkEditorView to it. When the window is |
| 102 // closed the BookmarkEditorView is deleted. | 102 // closed the BookmarkEditorView is deleted. |
| 103 void Show(HWND parent_hwnd); | 103 void Show(HWND parent_hwnd); |
| 104 | 104 |
| 105 // Closes the dialog. | 105 // Closes the dialog. |
| 106 void Close(); | 106 void Close(); |
| 107 | 107 |
| 108 // Shows the context menu. | 108 // Shows the context menu. |
| 109 virtual void ShowContextMenu(View* source, | 109 virtual void ShowContextMenu(View* source, |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 // Used for editing the title. | 237 // Used for editing the title. |
| 238 views::Textfield title_tf_; | 238 views::Textfield title_tf_; |
| 239 | 239 |
| 240 // Initial parent to select. Is only used if node_ is NULL. | 240 // Initial parent to select. Is only used if node_ is NULL. |
| 241 BookmarkNode* parent_; | 241 BookmarkNode* parent_; |
| 242 | 242 |
| 243 // Node being edited. Is NULL if creating a new node. | 243 // Node being edited. Is NULL if creating a new node. |
| 244 BookmarkNode* node_; | 244 BookmarkNode* node_; |
| 245 | 245 |
| 246 // The context menu. | 246 // The context menu. |
| 247 scoped_ptr<views::Menu> context_menu_; | 247 scoped_ptr<views::SimpleMenuModel> context_menu_contents_; |
| 248 scoped_ptr<views::Menu2> context_menu_; |
| 248 | 249 |
| 249 // Mode used to create nodes from. | 250 // Mode used to create nodes from. |
| 250 BookmarkModel* bb_model_; | 251 BookmarkModel* bb_model_; |
| 251 | 252 |
| 252 // If true, we're running the menu for the bookmark bar or other bookmarks | 253 // If true, we're running the menu for the bookmark bar or other bookmarks |
| 253 // nodes. | 254 // nodes. |
| 254 bool running_menu_for_root_; | 255 bool running_menu_for_root_; |
| 255 | 256 |
| 256 // Is the tree shown? | 257 // Is the tree shown? |
| 257 bool show_tree_; | 258 bool show_tree_; |
| 258 | 259 |
| 259 scoped_ptr<BookmarkEditor::Handler> handler_; | 260 scoped_ptr<BookmarkEditor::Handler> handler_; |
| 260 | 261 |
| 261 DISALLOW_COPY_AND_ASSIGN(BookmarkEditorView); | 262 DISALLOW_COPY_AND_ASSIGN(BookmarkEditorView); |
| 262 }; | 263 }; |
| 263 | 264 |
| 264 #endif // CHROME_BROWSER_VIEWS_BOOKMARK_EDITOR_VIEW_H_ | 265 #endif // CHROME_BROWSER_VIEWS_BOOKMARK_EDITOR_VIEW_H_ |
| OLD | NEW |