OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_BOOKMARKS_BOOKMARK_EDITOR_H_ | 5 #ifndef CHROME_BROWSER_UI_BOOKMARKS_BOOKMARK_EDITOR_H_ |
6 #define CHROME_BROWSER_UI_BOOKMARKS_BOOKMARK_EDITOR_H_ | 6 #define CHROME_BROWSER_UI_BOOKMARKS_BOOKMARK_EDITOR_H_ |
7 | 7 |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 17 matching lines...) Expand all Loading... |
28 // If Configuration is SHOW_TREE, a tree is shown allowing the user to | 28 // If Configuration is SHOW_TREE, a tree is shown allowing the user to |
29 // choose the parent of the node. | 29 // choose the parent of the node. |
30 SHOW_TREE, | 30 SHOW_TREE, |
31 NO_TREE | 31 NO_TREE |
32 }; | 32 }; |
33 | 33 |
34 // Describes what the user is editing. | 34 // Describes what the user is editing. |
35 class EditDetails { | 35 class EditDetails { |
36 public: | 36 public: |
37 // Returns the type of the existing or new node. | 37 // Returns the type of the existing or new node. |
38 BookmarkNode::Type GetNodeType() const; | 38 bookmarks::BookmarkNode::Type GetNodeType() const; |
39 | 39 |
40 // Returns the resource id for the string resource to use on the window | 40 // Returns the resource id for the string resource to use on the window |
41 // title for this edit operation. | 41 // title for this edit operation. |
42 int GetWindowTitleId() const; | 42 int GetWindowTitleId() const; |
43 | 43 |
44 // Returns an EditDetails instance for the user editing the given bookmark. | 44 // Returns an EditDetails instance for the user editing the given bookmark. |
45 static EditDetails EditNode(const BookmarkNode* node); | 45 static EditDetails EditNode(const bookmarks::BookmarkNode* node); |
46 | 46 |
47 // Returns an EditDetails instance for the user adding a bookmark within | 47 // Returns an EditDetails instance for the user adding a bookmark within |
48 // a given parent node with a specified index. | 48 // a given parent node with a specified index. |
49 static EditDetails AddNodeInFolder(const BookmarkNode* parent_node, | 49 static EditDetails AddNodeInFolder( |
50 int index, | 50 const bookmarks::BookmarkNode* parent_node, |
51 const GURL& url, | 51 int index, |
52 const base::string16& title); | 52 const GURL& url, |
| 53 const base::string16& title); |
53 | 54 |
54 // Returns an EditDetails instance for the user adding a folder within a | 55 // Returns an EditDetails instance for the user adding a folder within a |
55 // given parent node with a specified index. | 56 // given parent node with a specified index. |
56 static EditDetails AddFolder(const BookmarkNode* parent_node, | 57 static EditDetails AddFolder(const bookmarks::BookmarkNode* parent_node, |
57 int index); | 58 int index); |
58 | 59 |
59 enum Type { | 60 enum Type { |
60 // The user is editing an existing node in the model. The node the user | 61 // The user is editing an existing node in the model. The node the user |
61 // is editing is set in |existing_node|. | 62 // is editing is set in |existing_node|. |
62 EXISTING_NODE, | 63 EXISTING_NODE, |
63 | 64 |
64 // A new bookmark should be created if the user accepts the edit. | 65 // A new bookmark should be created if the user accepts the edit. |
65 // |existing_node| is null in this case. | 66 // |existing_node| is null in this case. |
66 NEW_URL, | 67 NEW_URL, |
67 | 68 |
68 // A new folder bookmark should be created if the user accepts the edit. | 69 // A new folder bookmark should be created if the user accepts the edit. |
69 // The contents of the folder should be that of |urls|. | 70 // The contents of the folder should be that of |urls|. |
70 // |existing_node| is null in this case. | 71 // |existing_node| is null in this case. |
71 NEW_FOLDER | 72 NEW_FOLDER |
72 }; | 73 }; |
73 | 74 |
74 ~EditDetails(); | 75 ~EditDetails(); |
75 | 76 |
76 // See description of enum value for details. | 77 // See description of enum value for details. |
77 const Type type; | 78 const Type type; |
78 | 79 |
79 // If type == EXISTING_NODE this gives the existing node. | 80 // If type == EXISTING_NODE this gives the existing node. |
80 const BookmarkNode* existing_node; | 81 const bookmarks::BookmarkNode* existing_node; |
81 | 82 |
82 // If type == NEW_URL or type == NEW_FOLDER this gives the initial parent | 83 // If type == NEW_URL or type == NEW_FOLDER this gives the initial parent |
83 // node to place the new node in. | 84 // node to place the new node in. |
84 const BookmarkNode* parent_node; | 85 const bookmarks::BookmarkNode* parent_node; |
85 | 86 |
86 // If type == NEW_URL or type == NEW_FOLDER this gives the index to insert | 87 // If type == NEW_URL or type == NEW_FOLDER this gives the index to insert |
87 // the new node at. | 88 // the new node at. |
88 int index; | 89 int index; |
89 | 90 |
90 // If type == NEW_URL this gives the URL/title. | 91 // If type == NEW_URL this gives the URL/title. |
91 GURL url; | 92 GURL url; |
92 base::string16 title; | 93 base::string16 title; |
93 | 94 |
94 // If type == NEW_FOLDER, this is the urls/title pairs to add to the | 95 // If type == NEW_FOLDER, this is the urls/title pairs to add to the |
95 // folder. | 96 // folder. |
96 std::vector<std::pair<GURL, base::string16> > urls; | 97 std::vector<std::pair<GURL, base::string16> > urls; |
97 | 98 |
98 private: | 99 private: |
99 explicit EditDetails(Type node_type); | 100 explicit EditDetails(Type node_type); |
100 }; | 101 }; |
101 | 102 |
102 // Shows the bookmark editor. The bookmark editor allows editing an existing | 103 // Shows the bookmark editor. The bookmark editor allows editing an existing |
103 // node or creating a new bookmark node (as determined by |details.type|). | 104 // node or creating a new bookmark node (as determined by |details.type|). |
104 // |details.parent_node| is only used if |details.existing_node| is null. | 105 // |details.parent_node| is only used if |details.existing_node| is null. |
105 static void Show(gfx::NativeWindow parent_window, | 106 static void Show(gfx::NativeWindow parent_window, |
106 Profile* profile, | 107 Profile* profile, |
107 const EditDetails& details, | 108 const EditDetails& details, |
108 Configuration configuration); | 109 Configuration configuration); |
109 | 110 |
110 // Modifies a bookmark node (assuming that there's no magic that needs to be | 111 // Modifies a bookmark node (assuming that there's no magic that needs to be |
111 // done regarding moving from one folder to another). If a new node is | 112 // done regarding moving from one folder to another). If a new node is |
112 // explicitly being added, returns a pointer to the new node that was created. | 113 // explicitly being added, returns a pointer to the new node that was created. |
113 // Otherwise the return value is identically |node|. | 114 // Otherwise the return value is identically |node|. |
114 static const BookmarkNode* ApplyEditsWithNoFolderChange( | 115 static const bookmarks::BookmarkNode* ApplyEditsWithNoFolderChange( |
115 bookmarks::BookmarkModel* model, | 116 bookmarks::BookmarkModel* model, |
116 const BookmarkNode* parent, | 117 const bookmarks::BookmarkNode* parent, |
117 const EditDetails& details, | 118 const EditDetails& details, |
118 const base::string16& new_title, | 119 const base::string16& new_title, |
119 const GURL& new_url); | 120 const GURL& new_url); |
120 | 121 |
121 // Modifies a bookmark node assuming that the parent of the node may have | 122 // Modifies a bookmark node assuming that the parent of the node may have |
122 // changed and the node will need to be removed and reinserted. If a new node | 123 // changed and the node will need to be removed and reinserted. If a new node |
123 // is explicitly being added, returns a pointer to the new node that was | 124 // is explicitly being added, returns a pointer to the new node that was |
124 // created. Otherwise the return value is identically |node|. | 125 // created. Otherwise the return value is identically |node|. |
125 static const BookmarkNode* ApplyEditsWithPossibleFolderChange( | 126 static const bookmarks::BookmarkNode* ApplyEditsWithPossibleFolderChange( |
126 bookmarks::BookmarkModel* model, | 127 bookmarks::BookmarkModel* model, |
127 const BookmarkNode* new_parent, | 128 const bookmarks::BookmarkNode* new_parent, |
128 const EditDetails& details, | 129 const EditDetails& details, |
129 const base::string16& new_title, | 130 const base::string16& new_title, |
130 const GURL& new_url); | 131 const GURL& new_url); |
131 }; | 132 }; |
132 | 133 |
133 #endif // CHROME_BROWSER_UI_BOOKMARKS_BOOKMARK_EDITOR_H_ | 134 #endif // CHROME_BROWSER_UI_BOOKMARKS_BOOKMARK_EDITOR_H_ |
OLD | NEW |