| OLD | NEW |
| 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 | |
| 23 namespace base { | 21 namespace base { |
| 24 class FilePath; | 22 class FilePath; |
| 25 class ListValue; | 23 class ListValue; |
| 26 } | 24 } |
| 27 | 25 |
| 26 namespace bookmarks { |
| 27 class BookmarkModel; |
| 28 class ManagedBookmarkService; |
| 29 } |
| 30 |
| 28 namespace content { | 31 namespace content { |
| 29 class BrowserContext; | 32 class BrowserContext; |
| 30 } | 33 } |
| 31 | 34 |
| 32 namespace extensions { | 35 namespace extensions { |
| 33 | 36 |
| 34 namespace api { | 37 namespace api { |
| 35 namespace bookmarks { | 38 namespace bookmarks { |
| 36 struct CreateDetails; | 39 struct CreateDetails; |
| 37 } | 40 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 bookmarks::BookmarkModel* model) override; | 77 bookmarks::BookmarkModel* model) override; |
| 75 void ExtensiveBookmarkChangesEnded(bookmarks::BookmarkModel* model) override; | 78 void ExtensiveBookmarkChangesEnded(bookmarks::BookmarkModel* model) override; |
| 76 | 79 |
| 77 private: | 80 private: |
| 78 // Helper to actually dispatch an event to extension listeners. | 81 // Helper to actually dispatch an event to extension listeners. |
| 79 void DispatchEvent(const std::string& event_name, | 82 void DispatchEvent(const std::string& event_name, |
| 80 scoped_ptr<base::ListValue> event_args); | 83 scoped_ptr<base::ListValue> event_args); |
| 81 | 84 |
| 82 content::BrowserContext* browser_context_; | 85 content::BrowserContext* browser_context_; |
| 83 bookmarks::BookmarkModel* model_; | 86 bookmarks::BookmarkModel* model_; |
| 84 ChromeBookmarkClient* client_; | 87 bookmarks::ManagedBookmarkService* managed_; |
| 85 | 88 |
| 86 DISALLOW_COPY_AND_ASSIGN(BookmarkEventRouter); | 89 DISALLOW_COPY_AND_ASSIGN(BookmarkEventRouter); |
| 87 }; | 90 }; |
| 88 | 91 |
| 89 class BookmarksAPI : public BrowserContextKeyedAPI, | 92 class BookmarksAPI : public BrowserContextKeyedAPI, |
| 90 public EventRouter::Observer { | 93 public EventRouter::Observer { |
| 91 public: | 94 public: |
| 92 explicit BookmarksAPI(content::BrowserContext* context); | 95 explicit BookmarksAPI(content::BrowserContext* context); |
| 93 ~BookmarksAPI() override; | 96 ~BookmarksAPI() override; |
| 94 | 97 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 124 | 127 |
| 125 protected: | 128 protected: |
| 126 ~BookmarksFunction() override {} | 129 ~BookmarksFunction() override {} |
| 127 | 130 |
| 128 // RunAsync semantic equivalent called when the bookmarks are ready. | 131 // RunAsync semantic equivalent called when the bookmarks are ready. |
| 129 virtual bool RunOnReady() = 0; | 132 virtual bool RunOnReady() = 0; |
| 130 | 133 |
| 131 // Helper to get the BookmarkModel. | 134 // Helper to get the BookmarkModel. |
| 132 bookmarks::BookmarkModel* GetBookmarkModel(); | 135 bookmarks::BookmarkModel* GetBookmarkModel(); |
| 133 | 136 |
| 134 // Helper to get the ChromeBookmarkClient. | 137 // Helper to get the ManagedBookmarkService. |
| 135 ChromeBookmarkClient* GetChromeBookmarkClient(); | 138 bookmarks::ManagedBookmarkService* GetManagedBookmarkService(); |
| 136 | 139 |
| 137 // Helper to get the bookmark id as int64 from the given string id. | 140 // Helper to get the bookmark id as int64 from the given string id. |
| 138 // Sets error_ to an error string if the given id string can't be parsed | 141 // Sets error_ to an error string if the given id string can't be parsed |
| 139 // as an int64. In case of error, doesn't change id and returns false. | 142 // as an int64. In case of error, doesn't change id and returns false. |
| 140 bool GetBookmarkIdAsInt64(const std::string& id_string, int64* id); | 143 bool GetBookmarkIdAsInt64(const std::string& id_string, int64* id); |
| 141 | 144 |
| 142 // Helper to get the bookmark node from a given string id. | 145 // Helper to get the bookmark node from a given string id. |
| 143 // If the given id can't be parsed or doesn't refer to a valid node, sets | 146 // If the given id can't be parsed or doesn't refer to a valid node, sets |
| 144 // error_ and returns NULL. | 147 // error_ and returns NULL. |
| 145 const bookmarks::BookmarkNode* GetBookmarkNodeFromId( | 148 const bookmarks::BookmarkNode* GetBookmarkNodeFromId( |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 private: | 362 private: |
| 360 ~BookmarksExportFunction() override {} | 363 ~BookmarksExportFunction() override {} |
| 361 | 364 |
| 362 // BookmarksFunction: | 365 // BookmarksFunction: |
| 363 bool RunOnReady() override; | 366 bool RunOnReady() override; |
| 364 }; | 367 }; |
| 365 | 368 |
| 366 } // namespace extensions | 369 } // namespace extensions |
| 367 | 370 |
| 368 #endif // CHROME_BROWSER_EXTENSIONS_API_BOOKMARKS_BOOKMARKS_API_H_ | 371 #endif // CHROME_BROWSER_EXTENSIONS_API_BOOKMARKS_BOOKMARKS_API_H_ |
| OLD | NEW |