Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(44)

Side by Side Diff: chrome/browser/bookmarks/bookmark_editor.h

Issue 7957002: Reland add --use-more-webui runtime flag to toggle WebUI replacements for native dialogs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with trunk. Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_BOOKMARKS_BOOKMARK_EDITOR_H_ 5 #ifndef CHROME_BROWSER_BOOKMARKS_BOOKMARK_EDITOR_H_
6 #define CHROME_BROWSER_BOOKMARKS_BOOKMARK_EDITOR_H_ 6 #define CHROME_BROWSER_BOOKMARKS_BOOKMARK_EDITOR_H_
7 #pragma once 7 #pragma once
8 8
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/string16.h" 12 #include "base/string16.h"
13 #include "ui/gfx/native_widget_types.h" 13 #include "ui/gfx/native_widget_types.h"
14 14
15 class BookmarkNode; 15 class BookmarkNode;
16 class GURL; 16 class GURL;
17 class Profile; 17 class Profile;
18 18
19 // Small, cross platform interface that shows the correct platform specific 19 // Small, cross platform interface that shows the correct platform specific
20 // bookmark editor dialog. 20 // bookmark editor dialog.
21 class BookmarkEditor { 21 class BookmarkEditor {
22 public: 22 public:
23 // An enumeration of the possible configurations offered. 23 // An enumeration of the possible configurations offered.
24 enum Configuration { 24 enum Configuration {
25 SHOW_TREE, 25 SHOW_TREE,
26 NO_TREE 26 NO_TREE
27 }; 27 };
28 28
29 // Describes what the user is editing. 29 // Describes what the user is editing.
30 struct EditDetails { 30 class EditDetails {
31 public:
32 // Returns an EditDetails instance for the user editing the given bookmark.
33 static EditDetails EditNode(const BookmarkNode* node);
34
35 // Returns an EditDetails instance for the user adding a bookmark within
36 // a given parent node.
37 static EditDetails AddNodeInFolder(const BookmarkNode* parent_node);
38
39 // Returns an EditDetails instance for the user adding a folder within a
40 // given parent node.
41 static EditDetails AddFolder(const BookmarkNode* parent_node);
42
31 enum Type { 43 enum Type {
32 // The user is editing an existing node in the model. The node the user 44 // The user is editing an existing node in the model. The node the user
33 // is editing is set in |existing_node|. 45 // is editing is set in |existing_node|.
34 EXISTING_NODE, 46 EXISTING_NODE,
35 47
36 // A new bookmark should be created if the user accepts the edit. 48 // A new bookmark should be created if the user accepts the edit.
37 // |existing_node| is null in this case. 49 // |existing_node| is null in this case.
38 NEW_URL, 50 NEW_URL,
39 51
40 // A new folder bookmark should be created if the user accepts the edit. 52 // A new folder bookmark should be created if the user accepts the edit.
41 // The contents of the folder should be that of |urls|. 53 // The contents of the folder should be that of |urls|.
42 // |existing_node| is null in this case. 54 // |existing_node| is null in this case.
43 NEW_FOLDER 55 NEW_FOLDER
44 }; 56 };
45 57
46 EditDetails();
47 explicit EditDetails(const BookmarkNode* node);
48 ~EditDetails(); 58 ~EditDetails();
49 59
50 // See description of enum value for details. 60 // See description of enum value for details.
51 Type type; 61 const Type type;
52 62
53 // If type == EXISTING_NODE this gives the existing node. 63 // If type == EXISTING_NODE this gives the existing node.
54 const BookmarkNode* existing_node; 64 const BookmarkNode* existing_node;
55 65
66 // If type == NEW_URL or type == NEW_FOLDER this gives the parent node
67 // to place the new node in.
68 const BookmarkNode* parent_node;
69
56 // If type == NEW_FOLDER, this is the urls/title pairs to add to the 70 // If type == NEW_FOLDER, this is the urls/title pairs to add to the
57 // folder. 71 // folder.
58 std::vector<std::pair<GURL, string16> > urls; 72 std::vector<std::pair<GURL, string16> > urls;
73
74 private:
75 explicit EditDetails(Type node_type);
59 }; 76 };
60 77
61 // Shows the bookmark editor. The bookmark editor allows editing an 78 // Shows the bookmark editor. If --use-more-webui is enabled use the bookmark
79 // manager to add or edit bookmarks. The bookmark editor allows editing an
62 // existing node or creating a new bookmark node (as determined by 80 // existing node or creating a new bookmark node (as determined by
63 // |details.type|). If |configuration| is SHOW_TREE, a tree is shown allowing 81 // |details.type|). If |configuration| is SHOW_TREE, a tree is shown allowing
64 // the user to choose the parent of the node. 82 // the user to choose the parent of the node.
65 // |parent| gives the initial parent to select in the tree for the node. 83 // |parent| gives the initial parent to select in the tree for the node.
66 // |parent| is only used if |details.existing_node| is null. 84 // |parent| is only used if |details.existing_node| is null.
67 // TODO(flackr): Rename this to ShowNative and add cross platform Show method
68 // which will show a WebUI version of the dialog if --pure-views is set.
69 static void Show(gfx::NativeWindow parent_window, 85 static void Show(gfx::NativeWindow parent_window,
70 Profile* profile, 86 Profile* profile,
71 const BookmarkNode* parent,
72 const EditDetails& details, 87 const EditDetails& details,
73 Configuration configuration); 88 Configuration configuration);
89
90 private:
91 // Shows the native bookmark editor.
92 // TODO(flackr): Remove parent argument.
93 static void ShowNative(gfx::NativeWindow parent_window,
94 Profile* profile,
95 const BookmarkNode* parent,
96 const EditDetails& details,
97 Configuration configuration);
98
99 // Shows the WebUI bookmark editor.
100 static void ShowWebUI(Profile* profile,
101 const EditDetails& details);
74 }; 102 };
75 103
76 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_EDITOR_H_ 104 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_EDITOR_H_
OLDNEW
« no previous file with comments | « chrome/browser/bookmarks/bookmark_context_menu_controller.cc ('k') | chrome/browser/bookmarks/bookmark_editor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698