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 #ifndef CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_EDITOR_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_EDITOR_VIEW_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_EDITOR_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_EDITOR_VIEW_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 : ui::TreeNodeModel<EditorNode>(root) {} | 64 : ui::TreeNodeModel<EditorNode>(root) {} |
65 | 65 |
66 void SetTitle(ui::TreeModelNode* node, | 66 void SetTitle(ui::TreeModelNode* node, |
67 const base::string16& title) override; | 67 const base::string16& title) override; |
68 | 68 |
69 private: | 69 private: |
70 DISALLOW_COPY_AND_ASSIGN(EditorTreeModel); | 70 DISALLOW_COPY_AND_ASSIGN(EditorTreeModel); |
71 }; | 71 }; |
72 | 72 |
73 BookmarkEditorView(Profile* profile, | 73 BookmarkEditorView(Profile* profile, |
74 const BookmarkNode* parent, | 74 const bookmarks::BookmarkNode* parent, |
75 const EditDetails& details, | 75 const EditDetails& details, |
76 BookmarkEditor::Configuration configuration); | 76 BookmarkEditor::Configuration configuration); |
77 | 77 |
78 ~BookmarkEditorView() override; | 78 ~BookmarkEditorView() override; |
79 | 79 |
80 // views::DialogDelegateView: | 80 // views::DialogDelegateView: |
81 base::string16 GetDialogButtonLabel(ui::DialogButton button) const override; | 81 base::string16 GetDialogButtonLabel(ui::DialogButton button) const override; |
82 bool IsDialogButtonEnabled(ui::DialogButton button) const override; | 82 bool IsDialogButtonEnabled(ui::DialogButton button) const override; |
83 views::View* CreateExtraView() override; | 83 views::View* CreateExtraView() override; |
84 ui::ModalType GetModalType() const override; | 84 ui::ModalType GetModalType() const override; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 friend class BookmarkEditorViewTest; | 123 friend class BookmarkEditorViewTest; |
124 | 124 |
125 // views::DialogDelegateView: | 125 // views::DialogDelegateView: |
126 const char* GetClassName() const override; | 126 const char* GetClassName() const override; |
127 | 127 |
128 // bookmarks::BookmarkModelObserver: | 128 // bookmarks::BookmarkModelObserver: |
129 // Any structural change results in resetting the tree model. | 129 // Any structural change results in resetting the tree model. |
130 void BookmarkModelLoaded(bookmarks::BookmarkModel* model, | 130 void BookmarkModelLoaded(bookmarks::BookmarkModel* model, |
131 bool ids_reassigned) override {} | 131 bool ids_reassigned) override {} |
132 void BookmarkNodeMoved(bookmarks::BookmarkModel* model, | 132 void BookmarkNodeMoved(bookmarks::BookmarkModel* model, |
133 const BookmarkNode* old_parent, | 133 const bookmarks::BookmarkNode* old_parent, |
134 int old_index, | 134 int old_index, |
135 const BookmarkNode* new_parent, | 135 const bookmarks::BookmarkNode* new_parent, |
136 int new_index) override; | 136 int new_index) override; |
137 void BookmarkNodeAdded(bookmarks::BookmarkModel* model, | 137 void BookmarkNodeAdded(bookmarks::BookmarkModel* model, |
138 const BookmarkNode* parent, | 138 const bookmarks::BookmarkNode* parent, |
139 int index) override; | 139 int index) override; |
140 void BookmarkNodeRemoved(bookmarks::BookmarkModel* model, | 140 void BookmarkNodeRemoved(bookmarks::BookmarkModel* model, |
141 const BookmarkNode* parent, | 141 const bookmarks::BookmarkNode* parent, |
142 int index, | 142 int index, |
143 const BookmarkNode* node, | 143 const bookmarks::BookmarkNode* node, |
144 const std::set<GURL>& removed_urls) override; | 144 const std::set<GURL>& removed_urls) override; |
145 void BookmarkAllUserNodesRemoved(bookmarks::BookmarkModel* model, | 145 void BookmarkAllUserNodesRemoved(bookmarks::BookmarkModel* model, |
146 const std::set<GURL>& removed_urls) override; | 146 const std::set<GURL>& removed_urls) override; |
147 void BookmarkNodeChanged(bookmarks::BookmarkModel* model, | 147 void BookmarkNodeChanged(bookmarks::BookmarkModel* model, |
148 const BookmarkNode* node) override {} | 148 const bookmarks::BookmarkNode* node) override {} |
149 void BookmarkNodeChildrenReordered(bookmarks::BookmarkModel* model, | 149 void BookmarkNodeChildrenReordered( |
150 const BookmarkNode* node) override; | 150 bookmarks::BookmarkModel* model, |
151 void BookmarkNodeFaviconChanged(bookmarks::BookmarkModel* model, | 151 const bookmarks::BookmarkNode* node) override; |
152 const BookmarkNode* node) override {} | 152 void BookmarkNodeFaviconChanged( |
| 153 bookmarks::BookmarkModel* model, |
| 154 const bookmarks::BookmarkNode* node) override {} |
153 | 155 |
154 // Creates the necessary sub-views, configures them, adds them to the layout, | 156 // Creates the necessary sub-views, configures them, adds them to the layout, |
155 // and requests the entries to display from the database. | 157 // and requests the entries to display from the database. |
156 void Init(); | 158 void Init(); |
157 | 159 |
158 // Resets the model of the tree and updates the various buttons appropriately. | 160 // Resets the model of the tree and updates the various buttons appropriately. |
159 void Reset(); | 161 void Reset(); |
160 | 162 |
161 // Expands all the nodes in the tree and selects the parent node of the | 163 // Expands all the nodes in the tree and selects the parent node of the |
162 // url we're editing or the most recent parent if the url being editted isn't | 164 // url we're editing or the most recent parent if the url being editted isn't |
163 // starred. | 165 // starred. |
164 void ExpandAndSelect(); | 166 void ExpandAndSelect(); |
165 | 167 |
166 // Creates a returns the new root node. This invokes CreateNodes to do | 168 // Creates a returns the new root node. This invokes CreateNodes to do |
167 // the real work. | 169 // the real work. |
168 EditorNode* CreateRootNode(); | 170 EditorNode* CreateRootNode(); |
169 | 171 |
170 // Adds and creates a child node in b_node for all children of bb_node that | 172 // Adds and creates a child node in b_node for all children of bb_node that |
171 // are folders. | 173 // are folders. |
172 void CreateNodes(const BookmarkNode* bb_node, EditorNode* b_node); | 174 void CreateNodes(const bookmarks::BookmarkNode* bb_node, EditorNode* b_node); |
173 | 175 |
174 // Returns the node with the specified id, or NULL if one can't be found. | 176 // Returns the node with the specified id, or NULL if one can't be found. |
175 EditorNode* FindNodeWithID(BookmarkEditorView::EditorNode* node, int64 id); | 177 EditorNode* FindNodeWithID(BookmarkEditorView::EditorNode* node, int64 id); |
176 | 178 |
177 // Invokes ApplyEdits with the selected node. | 179 // Invokes ApplyEdits with the selected node. |
178 void ApplyEdits(); | 180 void ApplyEdits(); |
179 | 181 |
180 // Applies the edits done by the user. |parent| gives the parent of the URL | 182 // Applies the edits done by the user. |parent| gives the parent of the URL |
181 // being edited. | 183 // being edited. |
182 void ApplyEdits(EditorNode* parent); | 184 void ApplyEdits(EditorNode* parent); |
183 | 185 |
184 // Recursively adds newly created folders and sets the title of nodes to | 186 // Recursively adds newly created folders and sets the title of nodes to |
185 // match the user edited title. | 187 // match the user edited title. |
186 // | 188 // |
187 // bb_node gives the BookmarkNode the edits are to be applied to, with b_node | 189 // bb_node gives the BookmarkNode the edits are to be applied to, with b_node |
188 // the source of the edits. | 190 // the source of the edits. |
189 // | 191 // |
190 // If b_node == parent_b_node, parent_bb_node is set to bb_node. This is | 192 // If b_node == parent_b_node, parent_bb_node is set to bb_node. This is |
191 // used to determine the new BookmarkNode parent based on the EditorNode | 193 // used to determine the new BookmarkNode parent based on the EditorNode |
192 // parent. | 194 // parent. |
193 void ApplyNameChangesAndCreateNewFolders( | 195 void ApplyNameChangesAndCreateNewFolders( |
194 const BookmarkNode* bb_node, | 196 const bookmarks::BookmarkNode* bb_node, |
195 BookmarkEditorView::EditorNode* b_node, | 197 BookmarkEditorView::EditorNode* b_node, |
196 BookmarkEditorView::EditorNode* parent_b_node, | 198 BookmarkEditorView::EditorNode* parent_b_node, |
197 const BookmarkNode** parent_bb_node); | 199 const bookmarks::BookmarkNode** parent_bb_node); |
198 | 200 |
199 // Returns the current url the user has input. | 201 // Returns the current url the user has input. |
200 GURL GetInputURL() const; | 202 GURL GetInputURL() const; |
201 | 203 |
202 // Invoked when the url or title has possibly changed. Updates the background | 204 // Invoked when the url or title has possibly changed. Updates the background |
203 // of Textfields and ok button appropriately. | 205 // of Textfields and ok button appropriately. |
204 void UserInputChanged(); | 206 void UserInputChanged(); |
205 | 207 |
206 // Creates a new folder as a child of the selected node. If no node is | 208 // Creates a new folder as a child of the selected node. If no node is |
207 // selected, the new folder is added as a child of the bookmark node. Starts | 209 // selected, the new folder is added as a child of the bookmark node. Starts |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 views::Textfield* url_tf_; | 242 views::Textfield* url_tf_; |
241 | 243 |
242 // The label for the title text field. | 244 // The label for the title text field. |
243 views::Label* title_label_; | 245 views::Label* title_label_; |
244 | 246 |
245 // The text field used for editing the title. | 247 // The text field used for editing the title. |
246 views::Textfield* title_tf_; | 248 views::Textfield* title_tf_; |
247 | 249 |
248 // Initial parent to select. Is only used if |details_.existing_node| is | 250 // Initial parent to select. Is only used if |details_.existing_node| is |
249 // NULL. | 251 // NULL. |
250 const BookmarkNode* parent_; | 252 const bookmarks::BookmarkNode* parent_; |
251 | 253 |
252 const EditDetails details_; | 254 const EditDetails details_; |
253 | 255 |
254 // The context menu. | 256 // The context menu. |
255 scoped_ptr<ui::SimpleMenuModel> context_menu_model_; | 257 scoped_ptr<ui::SimpleMenuModel> context_menu_model_; |
256 scoped_ptr<views::MenuRunner> context_menu_runner_; | 258 scoped_ptr<views::MenuRunner> context_menu_runner_; |
257 | 259 |
258 // Mode used to create nodes from. | 260 // Mode used to create nodes from. |
259 bookmarks::BookmarkModel* bb_model_; | 261 bookmarks::BookmarkModel* bb_model_; |
260 | 262 |
261 // If true, we're running the menu for the bookmark bar or other bookmarks | 263 // If true, we're running the menu for the bookmark bar or other bookmarks |
262 // nodes. | 264 // nodes. |
263 bool running_menu_for_root_; | 265 bool running_menu_for_root_; |
264 | 266 |
265 // Is the tree shown? | 267 // Is the tree shown? |
266 bool show_tree_; | 268 bool show_tree_; |
267 | 269 |
268 // List of deleted bookmark folders. | 270 // List of deleted bookmark folders. |
269 std::vector<int64> deletes_; | 271 std::vector<int64> deletes_; |
270 | 272 |
271 DISALLOW_COPY_AND_ASSIGN(BookmarkEditorView); | 273 DISALLOW_COPY_AND_ASSIGN(BookmarkEditorView); |
272 }; | 274 }; |
273 | 275 |
274 #endif // CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_EDITOR_VIEW_H_ | 276 #endif // CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_EDITOR_VIEW_H_ |
OLD | NEW |