| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 | 7 |
| 8 #include <string> |
| 9 #include <utility> |
| 10 #include <vector> |
| 11 |
| 8 #include "app/gfx/native_widget_types.h" | 12 #include "app/gfx/native_widget_types.h" |
| 9 | 13 |
| 10 class BookmarkNode; | 14 class BookmarkNode; |
| 15 class GURL; |
| 11 class Profile; | 16 class Profile; |
| 12 | 17 |
| 13 // Small, cross platform interface that shows the correct platform specific | 18 // Small, cross platform interface that shows the correct platform specific |
| 14 // bookmark editor dialog. | 19 // bookmark editor dialog. |
| 15 class BookmarkEditor { | 20 class BookmarkEditor { |
| 16 public: | 21 public: |
| 17 // Handler is notified when the BookmarkEditor creates a new bookmark. | 22 // Handler is notified when the BookmarkEditor creates a new bookmark. |
| 18 // Handler is owned by the BookmarkEditor and deleted when it is deleted. | 23 // Handler is owned by the BookmarkEditor and deleted when it is deleted. |
| 19 class Handler { | 24 class Handler { |
| 20 public: | 25 public: |
| 21 virtual ~Handler() {} | 26 virtual ~Handler() {} |
| 22 virtual void NodeCreated(const BookmarkNode* new_node) = 0; | 27 virtual void NodeCreated(const BookmarkNode* new_node) = 0; |
| 23 }; | 28 }; |
| 24 | 29 |
| 25 // An enumeration of the possible configurations offered. | 30 // An enumeration of the possible configurations offered. |
| 26 enum Configuration { | 31 enum Configuration { |
| 27 SHOW_TREE, | 32 SHOW_TREE, |
| 28 NO_TREE | 33 NO_TREE |
| 29 }; | 34 }; |
| 30 | 35 |
| 31 // Shows the platform specific BookmarkEditor subclass editing |node|. |node| | 36 // Describes what the user is editing. |
| 32 // may be one of three values: | 37 struct EditDetails { |
| 33 // . NULL, in which a case a new entry is created initially parented to | 38 enum Type { |
| 34 // |parent|. | 39 // The user is editing an existing node in the model. The node the user |
| 35 // . non-null and a url. | 40 // is editing is set in |existing_node|. |
| 36 // . non-null and a folder. In this case the url field is not shown and an | 41 EXISTING_NODE, |
| 37 // entry for the node is not shown in the tree. | 42 |
| 38 // If |show_tree| is false the tree is not shown. BookmarkEditor takes | 43 // A new bookmark should be created if the user accepts the edit. |
| 39 // ownership of |handler| and deletes it when done. |handler| may be | 44 // |existing_node| is null in this case. |
| 40 // null. See description of Handler for details. | 45 NEW_URL, |
| 46 |
| 47 // A new folder bookmark should be created if the user accepts the edit. |
| 48 // The contents of the folder should be that of |urls|. |
| 49 // |existing_node| is null in this case. |
| 50 NEW_FOLDER |
| 51 }; |
| 52 |
| 53 EditDetails() : type(NEW_URL), existing_node(NULL) {} |
| 54 |
| 55 explicit EditDetails(const BookmarkNode* node) |
| 56 : type(EXISTING_NODE), |
| 57 existing_node(node) { |
| 58 } |
| 59 |
| 60 // See description of enum value for details. |
| 61 Type type; |
| 62 |
| 63 // If type == EXISTING_NODE this gives the existing node. |
| 64 const BookmarkNode* existing_node; |
| 65 |
| 66 // If type == NEW_FOLDER, this is the urls/title pairs to add to the |
| 67 // folder. |
| 68 std::vector<std::pair<GURL, std::wstring> > urls; |
| 69 }; |
| 70 |
| 71 // Shows the bookmark editor. The bookmark editor allows editing an |
| 72 // existing node or creating a new bookmark node (as determined by |
| 73 // |details.type|). If |configuration| is SHOW_TREE, a tree is shown allowing |
| 74 // the user to choose the parent of the node. |
| 75 // |parent| gives the initial parent to select in the tree for the node. |
| 76 // |parent| is only used if |details.existing_node| is null. |
| 77 // BookmarkEditor takes ownership of |handler| and deletes it when done. |
| 78 // |handler| may be null. See description of Handler for details. |
| 41 static void Show(gfx::NativeWindow parent_window, | 79 static void Show(gfx::NativeWindow parent_window, |
| 42 Profile* profile, | 80 Profile* profile, |
| 43 const BookmarkNode* parent, | 81 const BookmarkNode* parent, |
| 44 const BookmarkNode* node, | 82 const EditDetails& details, |
| 45 Configuration configuration, | 83 Configuration configuration, |
| 46 Handler* handler); | 84 Handler* handler); |
| 47 }; | 85 }; |
| 48 | 86 |
| 49 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_EDITOR_H_ | 87 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_EDITOR_H_ |
| OLD | NEW |