| 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 <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> |
| 10 #include <vector> | 11 #include <vector> |
| 11 | 12 |
| 12 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 13 #include "base/macros.h" | 14 #include "base/macros.h" |
| 14 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
| 15 #include "chrome/browser/ui/bookmarks/bookmark_editor.h" | 16 #include "chrome/browser/ui/bookmarks/bookmark_editor.h" |
| 16 #include "components/bookmarks/browser/bookmark_expanded_state_tracker.h" | 17 #include "components/bookmarks/browser/bookmark_expanded_state_tracker.h" |
| 17 #include "components/bookmarks/browser/bookmark_model_observer.h" | 18 #include "components/bookmarks/browser/bookmark_model_observer.h" |
| 18 #include "ui/base/models/simple_menu_model.h" | 19 #include "ui/base/models/simple_menu_model.h" |
| 19 #include "ui/base/models/tree_node_model.h" | 20 #include "ui/base/models/tree_node_model.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 public ui::SimpleMenuModel::Delegate, | 56 public ui::SimpleMenuModel::Delegate, |
| 56 public bookmarks::BookmarkModelObserver { | 57 public bookmarks::BookmarkModelObserver { |
| 57 public: | 58 public: |
| 58 // Type of node in the tree. Public purely for testing. | 59 // Type of node in the tree. Public purely for testing. |
| 59 typedef ui::TreeNodeWithValue<int64_t> EditorNode; | 60 typedef ui::TreeNodeWithValue<int64_t> EditorNode; |
| 60 | 61 |
| 61 // Model for the TreeView. Trivial subclass that doesn't allow titles with | 62 // Model for the TreeView. Trivial subclass that doesn't allow titles with |
| 62 // empty strings. Public purely for testing. | 63 // empty strings. Public purely for testing. |
| 63 class EditorTreeModel : public ui::TreeNodeModel<EditorNode> { | 64 class EditorTreeModel : public ui::TreeNodeModel<EditorNode> { |
| 64 public: | 65 public: |
| 65 explicit EditorTreeModel(EditorNode* root) | 66 explicit EditorTreeModel(std::unique_ptr<EditorNode> root) |
| 66 : ui::TreeNodeModel<EditorNode>(root) {} | 67 : ui::TreeNodeModel<EditorNode>(std::move(root)) {} |
| 67 | 68 |
| 68 void SetTitle(ui::TreeModelNode* node, | 69 void SetTitle(ui::TreeModelNode* node, |
| 69 const base::string16& title) override; | 70 const base::string16& title) override; |
| 70 | 71 |
| 71 private: | 72 private: |
| 72 DISALLOW_COPY_AND_ASSIGN(EditorTreeModel); | 73 DISALLOW_COPY_AND_ASSIGN(EditorTreeModel); |
| 73 }; | 74 }; |
| 74 | 75 |
| 75 BookmarkEditorView(Profile* profile, | 76 BookmarkEditorView(Profile* profile, |
| 76 const bookmarks::BookmarkNode* parent, | 77 const bookmarks::BookmarkNode* parent, |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 // Resets the model of the tree and updates the various buttons appropriately. | 163 // Resets the model of the tree and updates the various buttons appropriately. |
| 163 void Reset(); | 164 void Reset(); |
| 164 | 165 |
| 165 // Expands all the nodes in the tree and selects the parent node of the | 166 // Expands all the nodes in the tree and selects the parent node of the |
| 166 // url we're editing or the most recent parent if the url being editted isn't | 167 // url we're editing or the most recent parent if the url being editted isn't |
| 167 // starred. | 168 // starred. |
| 168 void ExpandAndSelect(); | 169 void ExpandAndSelect(); |
| 169 | 170 |
| 170 // Creates a returns the new root node. This invokes CreateNodes to do | 171 // Creates a returns the new root node. This invokes CreateNodes to do |
| 171 // the real work. | 172 // the real work. |
| 172 EditorNode* CreateRootNode(); | 173 std::unique_ptr<EditorNode> CreateRootNode(); |
| 173 | 174 |
| 174 // Adds and creates a child node in b_node for all children of bb_node that | 175 // Adds and creates a child node in b_node for all children of bb_node that |
| 175 // are folders. | 176 // are folders. |
| 176 void CreateNodes(const bookmarks::BookmarkNode* bb_node, EditorNode* b_node); | 177 void CreateNodes(const bookmarks::BookmarkNode* bb_node, EditorNode* b_node); |
| 177 | 178 |
| 178 // Returns the node with the specified id, or NULL if one can't be found. | 179 // Returns the node with the specified id, or NULL if one can't be found. |
| 179 EditorNode* FindNodeWithID(BookmarkEditorView::EditorNode* node, int64_t id); | 180 EditorNode* FindNodeWithID(BookmarkEditorView::EditorNode* node, int64_t id); |
| 180 | 181 |
| 181 // Invokes ApplyEdits with the selected node. | 182 // Invokes ApplyEdits with the selected node. |
| 182 void ApplyEdits(); | 183 void ApplyEdits(); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 202 | 203 |
| 203 // Returns the current url the user has input. | 204 // Returns the current url the user has input. |
| 204 GURL GetInputURL() const; | 205 GURL GetInputURL() const; |
| 205 | 206 |
| 206 // Invoked when the url or title has possibly changed. Updates the background | 207 // Invoked when the url or title has possibly changed. Updates the background |
| 207 // of Textfields and ok button appropriately. | 208 // of Textfields and ok button appropriately. |
| 208 void UserInputChanged(); | 209 void UserInputChanged(); |
| 209 | 210 |
| 210 // Creates a new folder as a child of the selected node. If no node is | 211 // Creates a new folder as a child of the selected node. If no node is |
| 211 // selected, the new folder is added as a child of the bookmark node. Starts | 212 // selected, the new folder is added as a child of the bookmark node. Starts |
| 212 // editing on the new gorup as well. | 213 // editing on the new group as well. |
| 213 void NewFolder(); | 214 void NewFolder(); |
| 214 | 215 |
| 215 // Creates a new EditorNode as the last child of parent. The new node is | 216 // Creates a new EditorNode as the last child of parent. The new node is |
| 216 // added to the model and returned. This does NOT start editing. This is used | 217 // added to the model and returned. This does NOT start editing. This is used |
| 217 // internally by NewFolder and broken into a separate method for testing. | 218 // internally by NewFolder and broken into a separate method for testing. |
| 218 EditorNode* AddNewFolder(EditorNode* parent); | 219 EditorNode* AddNewFolder(EditorNode* parent); |
| 219 | 220 |
| 220 // If |editor_node| is expanded it's added to |expanded_nodes| and this is | 221 // If |editor_node| is expanded it's added to |expanded_nodes| and this is |
| 221 // recursively invoked for all the children. | 222 // recursively invoked for all the children. |
| 222 void UpdateExpandedNodes( | 223 void UpdateExpandedNodes( |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 // Is the tree shown? | 270 // Is the tree shown? |
| 270 bool show_tree_; | 271 bool show_tree_; |
| 271 | 272 |
| 272 // List of deleted bookmark folders. | 273 // List of deleted bookmark folders. |
| 273 std::vector<int64_t> deletes_; | 274 std::vector<int64_t> deletes_; |
| 274 | 275 |
| 275 DISALLOW_COPY_AND_ASSIGN(BookmarkEditorView); | 276 DISALLOW_COPY_AND_ASSIGN(BookmarkEditorView); |
| 276 }; | 277 }; |
| 277 | 278 |
| 278 #endif // CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_EDITOR_VIEW_H_ | 279 #endif // CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_EDITOR_VIEW_H_ |
| OLD | NEW |