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

Side by Side Diff: chrome/browser/extensions/api/bookmarks/bookmarks_api.h

Issue 308273002: Made the bookmarks extension APIs aware of managed bookmarks. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 6 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_EXTENSIONS_API_BOOKMARKS_BOOKMARKS_API_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_BOOKMARKS_BOOKMARKS_API_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_BOOKMARKS_BOOKMARKS_API_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_BOOKMARKS_BOOKMARKS_API_H_
7 7
8 #include <list> 8 #include <list>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "chrome/browser/extensions/chrome_extension_function.h" 14 #include "chrome/browser/extensions/chrome_extension_function.h"
15 #include "components/bookmarks/browser/base_bookmark_model_observer.h" 15 #include "components/bookmarks/browser/base_bookmark_model_observer.h"
16 #include "components/bookmarks/browser/bookmark_node.h" 16 #include "components/bookmarks/browser/bookmark_node.h"
17 #include "extensions/browser/browser_context_keyed_api_factory.h" 17 #include "extensions/browser/browser_context_keyed_api_factory.h"
18 #include "extensions/browser/event_router.h" 18 #include "extensions/browser/event_router.h"
19 #include "ui/shell_dialogs/select_file_dialog.h" 19 #include "ui/shell_dialogs/select_file_dialog.h"
20 20
21 class ChromeBookmarkClient;
22
21 namespace base { 23 namespace base {
22 class FilePath; 24 class FilePath;
23 class ListValue; 25 class ListValue;
24 } 26 }
25 27
26 namespace content { 28 namespace content {
27 class BrowserContext; 29 class BrowserContext;
28 } 30 }
29 31
30 namespace extensions { 32 namespace extensions {
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 public: 120 public:
119 // AsyncExtensionFunction: 121 // AsyncExtensionFunction:
120 virtual bool RunAsync() OVERRIDE; 122 virtual bool RunAsync() OVERRIDE;
121 123
122 protected: 124 protected:
123 virtual ~BookmarksFunction() {} 125 virtual ~BookmarksFunction() {}
124 126
125 // RunAsync semantic equivalent called when the bookmarks are ready. 127 // RunAsync semantic equivalent called when the bookmarks are ready.
126 virtual bool RunOnReady() = 0; 128 virtual bool RunOnReady() = 0;
127 129
130 // Helper to get the ChromeBookmarkClient.
131 ChromeBookmarkClient* GetChromeBookmarkClient();
132
128 // Helper to get the bookmark id as int64 from the given string id. 133 // Helper to get the bookmark id as int64 from the given string id.
129 // Sets error_ to an error string if the given id string can't be parsed 134 // Sets error_ to an error string if the given id string can't be parsed
130 // as an int64. In case of error, doesn't change id and returns false. 135 // as an int64. In case of error, doesn't change id and returns false.
131 bool GetBookmarkIdAsInt64(const std::string& id_string, int64* id); 136 bool GetBookmarkIdAsInt64(const std::string& id_string, int64* id);
132 137
133 // Helper to get the bookmark node from a given string id. 138 // Helper to get the bookmark node from a given string id.
134 // If the given id can't be parsed or doesn't refer to a valid node, sets 139 // If the given id can't be parsed or doesn't refer to a valid node, sets
135 // error_ and returns NULL. 140 // error_ and returns NULL.
136 const BookmarkNode* GetBookmarkNodeFromId(const std::string& id_string); 141 const BookmarkNode* GetBookmarkNodeFromId(const std::string& id_string);
137 142
138 // Helper to create a bookmark node from a CreateDetails object. If a node 143 // Helper to create a bookmark node from a CreateDetails object. If a node
139 // can't be created based on the given details, sets error_ and returns NULL. 144 // can't be created based on the given details, sets error_ and returns NULL.
140 const BookmarkNode* CreateBookmarkNode( 145 const BookmarkNode* CreateBookmarkNode(
141 BookmarkModel* model, 146 BookmarkModel* model,
142 const api::bookmarks::CreateDetails& details, 147 const api::bookmarks::CreateDetails& details,
143 const BookmarkNode::MetaInfoMap* meta_info); 148 const BookmarkNode::MetaInfoMap* meta_info);
144 149
145 // Helper that checks if bookmark editing is enabled. If it's not, this sets 150 // Helper that checks if bookmark editing is enabled. If it's not, this sets
146 // error_ to the appropriate error string. 151 // error_ to the appropriate error string.
147 bool EditBookmarksEnabled(); 152 bool EditBookmarksEnabled();
148 153
154 // Helper that checks if |node| can be modified. Returns false if |node|
155 // is NULL, or a managed node, or the root node. In these cases the node
156 // can't be edited, can't have new child nodes appended, and its direct
157 // children can't be moved or reordered.
158 bool CanBeModified(const BookmarkNode* node);
159
149 private: 160 private:
150 // BaseBookmarkModelObserver: 161 // BaseBookmarkModelObserver:
151 virtual void BookmarkModelChanged() OVERRIDE; 162 virtual void BookmarkModelChanged() OVERRIDE;
152 virtual void BookmarkModelLoaded(BookmarkModel* model, 163 virtual void BookmarkModelLoaded(BookmarkModel* model,
153 bool ids_reassigned) OVERRIDE; 164 bool ids_reassigned) OVERRIDE;
154 }; 165 };
155 166
156 class BookmarksGetFunction : public BookmarksFunction { 167 class BookmarksGetFunction : public BookmarksFunction {
157 public: 168 public:
158 DECLARE_EXTENSION_FUNCTION("bookmarks.get", BOOKMARKS_GET) 169 DECLARE_EXTENSION_FUNCTION("bookmarks.get", BOOKMARKS_GET)
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 private: 365 private:
355 virtual ~BookmarksExportFunction() {} 366 virtual ~BookmarksExportFunction() {}
356 367
357 // BookmarksFunction: 368 // BookmarksFunction:
358 virtual bool RunOnReady() OVERRIDE; 369 virtual bool RunOnReady() OVERRIDE;
359 }; 370 };
360 371
361 } // namespace extensions 372 } // namespace extensions
362 373
363 #endif // CHROME_BROWSER_EXTENSIONS_API_BOOKMARKS_BOOKMARKS_API_H_ 374 #endif // CHROME_BROWSER_EXTENSIONS_API_BOOKMARKS_BOOKMARKS_API_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/bookmarks/bookmark_apitest.cc ('k') | chrome/browser/extensions/api/bookmarks/bookmarks_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698