Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 static EditDetails EditNode(const BookmarkNode* node); | |
|
Rick Byers
2011/08/18 19:25:30
Nice, I like this change.
Add comments to these m
flackr
2011/08/23 17:41:44
Done.
| |
| 33 static EditDetails AddNodeInFolder(const BookmarkNode* parent_node); | |
| 34 static EditDetails AddFolder(const BookmarkNode* parent_node); | |
| 35 | |
| 31 enum Type { | 36 enum Type { |
| 32 // The user is editing an existing node in the model. The node the user | 37 // The user is editing an existing node in the model. The node the user |
| 33 // is editing is set in |existing_node|. | 38 // is editing is set in |existing_node|. |
| 34 EXISTING_NODE, | 39 EXISTING_NODE, |
| 35 | 40 |
| 36 // A new bookmark should be created if the user accepts the edit. | 41 // A new bookmark should be created if the user accepts the edit. |
| 37 // |existing_node| is null in this case. | 42 // |existing_node| is null in this case. |
| 38 NEW_URL, | 43 NEW_URL, |
| 39 | 44 |
| 40 // A new folder bookmark should be created if the user accepts the edit. | 45 // A new folder bookmark should be created if the user accepts the edit. |
| 41 // The contents of the folder should be that of |urls|. | 46 // The contents of the folder should be that of |urls|. |
| 42 // |existing_node| is null in this case. | 47 // |existing_node| is null in this case. |
| 43 NEW_FOLDER | 48 NEW_FOLDER |
| 44 }; | 49 }; |
| 45 | 50 |
| 46 EditDetails(); | |
| 47 explicit EditDetails(const BookmarkNode* node); | |
| 48 ~EditDetails(); | 51 ~EditDetails(); |
| 49 | 52 |
| 50 // See description of enum value for details. | 53 // See description of enum value for details. |
| 51 Type type; | 54 Type type; |
|
Rick Byers
2011/08/18 19:25:30
Could you make the fields const now (eg. by having
flackr
2011/08/23 17:41:44
Done.
| |
| 52 | 55 |
| 53 // If type == EXISTING_NODE this gives the existing node. | 56 // If type == EXISTING_NODE this gives the existing node. |
| 54 const BookmarkNode* existing_node; | 57 const BookmarkNode* existing_node; |
| 55 | 58 |
| 59 // If type == NEW_URL or type == NEW_FOLDER this gives the parent node | |
| 60 // to place the new node in. | |
| 61 const BookmarkNode* parent_node; | |
| 62 | |
| 56 // If type == NEW_FOLDER, this is the urls/title pairs to add to the | 63 // If type == NEW_FOLDER, this is the urls/title pairs to add to the |
| 57 // folder. | 64 // folder. |
| 58 std::vector<std::pair<GURL, string16> > urls; | 65 std::vector<std::pair<GURL, string16> > urls; |
| 66 | |
| 67 private: | |
| 68 EditDetails(); | |
|
Rick Byers
2011/08/18 19:25:30
nice
| |
| 59 }; | 69 }; |
| 60 | 70 |
| 61 // Shows the bookmark editor. The bookmark editor allows editing an | 71 // Shows the native bookmark editor. The bookmark editor allows editing an |
| 62 // existing node or creating a new bookmark node (as determined by | 72 // existing node or creating a new bookmark node (as determined by |
| 63 // |details.type|). If |configuration| is SHOW_TREE, a tree is shown allowing | 73 // |details.type|). If |configuration| is SHOW_TREE, a tree is shown allowing |
| 64 // the user to choose the parent of the node. | 74 // the user to choose the parent of the node. |
| 65 // |parent| gives the initial parent to select in the tree for the node. | 75 // |parent| gives the initial parent to select in the tree for the node. |
| 66 // |parent| is only used if |details.existing_node| is null. | 76 // |parent| is only used if |details.existing_node| is null. |
| 67 // TODO(flackr): Rename this to ShowNative and add cross platform Show method | 77 static void ShowNative(gfx::NativeWindow parent_window, |
|
Rick Byers
2011/08/18 19:25:30
This can be private now (or soon), right? It woul
flackr
2011/08/23 17:41:44
Done.
| |
| 68 // which will show a WebUI version of the dialog if --pure-views is set. | 78 Profile* profile, |
| 79 const BookmarkNode* parent, | |
| 80 const EditDetails& details, | |
| 81 Configuration configuration); | |
| 82 | |
| 83 // Shows the bookmark editor. If --use-more-webui is enabled use the bookmark | |
| 84 // manager to add or edit bookmarks. | |
|
Rick Byers
2011/08/18 19:25:30
add/move the detailed description of the args from
flackr
2011/08/23 17:41:44
Done.
| |
| 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); |
| 74 }; | 89 }; |
| 75 | 90 |
| 76 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_EDITOR_H_ | 91 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_EDITOR_H_ |
| OLD | NEW |