| 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 <string> | 9 #include <string> |
| 10 #include <queue> | 10 #include <queue> |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 virtual bool RunImpl() OVERRIDE; | 309 virtual bool RunImpl() OVERRIDE; |
| 310 | 310 |
| 311 private: | 311 private: |
| 312 // A callback method to handle the result of | 312 // A callback method to handle the result of |
| 313 // GetLocalPathsOnFileThreadAndRunCallbackOnUIThread. | 313 // GetLocalPathsOnFileThreadAndRunCallbackOnUIThread. |
| 314 void GetLocalPathsResponseOnUIThread(const std::string& mount_type_str, | 314 void GetLocalPathsResponseOnUIThread(const std::string& mount_type_str, |
| 315 const SelectedFileInfoList& files); | 315 const SelectedFileInfoList& files); |
| 316 // A callback method to handle the result of SetMountedState. | 316 // A callback method to handle the result of SetMountedState. |
| 317 void OnMountedStateSet(const std::string& mount_type, | 317 void OnMountedStateSet(const std::string& mount_type, |
| 318 const FilePath::StringType& file_name, | 318 const FilePath::StringType& file_name, |
| 319 gdata::GDataFileError error, | 319 gdata::DriveFileError error, |
| 320 const FilePath& file_path); | 320 const FilePath& file_path); |
| 321 }; | 321 }; |
| 322 | 322 |
| 323 // Unmounts selected device. Expects mount point path as an argument. | 323 // Unmounts selected device. Expects mount point path as an argument. |
| 324 class RemoveMountFunction : public FileBrowserFunction { | 324 class RemoveMountFunction : public FileBrowserFunction { |
| 325 public: | 325 public: |
| 326 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.removeMount"); | 326 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.removeMount"); |
| 327 | 327 |
| 328 RemoveMountFunction(); | 328 RemoveMountFunction(); |
| 329 | 329 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 virtual ~GetSizeStatsFunction(); | 381 virtual ~GetSizeStatsFunction(); |
| 382 | 382 |
| 383 // AsyncExtensionFunction overrides. | 383 // AsyncExtensionFunction overrides. |
| 384 virtual bool RunImpl() OVERRIDE; | 384 virtual bool RunImpl() OVERRIDE; |
| 385 | 385 |
| 386 private: | 386 private: |
| 387 // A callback method to handle the result of | 387 // A callback method to handle the result of |
| 388 // GetLocalPathsOnFileThreadAndRunCallbackOnUIThread. | 388 // GetLocalPathsOnFileThreadAndRunCallbackOnUIThread. |
| 389 void GetLocalPathsResponseOnUIThread(const SelectedFileInfoList& files); | 389 void GetLocalPathsResponseOnUIThread(const SelectedFileInfoList& files); |
| 390 | 390 |
| 391 void GetGDataAvailableSpaceCallback(gdata::GDataFileError error, | 391 void GetGDataAvailableSpaceCallback(gdata::DriveFileError error, |
| 392 int64 bytes_total, | 392 int64 bytes_total, |
| 393 int64 bytes_used); | 393 int64 bytes_used); |
| 394 | 394 |
| 395 void GetSizeStatsCallbackOnUIThread(size_t total_size_kb, | 395 void GetSizeStatsCallbackOnUIThread(size_t total_size_kb, |
| 396 size_t remaining_size_kb); | 396 size_t remaining_size_kb); |
| 397 void CallGetSizeStatsOnFileThread(const std::string& mount_path); | 397 void CallGetSizeStatsOnFileThread(const std::string& mount_path); |
| 398 }; | 398 }; |
| 399 | 399 |
| 400 // Retrieves devices meta-data. Expects volume's device path as an argument. | 400 // Retrieves devices meta-data. Expects volume's device path as an argument. |
| 401 class GetVolumeMetadataFunction : public FileBrowserFunction { | 401 class GetVolumeMetadataFunction : public FileBrowserFunction { |
| 402 public: | 402 public: |
| 403 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.getVolumeMetadata"); | 403 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.getVolumeMetadata"); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 protected: | 450 protected: |
| 451 virtual ~FileDialogStringsFunction() {} | 451 virtual ~FileDialogStringsFunction() {} |
| 452 | 452 |
| 453 // SyncExtensionFunction overrides. | 453 // SyncExtensionFunction overrides. |
| 454 virtual bool RunImpl() OVERRIDE; | 454 virtual bool RunImpl() OVERRIDE; |
| 455 }; | 455 }; |
| 456 | 456 |
| 457 // Retrieve property information for multiple files, returning a list of the | 457 // Retrieve property information for multiple files, returning a list of the |
| 458 // same length as the input list of file URLs. If a particular file has an | 458 // same length as the input list of file URLs. If a particular file has an |
| 459 // error, then return a dictionary with the key "error" set to the error number | 459 // error, then return a dictionary with the key "error" set to the error number |
| 460 // (gdata::GDataFileError) for that entry in the returned list. | 460 // (gdata::DriveFileError) for that entry in the returned list. |
| 461 class GetGDataFilePropertiesFunction : public FileBrowserFunction { | 461 class GetGDataFilePropertiesFunction : public FileBrowserFunction { |
| 462 public: | 462 public: |
| 463 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.getGDataFileProperties"); | 463 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.getGDataFileProperties"); |
| 464 | 464 |
| 465 GetGDataFilePropertiesFunction(); | 465 GetGDataFilePropertiesFunction(); |
| 466 | 466 |
| 467 protected: | 467 protected: |
| 468 virtual ~GetGDataFilePropertiesFunction(); | 468 virtual ~GetGDataFilePropertiesFunction(); |
| 469 | 469 |
| 470 void GetNextFileProperties(); | 470 void GetNextFileProperties(); |
| 471 void CompleteGetFileProperties(); | 471 void CompleteGetFileProperties(); |
| 472 | 472 |
| 473 // Virtual function that can be overridden to do operations on each virtual | 473 // Virtual function that can be overridden to do operations on each virtual |
| 474 // file path and update its the properties. | 474 // file path and update its the properties. |
| 475 virtual void DoOperation(const FilePath& file_path, | 475 virtual void DoOperation(const FilePath& file_path, |
| 476 base::DictionaryValue* properties, | 476 base::DictionaryValue* properties, |
| 477 scoped_ptr<gdata::DriveEntryProto> entry_proto); | 477 scoped_ptr<gdata::DriveEntryProto> entry_proto); |
| 478 | 478 |
| 479 void OnOperationComplete(const FilePath& file_path, | 479 void OnOperationComplete(const FilePath& file_path, |
| 480 base::DictionaryValue* properties, | 480 base::DictionaryValue* properties, |
| 481 gdata::GDataFileError error, | 481 gdata::DriveFileError error, |
| 482 scoped_ptr<gdata::DriveEntryProto> entry_proto); | 482 scoped_ptr<gdata::DriveEntryProto> entry_proto); |
| 483 | 483 |
| 484 // AsyncExtensionFunction overrides. | 484 // AsyncExtensionFunction overrides. |
| 485 virtual bool RunImpl() OVERRIDE; | 485 virtual bool RunImpl() OVERRIDE; |
| 486 | 486 |
| 487 // Builds list of file properies. Calls DoOperation for each file. | 487 // Builds list of file properies. Calls DoOperation for each file. |
| 488 void PrepareResults(); | 488 void PrepareResults(); |
| 489 | 489 |
| 490 private: | 490 private: |
| 491 void OnGetFileInfo(const FilePath& file_path, | 491 void OnGetFileInfo(const FilePath& file_path, |
| 492 base::DictionaryValue* property_dict, | 492 base::DictionaryValue* property_dict, |
| 493 gdata::GDataFileError error, | 493 gdata::DriveFileError error, |
| 494 scoped_ptr<gdata::DriveEntryProto> entry_proto); | 494 scoped_ptr<gdata::DriveEntryProto> entry_proto); |
| 495 | 495 |
| 496 void CacheStateReceived(base::DictionaryValue* property_dict, | 496 void CacheStateReceived(base::DictionaryValue* property_dict, |
| 497 bool success, | 497 bool success, |
| 498 const gdata::DriveCacheEntry& cache_entry); | 498 const gdata::DriveCacheEntry& cache_entry); |
| 499 | 499 |
| 500 size_t current_index_; | 500 size_t current_index_; |
| 501 base::ListValue* path_list_; | 501 base::ListValue* path_list_; |
| 502 scoped_ptr<base::ListValue> file_properties_; | 502 scoped_ptr<base::ListValue> file_properties_; |
| 503 }; | 503 }; |
| 504 | 504 |
| 505 // Pin/unpin multiple files in the cache, returning a list of file | 505 // Pin/unpin multiple files in the cache, returning a list of file |
| 506 // properties with the updated cache state. The returned array is the | 506 // properties with the updated cache state. The returned array is the |
| 507 // same length as the input list of file URLs. If a particular file | 507 // same length as the input list of file URLs. If a particular file |
| 508 // has an error, then return a dictionary with the key "error" set to | 508 // has an error, then return a dictionary with the key "error" set to |
| 509 // the error number (gdata::GDataFileError) for that entry in the | 509 // the error number (gdata::DriveFileError) for that entry in the |
| 510 // returned list. | 510 // returned list. |
| 511 class PinGDataFileFunction : public GetGDataFilePropertiesFunction { | 511 class PinGDataFileFunction : public GetGDataFilePropertiesFunction { |
| 512 public: | 512 public: |
| 513 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.pinGDataFile"); | 513 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.pinGDataFile"); |
| 514 | 514 |
| 515 PinGDataFileFunction(); | 515 PinGDataFileFunction(); |
| 516 | 516 |
| 517 protected: | 517 protected: |
| 518 virtual ~PinGDataFileFunction(); | 518 virtual ~PinGDataFileFunction(); |
| 519 | 519 |
| 520 // AsyncExtensionFunction overrides. | 520 // AsyncExtensionFunction overrides. |
| 521 virtual bool RunImpl() OVERRIDE; | 521 virtual bool RunImpl() OVERRIDE; |
| 522 | 522 |
| 523 private: | 523 private: |
| 524 // Actually do the pinning/unpinning of each file. | 524 // Actually do the pinning/unpinning of each file. |
| 525 virtual void DoOperation( | 525 virtual void DoOperation( |
| 526 const FilePath& file_path, | 526 const FilePath& file_path, |
| 527 base::DictionaryValue* properties, | 527 base::DictionaryValue* properties, |
| 528 scoped_ptr<gdata::DriveEntryProto> entry_proto) OVERRIDE; | 528 scoped_ptr<gdata::DriveEntryProto> entry_proto) OVERRIDE; |
| 529 | 529 |
| 530 // Callback for SetPinState. Updates properties with error. | 530 // Callback for SetPinState. Updates properties with error. |
| 531 void OnPinStateSet(const FilePath& path, | 531 void OnPinStateSet(const FilePath& path, |
| 532 base::DictionaryValue* properties, | 532 base::DictionaryValue* properties, |
| 533 scoped_ptr<gdata::DriveEntryProto> entry_proto, | 533 scoped_ptr<gdata::DriveEntryProto> entry_proto, |
| 534 gdata::GDataFileError error, | 534 gdata::DriveFileError error, |
| 535 const std::string& resource_id, | 535 const std::string& resource_id, |
| 536 const std::string& md5); | 536 const std::string& md5); |
| 537 | 537 |
| 538 // True for pin, false for unpin. | 538 // True for pin, false for unpin. |
| 539 bool set_pin_; | 539 bool set_pin_; |
| 540 }; | 540 }; |
| 541 | 541 |
| 542 // Get file locations for the given list of file URLs. Returns a list of | 542 // Get file locations for the given list of file URLs. Returns a list of |
| 543 // location idenfitiers, like ['drive', 'local'], where 'drive' means the | 543 // location idenfitiers, like ['drive', 'local'], where 'drive' means the |
| 544 // file is on gdata, and 'local' means the file is on the local drive. | 544 // file is on gdata, and 'local' means the file is on the local drive. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 // A callback method to handle the result of | 584 // A callback method to handle the result of |
| 585 // GetLocalPathsOnFileThreadAndRunCallbackOnUIThread. | 585 // GetLocalPathsOnFileThreadAndRunCallbackOnUIThread. |
| 586 void GetLocalPathsResponseOnUIThread(const SelectedFileInfoList& files); | 586 void GetLocalPathsResponseOnUIThread(const SelectedFileInfoList& files); |
| 587 | 587 |
| 588 // Gets the file on the top of the |remaining_gdata_paths_| or sends the | 588 // Gets the file on the top of the |remaining_gdata_paths_| or sends the |
| 589 // response if the queue is empty. | 589 // response if the queue is empty. |
| 590 void GetFileOrSendResponse(); | 590 void GetFileOrSendResponse(); |
| 591 | 591 |
| 592 // Called by GDataFileSystem::GetFile(). Pops the file from | 592 // Called by GDataFileSystem::GetFile(). Pops the file from |
| 593 // |remaining_gdata_paths_|, and calls GetFileOrSendResponse(). | 593 // |remaining_gdata_paths_|, and calls GetFileOrSendResponse(). |
| 594 void OnFileReady(gdata::GDataFileError error, | 594 void OnFileReady(gdata::DriveFileError error, |
| 595 const FilePath& local_path, | 595 const FilePath& local_path, |
| 596 const std::string& unused_mime_type, | 596 const std::string& unused_mime_type, |
| 597 gdata::DriveFileType file_type); | 597 gdata::DriveFileType file_type); |
| 598 | 598 |
| 599 std::queue<FilePath> remaining_gdata_paths_; | 599 std::queue<FilePath> remaining_gdata_paths_; |
| 600 ListValue* local_paths_; | 600 ListValue* local_paths_; |
| 601 }; | 601 }; |
| 602 | 602 |
| 603 // Implements the chrome.fileBrowserPrivate.executeTask method. | 603 // Implements the chrome.fileBrowserPrivate.executeTask method. |
| 604 class GetFileTransfersFunction : public AsyncExtensionFunction { | 604 class GetFileTransfersFunction : public AsyncExtensionFunction { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 645 | 645 |
| 646 // AsyncExtensionFunction overrides. | 646 // AsyncExtensionFunction overrides. |
| 647 virtual bool RunImpl() OVERRIDE; | 647 virtual bool RunImpl() OVERRIDE; |
| 648 | 648 |
| 649 private: | 649 private: |
| 650 // Helper callback for handling response from | 650 // Helper callback for handling response from |
| 651 // GetLocalPathsOnFileThreadAndRunCallbackOnUIThread() | 651 // GetLocalPathsOnFileThreadAndRunCallbackOnUIThread() |
| 652 void GetLocalPathsResponseOnUIThread(const SelectedFileInfoList& files); | 652 void GetLocalPathsResponseOnUIThread(const SelectedFileInfoList& files); |
| 653 | 653 |
| 654 // Helper callback for handling response from GDataFileSystem::TransferFile(). | 654 // Helper callback for handling response from GDataFileSystem::TransferFile(). |
| 655 void OnTransferCompleted(gdata::GDataFileError error); | 655 void OnTransferCompleted(gdata::DriveFileError error); |
| 656 }; | 656 }; |
| 657 | 657 |
| 658 // Read setting value. | 658 // Read setting value. |
| 659 class GetGDataPreferencesFunction : public SyncExtensionFunction { | 659 class GetGDataPreferencesFunction : public SyncExtensionFunction { |
| 660 public: | 660 public: |
| 661 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.getGDataPreferences"); | 661 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.getGDataPreferences"); |
| 662 | 662 |
| 663 protected: | 663 protected: |
| 664 virtual ~GetGDataPreferencesFunction() {} | 664 virtual ~GetGDataPreferencesFunction() {} |
| 665 | 665 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 687 virtual ~SearchDriveFunction(); | 687 virtual ~SearchDriveFunction(); |
| 688 | 688 |
| 689 virtual bool RunImpl() OVERRIDE; | 689 virtual bool RunImpl() OVERRIDE; |
| 690 | 690 |
| 691 private: | 691 private: |
| 692 // Callback fo OpenFileSystem called from RunImpl. | 692 // Callback fo OpenFileSystem called from RunImpl. |
| 693 void OnFileSystemOpened(base::PlatformFileError result, | 693 void OnFileSystemOpened(base::PlatformFileError result, |
| 694 const std::string& file_system_name, | 694 const std::string& file_system_name, |
| 695 const GURL& file_system_url); | 695 const GURL& file_system_url); |
| 696 // Callback for gdata::SearchAsync called after file system is opened. | 696 // Callback for gdata::SearchAsync called after file system is opened. |
| 697 void OnSearch(gdata::GDataFileError error, | 697 void OnSearch(gdata::DriveFileError error, |
| 698 const GURL& next_feed, | 698 const GURL& next_feed, |
| 699 scoped_ptr<std::vector<gdata::SearchResultInfo> > result_paths); | 699 scoped_ptr<std::vector<gdata::SearchResultInfo> > result_paths); |
| 700 | 700 |
| 701 // Query for which the search is being performed. | 701 // Query for which the search is being performed. |
| 702 std::string query_; | 702 std::string query_; |
| 703 std::string next_feed_; | 703 std::string next_feed_; |
| 704 // Information about remote file system we will need to create file entries | 704 // Information about remote file system we will need to create file entries |
| 705 // to represent search results. | 705 // to represent search results. |
| 706 std::string file_system_name_; | 706 std::string file_system_name_; |
| 707 GURL file_system_url_; | 707 GURL file_system_url_; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 735 DECLARE_EXTENSION_FUNCTION_NAME( | 735 DECLARE_EXTENSION_FUNCTION_NAME( |
| 736 "fileBrowserPrivate.requestDirectoryRefresh"); | 736 "fileBrowserPrivate.requestDirectoryRefresh"); |
| 737 | 737 |
| 738 protected: | 738 protected: |
| 739 virtual ~RequestDirectoryRefreshFunction() {} | 739 virtual ~RequestDirectoryRefreshFunction() {} |
| 740 | 740 |
| 741 virtual bool RunImpl() OVERRIDE; | 741 virtual bool RunImpl() OVERRIDE; |
| 742 }; | 742 }; |
| 743 | 743 |
| 744 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_BROWSER_PRIVATE_API_H_ | 744 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_BROWSER_PRIVATE_API_H_ |
| OLD | NEW |