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