1 // Copyright (c) 2010 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. 4 5 #ifndef CHROME_BROWSER_BOOKMARKS_BOOKMARK_EDITOR_H_ 6 #define CHROME_BROWSER_BOOKMARKS_BOOKMARK_EDITOR_H_ 7 #pragma once 8 9 #include <utility> 10 #include <vector> 11 12 #include "base/string16.h" 13 #include "ui/gfx/native_widget_types.h" 14 15 class BookmarkNode; 16 class GURL; 17 class Profile; 18 19 // Small, cross platform interface that shows the correct platform specific 20 // bookmark editor dialog. 21 class BookmarkEditor { 22 public: 23 // An enumeration of the possible configurations offered. 24 enum Configuration { 25 SHOW_TREE, 26 NO_TREE 27 }; 28 29 // Describes what the user is editing. 30 struct EditDetails { 31 enum Type { 32 // The user is editing an existing node in the model. The node the user 33 // is editing is set in |existing_node|. 34 EXISTING_NODE, 35 36 // A new bookmark should be created if the user accepts the edit. 37 // |existing_node| is null in this case. 38 NEW_URL, 39 40 // A new folder bookmark should be created if the user accepts the edit. 41 // The contents of the folder should be that of |urls|. 42 // |existing_node| is null in this case. 43 NEW_FOLDER 44 }; 45 46 EditDetails(); 47 explicit EditDetails(const BookmarkNode* node); 48 ~EditDetails(); 49 50 // See description of enum value for details. 51 Type type; 52 53 // If type == EXISTING_NODE this gives the existing node. 54 const BookmarkNode* existing_node; 55 56 // If type == NEW_FOLDER, this is the urls/title pairs to add to the 57 // folder. 58 std::vector<std::pair<GURL, string16> > urls; 59 }; 60 61 // Shows the bookmark editor. The bookmark editor allows editing an 62 // existing node or creating a new bookmark node (as determined by 63 // |details.type|). If |configuration| is SHOW_TREE, a tree is shown allowing 64 // the user to choose the parent of the node. 65 // |parent| gives the initial parent to select in the tree for the node. 66 // |parent| is only used if |details.existing_node| is null. 67 static void Show(gfx::NativeWindow parent_window, 68 Profile* profile, 69 const BookmarkNode* parent, 70 const EditDetails& details, 71 Configuration configuration); 72 }; 73 74 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_EDITOR_H_ 75