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_CHROMEOS_EXTENSIONS_FILE_BROWSER_PRIVATE_API_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_BROWSER_PRIVATE_API_H_ |
6 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_BROWSER_PRIVATE_API_H_ | 6 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_BROWSER_PRIVATE_API_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <queue> | 9 #include <queue> |
10 #include <string> | 10 #include <string> |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 scoped_refptr<FileBrowserEventRouter> event_router, | 69 scoped_refptr<FileBrowserEventRouter> event_router, |
70 const FilePath& local_path, const FilePath& virtual_path, | 70 const FilePath& local_path, const FilePath& virtual_path, |
71 const std::string& extension_id) = 0; | 71 const std::string& extension_id) = 0; |
72 | 72 |
73 // AsyncExtensionFunction overrides. | 73 // AsyncExtensionFunction overrides. |
74 virtual bool RunImpl() OVERRIDE; | 74 virtual bool RunImpl() OVERRIDE; |
75 | 75 |
76 private: | 76 private: |
77 void RespondOnUIThread(bool success); | 77 void RespondOnUIThread(bool success); |
78 void RunFileWatchOperationOnFileThread( | 78 void RunFileWatchOperationOnFileThread( |
79 scoped_refptr<fileapi::FileSystemContext> file_system_context, | |
80 scoped_refptr<FileBrowserEventRouter> event_router, | 79 scoped_refptr<FileBrowserEventRouter> event_router, |
81 const GURL& file_url, | 80 const GURL& file_url, |
82 const std::string& extension_id); | 81 const std::string& extension_id); |
83 }; | 82 }; |
84 | 83 |
85 // Implements the chrome.fileBrowserPrivate.addFileWatch method. | 84 // Implements the chrome.fileBrowserPrivate.addFileWatch method. |
86 class AddFileWatchBrowserFunction : public FileWatchBrowserFunctionBase { | 85 class AddFileWatchBrowserFunction : public FileWatchBrowserFunctionBase { |
87 public: | 86 public: |
88 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.addFileWatch"); | 87 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.addFileWatch"); |
89 | 88 |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 public: | 266 public: |
268 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.viewFiles"); | 267 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.viewFiles"); |
269 | 268 |
270 ViewFilesFunction(); | 269 ViewFilesFunction(); |
271 | 270 |
272 protected: | 271 protected: |
273 virtual ~ViewFilesFunction(); | 272 virtual ~ViewFilesFunction(); |
274 | 273 |
275 // AsyncExtensionFunction overrides. | 274 // AsyncExtensionFunction overrides. |
276 virtual bool RunImpl() OVERRIDE; | 275 virtual bool RunImpl() OVERRIDE; |
277 | |
278 private: | |
279 // A callback method to handle the result of | |
280 // GetLocalPathsOnFileThreadAndRunCallbackOnUIThread. | |
281 void GetLocalPathsResponseOnUIThread(const std::string& internal_task_id, | |
282 const SelectedFileInfoList& files); | |
283 }; | 276 }; |
284 | 277 |
285 // Select multiple files. Closes the dialog window. | 278 // Select multiple files. Closes the dialog window. |
286 class SelectFilesFunction : public FileBrowserFunction { | 279 class SelectFilesFunction : public FileBrowserFunction { |
287 public: | 280 public: |
288 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.selectFiles"); | 281 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.selectFiles"); |
289 | 282 |
290 SelectFilesFunction(); | 283 SelectFilesFunction(); |
291 | 284 |
292 protected: | 285 protected: |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 public: | 370 public: |
378 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.formatDevice"); | 371 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.formatDevice"); |
379 | 372 |
380 FormatDeviceFunction(); | 373 FormatDeviceFunction(); |
381 | 374 |
382 protected: | 375 protected: |
383 virtual ~FormatDeviceFunction(); | 376 virtual ~FormatDeviceFunction(); |
384 | 377 |
385 // AsyncExtensionFunction overrides. | 378 // AsyncExtensionFunction overrides. |
386 virtual bool RunImpl() OVERRIDE; | 379 virtual bool RunImpl() OVERRIDE; |
387 | |
388 private: | |
389 // A callback method to handle the result of | |
390 // GetLocalPathsOnFileThreadAndRunCallbackOnUIThread. | |
391 void GetLocalPathsResponseOnUIThread(const SelectedFileInfoList& files); | |
392 }; | 380 }; |
393 | 381 |
394 // Sets last modified date in seconds of local file | 382 // Sets last modified date in seconds of local file |
395 class SetLastModifiedFunction : public FileBrowserFunction { | 383 class SetLastModifiedFunction : public FileBrowserFunction { |
396 public: | 384 public: |
397 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.setLastModified"); | 385 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.setLastModified"); |
398 | 386 |
399 SetLastModifiedFunction(); | 387 SetLastModifiedFunction(); |
400 | 388 |
401 protected: | 389 protected: |
(...skipping 11 matching lines...) Expand all Loading... |
413 | 401 |
414 GetSizeStatsFunction(); | 402 GetSizeStatsFunction(); |
415 | 403 |
416 protected: | 404 protected: |
417 virtual ~GetSizeStatsFunction(); | 405 virtual ~GetSizeStatsFunction(); |
418 | 406 |
419 // AsyncExtensionFunction overrides. | 407 // AsyncExtensionFunction overrides. |
420 virtual bool RunImpl() OVERRIDE; | 408 virtual bool RunImpl() OVERRIDE; |
421 | 409 |
422 private: | 410 private: |
423 // A callback method to handle the result of | |
424 // GetLocalPathsOnFileThreadAndRunCallbackOnUIThread. | |
425 void GetLocalPathsResponseOnUIThread(const SelectedFileInfoList& files); | |
426 | |
427 void GetDriveAvailableSpaceCallback(drive::DriveFileError error, | 411 void GetDriveAvailableSpaceCallback(drive::DriveFileError error, |
428 int64 bytes_total, | 412 int64 bytes_total, |
429 int64 bytes_used); | 413 int64 bytes_used); |
430 | 414 |
431 void GetSizeStatsCallbackOnUIThread(size_t total_size_kb, | 415 void GetSizeStatsCallbackOnUIThread(size_t total_size_kb, |
432 size_t remaining_size_kb); | 416 size_t remaining_size_kb); |
433 void CallGetSizeStatsOnFileThread(const std::string& mount_path); | 417 void CallGetSizeStatsOnFileThread(const std::string& mount_path); |
434 }; | 418 }; |
435 | 419 |
436 // Retrieves devices meta-data. Expects volume's device path as an argument. | 420 // Retrieves devices meta-data. Expects volume's device path as an argument. |
437 class GetVolumeMetadataFunction : public FileBrowserFunction { | 421 class GetVolumeMetadataFunction : public FileBrowserFunction { |
438 public: | 422 public: |
439 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.getVolumeMetadata"); | 423 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.getVolumeMetadata"); |
440 | 424 |
441 GetVolumeMetadataFunction(); | 425 GetVolumeMetadataFunction(); |
442 | 426 |
443 protected: | 427 protected: |
444 virtual ~GetVolumeMetadataFunction(); | 428 virtual ~GetVolumeMetadataFunction(); |
445 | 429 |
446 // AsyncExtensionFunction overrides. | 430 // AsyncExtensionFunction overrides. |
447 virtual bool RunImpl() OVERRIDE; | 431 virtual bool RunImpl() OVERRIDE; |
448 | |
449 private: | |
450 // A callback method to handle the result of | |
451 // GetLocalPathsOnFileThreadAndRunCallbackOnUIThread. | |
452 void GetLocalPathsResponseOnUIThread(const SelectedFileInfoList& files); | |
453 }; | 432 }; |
454 | 433 |
455 // Toggles fullscreen mode for the browser. | 434 // Toggles fullscreen mode for the browser. |
456 class ToggleFullscreenFunction : public SyncExtensionFunction { | 435 class ToggleFullscreenFunction : public SyncExtensionFunction { |
457 public: | 436 public: |
458 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.toggleFullscreen"); | 437 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.toggleFullscreen"); |
459 | 438 |
460 protected: | 439 protected: |
461 virtual ~ToggleFullscreenFunction() {} | 440 virtual ~ToggleFullscreenFunction() {} |
462 | 441 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 void OnPinStateSet(const FilePath& path, | 546 void OnPinStateSet(const FilePath& path, |
568 base::DictionaryValue* properties, | 547 base::DictionaryValue* properties, |
569 scoped_ptr<drive::DriveEntryProto> entry_proto, | 548 scoped_ptr<drive::DriveEntryProto> entry_proto, |
570 drive::DriveFileError error); | 549 drive::DriveFileError error); |
571 | 550 |
572 // True for pin, false for unpin. | 551 // True for pin, false for unpin. |
573 bool set_pin_; | 552 bool set_pin_; |
574 }; | 553 }; |
575 | 554 |
576 // Get file locations for the given list of file URLs. Returns a list of | 555 // Get file locations for the given list of file URLs. Returns a list of |
577 // location idenfitiers, like ['drive', 'local'], where 'drive' means the | 556 // location identifiers, like ['drive', 'local'], where 'drive' means the |
578 // file is on gdata, and 'local' means the file is on the local drive. | 557 // file is on gdata, and 'local' means the file is on the local drive. |
579 class GetFileLocationsFunction : public FileBrowserFunction { | 558 class GetFileLocationsFunction : public FileBrowserFunction { |
580 public: | 559 public: |
581 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.getFileLocations"); | 560 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.getFileLocations"); |
582 | 561 |
583 GetFileLocationsFunction(); | 562 GetFileLocationsFunction(); |
584 | 563 |
585 protected: | 564 protected: |
586 virtual ~GetFileLocationsFunction(); | 565 virtual ~GetFileLocationsFunction(); |
587 | 566 |
588 // AsyncExtensionFunction overrides. | 567 // AsyncExtensionFunction overrides. |
589 virtual bool RunImpl() OVERRIDE; | 568 virtual bool RunImpl() OVERRIDE; |
590 | |
591 private: | |
592 // A callback method to handle the result of | |
593 // GetLocalPathsOnFileThreadAndRunCallbackOnUIThread. | |
594 void GetLocalPathsResponseOnUIThread(const SelectedFileInfoList& files); | |
595 }; | 569 }; |
596 | 570 |
597 // Get gdata files for the given list of file URLs. Initiate downloading of | 571 // Get gdata files for the given list of file URLs. Initiate downloading of |
598 // gdata files if these are not cached. Return a list of local file names. | 572 // gdata files if these are not cached. Return a list of local file names. |
599 // This function puts empty strings instead of local paths for files could | 573 // This function puts empty strings instead of local paths for files could |
600 // not be obtained. For instance, this can happen if the user specifies a new | 574 // not be obtained. For instance, this can happen if the user specifies a new |
601 // file name to save a file on gdata. There may be other reasons to fail. The | 575 // file name to save a file on gdata. There may be other reasons to fail. The |
602 // file manager should check if the local paths returned from getDriveFiles() | 576 // file manager should check if the local paths returned from getDriveFiles() |
603 // contain empty paths. | 577 // contain empty paths. |
604 // TODO(satorux): Should we propagate error types to the JavasScript layer? | 578 // TODO(satorux): Should we propagate error types to the JavasScript layer? |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
656 public: | 630 public: |
657 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.cancelFileTransfers"); | 631 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.cancelFileTransfers"); |
658 | 632 |
659 CancelFileTransfersFunction(); | 633 CancelFileTransfersFunction(); |
660 | 634 |
661 protected: | 635 protected: |
662 virtual ~CancelFileTransfersFunction(); | 636 virtual ~CancelFileTransfersFunction(); |
663 | 637 |
664 // AsyncExtensionFunction overrides. | 638 // AsyncExtensionFunction overrides. |
665 virtual bool RunImpl() OVERRIDE; | 639 virtual bool RunImpl() OVERRIDE; |
666 | |
667 void GetLocalPathsResponseOnUIThread(const SelectedFileInfoList& files); | |
668 }; | 640 }; |
669 | 641 |
670 // Implements the chrome.fileBrowserPrivate.transferFile method. | 642 // Implements the chrome.fileBrowserPrivate.transferFile method. |
671 class TransferFileFunction : public FileBrowserFunction { | 643 class TransferFileFunction : public FileBrowserFunction { |
672 public: | 644 public: |
673 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.transferFile"); | 645 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.transferFile"); |
674 | 646 |
675 TransferFileFunction(); | 647 TransferFileFunction(); |
676 | 648 |
677 protected: | 649 protected: |
678 virtual ~TransferFileFunction(); | 650 virtual ~TransferFileFunction(); |
679 | 651 |
680 // AsyncExtensionFunction overrides. | 652 // AsyncExtensionFunction overrides. |
681 virtual bool RunImpl() OVERRIDE; | 653 virtual bool RunImpl() OVERRIDE; |
682 | 654 |
683 private: | 655 private: |
684 // Helper callback for handling response from | |
685 // GetLocalPathsOnFileThreadAndRunCallbackOnUIThread() | |
686 void GetLocalPathsResponseOnUIThread(const SelectedFileInfoList& files); | |
687 | |
688 // Helper callback for handling response from DriveFileSystem::TransferFile(). | 656 // Helper callback for handling response from DriveFileSystem::TransferFile(). |
689 void OnTransferCompleted(drive::DriveFileError error); | 657 void OnTransferCompleted(drive::DriveFileError error); |
690 }; | 658 }; |
691 | 659 |
692 // Read setting value. | 660 // Read setting value. |
693 class GetPreferencesFunction : public SyncExtensionFunction { | 661 class GetPreferencesFunction : public SyncExtensionFunction { |
694 public: | 662 public: |
695 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.getPreferences"); | 663 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.getPreferences"); |
696 | 664 |
697 protected: | 665 protected: |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
798 protected: | 766 protected: |
799 virtual ~ZipSelectionFunction(); | 767 virtual ~ZipSelectionFunction(); |
800 | 768 |
801 // AsyncExtensionFunction overrides. | 769 // AsyncExtensionFunction overrides. |
802 virtual bool RunImpl() OVERRIDE; | 770 virtual bool RunImpl() OVERRIDE; |
803 | 771 |
804 // extensions::ZipFileCreator::Delegate overrides. | 772 // extensions::ZipFileCreator::Delegate overrides. |
805 virtual void OnZipDone(bool success) OVERRIDE; | 773 virtual void OnZipDone(bool success) OVERRIDE; |
806 | 774 |
807 private: | 775 private: |
808 // A callback method to handle the result of | |
809 // GetLocalPathsOnFileThreadAndRunCallbackOnUIThread. | |
810 void GetLocalPathsResponseOnUIThread(const std::string dest_name, | |
811 const SelectedFileInfoList& files); | |
812 | |
813 scoped_refptr<extensions::ZipFileCreator> zip_file_creator_; | 776 scoped_refptr<extensions::ZipFileCreator> zip_file_creator_; |
814 }; | 777 }; |
815 | 778 |
816 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_BROWSER_PRIVATE_API_H_ | 779 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_BROWSER_PRIVATE_API_H_ |
OLD | NEW |