| 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 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 protected: | 434 protected: |
| 435 virtual ~GetGDataFilePropertiesFunction(); | 435 virtual ~GetGDataFilePropertiesFunction(); |
| 436 | 436 |
| 437 void GetNextFileProperties(); | 437 void GetNextFileProperties(); |
| 438 void CompleteGetFileProperties(); | 438 void CompleteGetFileProperties(); |
| 439 | 439 |
| 440 // Virtual function that can be overridden to do operations on each virtual | 440 // Virtual function that can be overridden to do operations on each virtual |
| 441 // file path and update its the properties. | 441 // file path and update its the properties. |
| 442 virtual void DoOperation(const FilePath& file_path, | 442 virtual void DoOperation(const FilePath& file_path, |
| 443 base::DictionaryValue* properties, | 443 base::DictionaryValue* properties, |
| 444 scoped_ptr<gdata::GDataEntryProto> entry_proto); | 444 scoped_ptr<gdata::DriveEntryProto> entry_proto); |
| 445 | 445 |
| 446 void OnOperationComplete(const FilePath& file_path, | 446 void OnOperationComplete(const FilePath& file_path, |
| 447 base::DictionaryValue* properties, | 447 base::DictionaryValue* properties, |
| 448 gdata::GDataFileError error, | 448 gdata::GDataFileError error, |
| 449 scoped_ptr<gdata::GDataEntryProto> entry_proto); | 449 scoped_ptr<gdata::DriveEntryProto> entry_proto); |
| 450 | 450 |
| 451 // AsyncExtensionFunction overrides. | 451 // AsyncExtensionFunction overrides. |
| 452 virtual bool RunImpl() OVERRIDE; | 452 virtual bool RunImpl() OVERRIDE; |
| 453 | 453 |
| 454 // Builds list of file properies. Calls DoOperation for each file. | 454 // Builds list of file properies. Calls DoOperation for each file. |
| 455 void PrepareResults(); | 455 void PrepareResults(); |
| 456 | 456 |
| 457 private: | 457 private: |
| 458 void OnGetFileInfo(const FilePath& file_path, | 458 void OnGetFileInfo(const FilePath& file_path, |
| 459 base::DictionaryValue* property_dict, | 459 base::DictionaryValue* property_dict, |
| 460 gdata::GDataFileError error, | 460 gdata::GDataFileError error, |
| 461 scoped_ptr<gdata::GDataEntryProto> entry_proto); | 461 scoped_ptr<gdata::DriveEntryProto> entry_proto); |
| 462 | 462 |
| 463 void CacheStateReceived(base::DictionaryValue* property_dict, | 463 void CacheStateReceived(base::DictionaryValue* property_dict, |
| 464 bool success, | 464 bool success, |
| 465 const gdata::GDataCacheEntry& cache_entry); | 465 const gdata::DriveCacheEntry& cache_entry); |
| 466 | 466 |
| 467 size_t current_index_; | 467 size_t current_index_; |
| 468 base::ListValue* path_list_; | 468 base::ListValue* path_list_; |
| 469 scoped_ptr<base::ListValue> file_properties_; | 469 scoped_ptr<base::ListValue> file_properties_; |
| 470 }; | 470 }; |
| 471 | 471 |
| 472 // Pin/unpin multiple files in the cache, returning a list of file | 472 // Pin/unpin multiple files in the cache, returning a list of file |
| 473 // properties with the updated cache state. The returned array is the | 473 // properties with the updated cache state. The returned array is the |
| 474 // same length as the input list of file URLs. If a particular file | 474 // same length as the input list of file URLs. If a particular file |
| 475 // has an error, then return a dictionary with the key "error" set to | 475 // has an error, then return a dictionary with the key "error" set to |
| 476 // the error number (gdata::GDataFileError) for that entry in the | 476 // the error number (gdata::GDataFileError) for that entry in the |
| 477 // returned list. | 477 // returned list. |
| 478 class PinGDataFileFunction : public GetGDataFilePropertiesFunction { | 478 class PinGDataFileFunction : public GetGDataFilePropertiesFunction { |
| 479 public: | 479 public: |
| 480 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.pinGDataFile"); | 480 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.pinGDataFile"); |
| 481 | 481 |
| 482 PinGDataFileFunction(); | 482 PinGDataFileFunction(); |
| 483 | 483 |
| 484 protected: | 484 protected: |
| 485 virtual ~PinGDataFileFunction(); | 485 virtual ~PinGDataFileFunction(); |
| 486 | 486 |
| 487 // AsyncExtensionFunction overrides. | 487 // AsyncExtensionFunction overrides. |
| 488 virtual bool RunImpl() OVERRIDE; | 488 virtual bool RunImpl() OVERRIDE; |
| 489 | 489 |
| 490 private: | 490 private: |
| 491 // Actually do the pinning/unpinning of each file. | 491 // Actually do the pinning/unpinning of each file. |
| 492 virtual void DoOperation( | 492 virtual void DoOperation( |
| 493 const FilePath& file_path, | 493 const FilePath& file_path, |
| 494 base::DictionaryValue* properties, | 494 base::DictionaryValue* properties, |
| 495 scoped_ptr<gdata::GDataEntryProto> entry_proto) OVERRIDE; | 495 scoped_ptr<gdata::DriveEntryProto> entry_proto) OVERRIDE; |
| 496 | 496 |
| 497 // Callback for SetPinState. Updates properties with error. | 497 // Callback for SetPinState. Updates properties with error. |
| 498 void OnPinStateSet(const FilePath& path, | 498 void OnPinStateSet(const FilePath& path, |
| 499 base::DictionaryValue* properties, | 499 base::DictionaryValue* properties, |
| 500 scoped_ptr<gdata::GDataEntryProto> entry_proto, | 500 scoped_ptr<gdata::DriveEntryProto> entry_proto, |
| 501 gdata::GDataFileError error, | 501 gdata::GDataFileError error, |
| 502 const std::string& resource_id, | 502 const std::string& resource_id, |
| 503 const std::string& md5); | 503 const std::string& md5); |
| 504 | 504 |
| 505 // True for pin, false for unpin. | 505 // True for pin, false for unpin. |
| 506 bool set_pin_; | 506 bool set_pin_; |
| 507 }; | 507 }; |
| 508 | 508 |
| 509 // Get file locations for the given list of file URLs. Returns a list of | 509 // Get file locations for the given list of file URLs. Returns a list of |
| 510 // location idenfitiers, like ['drive', 'local'], where 'drive' means the | 510 // location idenfitiers, like ['drive', 'local'], where 'drive' means the |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 702 DECLARE_EXTENSION_FUNCTION_NAME( | 702 DECLARE_EXTENSION_FUNCTION_NAME( |
| 703 "fileBrowserPrivate.requestDirectoryRefresh"); | 703 "fileBrowserPrivate.requestDirectoryRefresh"); |
| 704 | 704 |
| 705 protected: | 705 protected: |
| 706 virtual ~RequestDirectoryRefreshFunction() {} | 706 virtual ~RequestDirectoryRefreshFunction() {} |
| 707 | 707 |
| 708 virtual bool RunImpl() OVERRIDE; | 708 virtual bool RunImpl() OVERRIDE; |
| 709 }; | 709 }; |
| 710 | 710 |
| 711 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_BROWSER_PRIVATE_API_H_ | 711 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_BROWSER_PRIVATE_API_H_ |
| OLD | NEW |