| 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/bookmarks/base_bookmark_model_observer.h" | 14 #include "chrome/browser/bookmarks/base_bookmark_model_observer.h" |
| 15 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" | 15 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" |
| 16 #include "chrome/browser/extensions/event_router.h" | 16 #include "chrome/browser/extensions/event_router.h" |
| 17 #include "chrome/browser/extensions/extension_function.h" | 17 #include "chrome/browser/extensions/extension_function.h" |
| 18 #include "ui/shell_dialogs/select_file_dialog.h" | 18 #include "ui/shell_dialogs/select_file_dialog.h" |
| 19 | 19 |
| 20 namespace base { |
| 20 class FilePath; | 21 class FilePath; |
| 21 | |
| 22 namespace base { | |
| 23 class ListValue; | 22 class ListValue; |
| 24 } | 23 } |
| 25 | 24 |
| 26 namespace extensions { | 25 namespace extensions { |
| 27 | 26 |
| 28 // Observes BookmarkModel and then routes the notifications as events to | 27 // Observes BookmarkModel and then routes the notifications as events to |
| 29 // the extension system. | 28 // the extension system. |
| 30 class BookmarkEventRouter : public BookmarkModelObserver { | 29 class BookmarkEventRouter : public BookmarkModelObserver { |
| 31 public: | 30 public: |
| 32 explicit BookmarkEventRouter(BookmarkModel* model); | 31 explicit BookmarkEventRouter(BookmarkModel* model); |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 | 266 |
| 268 // ExtensionFunction: | 267 // ExtensionFunction: |
| 269 virtual bool RunImpl() OVERRIDE; | 268 virtual bool RunImpl() OVERRIDE; |
| 270 }; | 269 }; |
| 271 | 270 |
| 272 class BookmarksIOFunction : public BookmarksFunction, | 271 class BookmarksIOFunction : public BookmarksFunction, |
| 273 public ui::SelectFileDialog::Listener { | 272 public ui::SelectFileDialog::Listener { |
| 274 public: | 273 public: |
| 275 BookmarksIOFunction(); | 274 BookmarksIOFunction(); |
| 276 | 275 |
| 277 virtual void FileSelected(const FilePath& path, int index, void* params) = 0; | 276 virtual void FileSelected(const base::FilePath& path, int index, void* params)
= 0; |
| 278 | 277 |
| 279 // ui::SelectFileDialog::Listener: | 278 // ui::SelectFileDialog::Listener: |
| 280 virtual void MultiFilesSelected(const std::vector<FilePath>& files, | 279 virtual void MultiFilesSelected(const std::vector<base::FilePath>& files, |
| 281 void* params) OVERRIDE; | 280 void* params) OVERRIDE; |
| 282 virtual void FileSelectionCanceled(void* params) OVERRIDE; | 281 virtual void FileSelectionCanceled(void* params) OVERRIDE; |
| 283 | 282 |
| 284 void SelectFile(ui::SelectFileDialog::Type type); | 283 void SelectFile(ui::SelectFileDialog::Type type); |
| 285 | 284 |
| 286 protected: | 285 protected: |
| 287 virtual ~BookmarksIOFunction(); | 286 virtual ~BookmarksIOFunction(); |
| 288 | 287 |
| 289 private: | 288 private: |
| 290 void ShowSelectFileDialog( | 289 void ShowSelectFileDialog( |
| 291 ui::SelectFileDialog::Type type, | 290 ui::SelectFileDialog::Type type, |
| 292 const FilePath& default_path); | 291 const base::FilePath& default_path); |
| 293 | 292 |
| 294 protected: | 293 protected: |
| 295 scoped_refptr<ui::SelectFileDialog> select_file_dialog_; | 294 scoped_refptr<ui::SelectFileDialog> select_file_dialog_; |
| 296 }; | 295 }; |
| 297 | 296 |
| 298 class BookmarksImportFunction : public BookmarksIOFunction { | 297 class BookmarksImportFunction : public BookmarksIOFunction { |
| 299 public: | 298 public: |
| 300 DECLARE_EXTENSION_FUNCTION("bookmarks.import", BOOKMARKS_IMPORT) | 299 DECLARE_EXTENSION_FUNCTION("bookmarks.import", BOOKMARKS_IMPORT) |
| 301 | 300 |
| 302 // BookmarkManagerIOFunction: | 301 // BookmarkManagerIOFunction: |
| 303 virtual void FileSelected(const FilePath& path, | 302 virtual void FileSelected(const base::FilePath& path, |
| 304 int index, | 303 int index, |
| 305 void* params) OVERRIDE; | 304 void* params) OVERRIDE; |
| 306 | 305 |
| 307 private: | 306 private: |
| 308 virtual ~BookmarksImportFunction() {} | 307 virtual ~BookmarksImportFunction() {} |
| 309 | 308 |
| 310 // ExtensionFunction: | 309 // ExtensionFunction: |
| 311 virtual bool RunImpl() OVERRIDE; | 310 virtual bool RunImpl() OVERRIDE; |
| 312 }; | 311 }; |
| 313 | 312 |
| 314 class BookmarksExportFunction : public BookmarksIOFunction { | 313 class BookmarksExportFunction : public BookmarksIOFunction { |
| 315 public: | 314 public: |
| 316 DECLARE_EXTENSION_FUNCTION("bookmarks.export", BOOKMARKS_EXPORT) | 315 DECLARE_EXTENSION_FUNCTION("bookmarks.export", BOOKMARKS_EXPORT) |
| 317 | 316 |
| 318 // BookmarkManagerIOFunction: | 317 // BookmarkManagerIOFunction: |
| 319 virtual void FileSelected(const FilePath& path, | 318 virtual void FileSelected(const base::FilePath& path, |
| 320 int index, | 319 int index, |
| 321 void* params) OVERRIDE; | 320 void* params) OVERRIDE; |
| 322 | 321 |
| 323 private: | 322 private: |
| 324 virtual ~BookmarksExportFunction() {} | 323 virtual ~BookmarksExportFunction() {} |
| 325 | 324 |
| 326 // ExtensionFunction: | 325 // ExtensionFunction: |
| 327 virtual bool RunImpl() OVERRIDE; | 326 virtual bool RunImpl() OVERRIDE; |
| 328 }; | 327 }; |
| 329 | 328 |
| 330 } // namespace extensions | 329 } // namespace extensions |
| 331 | 330 |
| 332 #endif // CHROME_BROWSER_EXTENSIONS_API_BOOKMARKS_BOOKMARKS_API_H_ | 331 #endif // CHROME_BROWSER_EXTENSIONS_API_BOOKMARKS_BOOKMARKS_API_H_ |
| OLD | NEW |