Add a minor text member to ui::MenuModel.
[chromium-blink-merge.git] / chrome / browser / ui / bookmarks / bookmark_editor.h
blob75f0f9be0d715f0d5b0df0c06b202ac4dd9738f1
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_BOOKMARKS_BOOKMARK_EDITOR_H_
6 #define CHROME_BROWSER_UI_BOOKMARKS_BOOKMARK_EDITOR_H_
8 #include <utility>
9 #include <vector>
11 #include "base/strings/string16.h"
12 #include "chrome/browser/bookmarks/bookmark_model.h"
13 #include "ui/gfx/native_widget_types.h"
15 class GURL;
16 class Profile;
18 // Small, cross platform interface that shows the correct platform specific
19 // bookmark editor dialog.
20 class BookmarkEditor {
21 public:
22 // An enumeration of the possible configurations offered.
23 enum Configuration {
24 // If Configuration is SHOW_TREE, a tree is shown allowing the user to
25 // choose the parent of the node.
26 SHOW_TREE,
27 NO_TREE
30 // Describes what the user is editing.
31 class EditDetails {
32 public:
33 // Returns the type of the existing or new node.
34 BookmarkNode::Type GetNodeType() const;
36 // Returns the resource id for the string resource to use on the window
37 // title for this edit operation.
38 int GetWindowTitleId() const;
40 // Returns an EditDetails instance for the user editing the given bookmark.
41 static EditDetails EditNode(const BookmarkNode* node);
43 // Returns an EditDetails instance for the user adding a bookmark within
44 // a given parent node with a specified index.
45 static EditDetails AddNodeInFolder(const BookmarkNode* parent_node,
46 int index,
47 const GURL& url,
48 const string16& title);
50 // Returns an EditDetails instance for the user adding a folder within a
51 // given parent node with a specified index.
52 static EditDetails AddFolder(const BookmarkNode* parent_node,
53 int index);
55 enum Type {
56 // The user is editing an existing node in the model. The node the user
57 // is editing is set in |existing_node|.
58 EXISTING_NODE,
60 // A new bookmark should be created if the user accepts the edit.
61 // |existing_node| is null in this case.
62 NEW_URL,
64 // A new folder bookmark should be created if the user accepts the edit.
65 // The contents of the folder should be that of |urls|.
66 // |existing_node| is null in this case.
67 NEW_FOLDER
70 ~EditDetails();
72 // See description of enum value for details.
73 const Type type;
75 // If type == EXISTING_NODE this gives the existing node.
76 const BookmarkNode* existing_node;
78 // If type == NEW_URL or type == NEW_FOLDER this gives the initial parent
79 // node to place the new node in.
80 const BookmarkNode* parent_node;
82 // If type == NEW_URL or type == NEW_FOLDER this gives the index to insert
83 // the new node at.
84 int index;
86 // If type == NEW_URL this gives the URL/title.
87 GURL url;
88 string16 title;
90 // If type == NEW_FOLDER, this is the urls/title pairs to add to the
91 // folder.
92 std::vector<std::pair<GURL, string16> > urls;
94 private:
95 explicit EditDetails(Type node_type);
98 // Shows the bookmark editor. The bookmark editor allows editing an existing
99 // node or creating a new bookmark node (as determined by |details.type|).
100 // |details.parent_node| is only used if |details.existing_node| is null.
101 static void Show(gfx::NativeWindow parent_window,
102 Profile* profile,
103 const EditDetails& details,
104 Configuration configuration);
106 // Modifies a bookmark node (assuming that there's no magic that needs to be
107 // done regarding moving from one folder to another). If a new node is
108 // explicitly being added, returns a pointer to the new node that was created.
109 // Otherwise the return value is identically |node|.
110 static const BookmarkNode* ApplyEditsWithNoFolderChange(
111 BookmarkModel* model,
112 const BookmarkNode* parent,
113 const EditDetails& details,
114 const base::string16& new_title,
115 const GURL& new_url);
117 // Modifies a bookmark node assuming that the parent of the node may have
118 // changed and the node will need to be removed and reinserted. If a new node
119 // is explicitly being added, returns a pointer to the new node that was
120 // created. Otherwise the return value is identically |node|.
121 static const BookmarkNode* ApplyEditsWithPossibleFolderChange(
122 BookmarkModel* model,
123 const BookmarkNode* new_parent,
124 const EditDetails& details,
125 const base::string16& new_title,
126 const GURL& new_url);
129 #endif // CHROME_BROWSER_UI_BOOKMARKS_BOOKMARK_EDITOR_H_