Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(308)

Side by Side Diff: chrome/browser/chromeos/extensions/file_browser_private_api.h

Issue 11106007: drive: Rename 'gdata' namespace to 'drive' in chrome/browser/chromeos/drive (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/platform_file.h" 15 #include "base/platform_file.h"
16 #include "chrome/browser/chromeos/drive/drive_cache.h" 16 #include "chrome/browser/chromeos/drive/drive_cache.h"
17 #include "chrome/browser/chromeos/drive/drive_file_error.h" 17 #include "chrome/browser/chromeos/drive/drive_file_error.h"
18 #include "chrome/browser/chromeos/extensions/file_browser_event_router.h" 18 #include "chrome/browser/chromeos/extensions/file_browser_event_router.h"
19 #include "chrome/browser/extensions/extension_function.h" 19 #include "chrome/browser/extensions/extension_function.h"
20 #include "chrome/browser/prefs/pref_service.h" 20 #include "chrome/browser/prefs/pref_service.h"
21 #include "googleurl/src/url_util.h" 21 #include "googleurl/src/url_util.h"
22 22
23 class GURL; 23 class GURL;
24 24
25 namespace fileapi { 25 namespace fileapi {
26 class FileSystemContext; 26 class FileSystemContext;
27 } 27 }
28 28
29 namespace gdata { 29 namespace drive {
30 struct SearchResultInfo; 30 struct SearchResultInfo;
31 struct DriveWebAppInfo; 31 struct DriveWebAppInfo;
32 class DriveWebAppsRegistry; 32 class DriveWebAppsRegistry;
33 } 33 }
34 34
35 namespace ui { 35 namespace ui {
36 struct SelectedFileInfo; 36 struct SelectedFileInfo;
37 } 37 }
38 38
39 // Implements the chrome.fileBrowserPrivate.requestLocalFileSystem method. 39 // Implements the chrome.fileBrowserPrivate.requestLocalFileSystem method.
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 private: 126 private:
127 struct FileInfo { 127 struct FileInfo {
128 GURL file_url; 128 GURL file_url;
129 FilePath file_path; 129 FilePath file_path;
130 std::string mime_type; 130 std::string mime_type;
131 }; 131 };
132 typedef std::vector<FileInfo> FileInfoList; 132 typedef std::vector<FileInfo> FileInfoList;
133 133
134 // Typedef for holding a map from app_id to DriveWebAppInfo so 134 // Typedef for holding a map from app_id to DriveWebAppInfo so
135 // we can look up information on the apps. 135 // we can look up information on the apps.
136 typedef std::map<std::string, gdata::DriveWebAppInfo*> WebAppInfoMap; 136 typedef std::map<std::string, drive::DriveWebAppInfo*> WebAppInfoMap;
137 137
138 // Look up apps in the registry, and collect applications that match the file 138 // Look up apps in the registry, and collect applications that match the file
139 // paths given. Returns the intersection of all available application ids in 139 // paths given. Returns the intersection of all available application ids in
140 // |available_apps| and a map of application ID to the Drive web application 140 // |available_apps| and a map of application ID to the Drive web application
141 // info collected in |app_info| so details can be collected later. The caller 141 // info collected in |app_info| so details can be collected later. The caller
142 // takes ownership of the pointers in |app_info|. 142 // takes ownership of the pointers in |app_info|.
143 static void IntersectAvailableDriveTasks( 143 static void IntersectAvailableDriveTasks(
144 gdata::DriveWebAppsRegistry* registry, 144 drive::DriveWebAppsRegistry* registry,
145 const FileInfoList& file_info_list, 145 const FileInfoList& file_info_list,
146 WebAppInfoMap* app_info, 146 WebAppInfoMap* app_info,
147 std::set<std::string>* available_apps); 147 std::set<std::string>* available_apps);
148 148
149 // Takes a map of app_id to application information in |app_info|, and the set 149 // Takes a map of app_id to application information in |app_info|, and the set
150 // of |available_apps| and adds Drive tasks to the |result_list| for each of 150 // of |available_apps| and adds Drive tasks to the |result_list| for each of
151 // the |available_apps|. If a default task is set in the result list, 151 // the |available_apps|. If a default task is set in the result list,
152 // then |default_already_set| is set to true. 152 // then |default_already_set| is set to true.
153 static void CreateDriveTasks(gdata::DriveWebAppsRegistry* registry, 153 static void CreateDriveTasks(drive::DriveWebAppsRegistry* registry,
154 const WebAppInfoMap& app_info, 154 const WebAppInfoMap& app_info,
155 const std::set<std::string>& available_apps, 155 const std::set<std::string>& available_apps,
156 const std::set<std::string>& default_apps, 156 const std::set<std::string>& default_apps,
157 ListValue* result_list, 157 ListValue* result_list,
158 bool* default_already_set); 158 bool* default_already_set);
159 159
160 // Looks in the preferences and finds any of the available apps that are 160 // Looks in the preferences and finds any of the available apps that are
161 // also listed as default apps for any of the files in the info list. 161 // also listed as default apps for any of the files in the info list.
162 void FindDefaultDriveTasks(const FileInfoList& file_info_list, 162 void FindDefaultDriveTasks(const FileInfoList& file_info_list,
163 const std::set<std::string>& available_apps, 163 const std::set<std::string>& available_apps,
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 virtual bool RunImpl() OVERRIDE; 325 virtual bool RunImpl() OVERRIDE;
326 326
327 private: 327 private:
328 // A callback method to handle the result of 328 // A callback method to handle the result of
329 // GetLocalPathsOnFileThreadAndRunCallbackOnUIThread. 329 // GetLocalPathsOnFileThreadAndRunCallbackOnUIThread.
330 void GetLocalPathsResponseOnUIThread(const std::string& mount_type_str, 330 void GetLocalPathsResponseOnUIThread(const std::string& mount_type_str,
331 const SelectedFileInfoList& files); 331 const SelectedFileInfoList& files);
332 // A callback method to handle the result of SetMountedState. 332 // A callback method to handle the result of SetMountedState.
333 void OnMountedStateSet(const std::string& mount_type, 333 void OnMountedStateSet(const std::string& mount_type,
334 const FilePath::StringType& file_name, 334 const FilePath::StringType& file_name,
335 gdata::DriveFileError error, 335 drive::DriveFileError error,
336 const FilePath& file_path); 336 const FilePath& file_path);
337 }; 337 };
338 338
339 // Unmounts selected device. Expects mount point path as an argument. 339 // Unmounts selected device. Expects mount point path as an argument.
340 class RemoveMountFunction : public FileBrowserFunction { 340 class RemoveMountFunction : public FileBrowserFunction {
341 public: 341 public:
342 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.removeMount"); 342 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.removeMount");
343 343
344 RemoveMountFunction(); 344 RemoveMountFunction();
345 345
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 virtual ~GetSizeStatsFunction(); 397 virtual ~GetSizeStatsFunction();
398 398
399 // AsyncExtensionFunction overrides. 399 // AsyncExtensionFunction overrides.
400 virtual bool RunImpl() OVERRIDE; 400 virtual bool RunImpl() OVERRIDE;
401 401
402 private: 402 private:
403 // A callback method to handle the result of 403 // A callback method to handle the result of
404 // GetLocalPathsOnFileThreadAndRunCallbackOnUIThread. 404 // GetLocalPathsOnFileThreadAndRunCallbackOnUIThread.
405 void GetLocalPathsResponseOnUIThread(const SelectedFileInfoList& files); 405 void GetLocalPathsResponseOnUIThread(const SelectedFileInfoList& files);
406 406
407 void GetDriveAvailableSpaceCallback(gdata::DriveFileError error, 407 void GetDriveAvailableSpaceCallback(drive::DriveFileError error,
408 int64 bytes_total, 408 int64 bytes_total,
409 int64 bytes_used); 409 int64 bytes_used);
410 410
411 void GetSizeStatsCallbackOnUIThread(size_t total_size_kb, 411 void GetSizeStatsCallbackOnUIThread(size_t total_size_kb,
412 size_t remaining_size_kb); 412 size_t remaining_size_kb);
413 void CallGetSizeStatsOnFileThread(const std::string& mount_path); 413 void CallGetSizeStatsOnFileThread(const std::string& mount_path);
414 }; 414 };
415 415
416 // Retrieves devices meta-data. Expects volume's device path as an argument. 416 // Retrieves devices meta-data. Expects volume's device path as an argument.
417 class GetVolumeMetadataFunction : public FileBrowserFunction { 417 class GetVolumeMetadataFunction : public FileBrowserFunction {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 protected: 466 protected:
467 virtual ~FileDialogStringsFunction() {} 467 virtual ~FileDialogStringsFunction() {}
468 468
469 // SyncExtensionFunction overrides. 469 // SyncExtensionFunction overrides.
470 virtual bool RunImpl() OVERRIDE; 470 virtual bool RunImpl() OVERRIDE;
471 }; 471 };
472 472
473 // Retrieve property information for multiple files, returning a list of the 473 // Retrieve property information for multiple files, returning a list of the
474 // same length as the input list of file URLs. If a particular file has an 474 // same length as the input list of file URLs. If a particular file has an
475 // error, then return a dictionary with the key "error" set to the error number 475 // error, then return a dictionary with the key "error" set to the error number
476 // (gdata::DriveFileError) for that entry in the returned list. 476 // (drive::DriveFileError) for that entry in the returned list.
477 class GetDriveFilePropertiesFunction : public FileBrowserFunction { 477 class GetDriveFilePropertiesFunction : public FileBrowserFunction {
478 public: 478 public:
479 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.getGDataFileProperties"); 479 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.getGDataFileProperties");
480 480
481 GetDriveFilePropertiesFunction(); 481 GetDriveFilePropertiesFunction();
482 482
483 protected: 483 protected:
484 virtual ~GetDriveFilePropertiesFunction(); 484 virtual ~GetDriveFilePropertiesFunction();
485 485
486 void GetNextFileProperties(); 486 void GetNextFileProperties();
487 void CompleteGetFileProperties(); 487 void CompleteGetFileProperties();
488 488
489 // Virtual function that can be overridden to do operations on each virtual 489 // Virtual function that can be overridden to do operations on each virtual
490 // file path and update its the properties. 490 // file path and update its the properties.
491 virtual void DoOperation(const FilePath& file_path, 491 virtual void DoOperation(const FilePath& file_path,
492 base::DictionaryValue* properties, 492 base::DictionaryValue* properties,
493 scoped_ptr<gdata::DriveEntryProto> entry_proto); 493 scoped_ptr<drive::DriveEntryProto> entry_proto);
494 494
495 void OnOperationComplete(const FilePath& file_path, 495 void OnOperationComplete(const FilePath& file_path,
496 base::DictionaryValue* properties, 496 base::DictionaryValue* properties,
497 gdata::DriveFileError error, 497 drive::DriveFileError error,
498 scoped_ptr<gdata::DriveEntryProto> entry_proto); 498 scoped_ptr<drive::DriveEntryProto> entry_proto);
499 499
500 // AsyncExtensionFunction overrides. 500 // AsyncExtensionFunction overrides.
501 virtual bool RunImpl() OVERRIDE; 501 virtual bool RunImpl() OVERRIDE;
502 502
503 // Builds list of file properies. Calls DoOperation for each file. 503 // Builds list of file properies. Calls DoOperation for each file.
504 void PrepareResults(); 504 void PrepareResults();
505 505
506 private: 506 private:
507 void OnGetFileInfo(const FilePath& file_path, 507 void OnGetFileInfo(const FilePath& file_path,
508 base::DictionaryValue* property_dict, 508 base::DictionaryValue* property_dict,
509 gdata::DriveFileError error, 509 drive::DriveFileError error,
510 scoped_ptr<gdata::DriveEntryProto> entry_proto); 510 scoped_ptr<drive::DriveEntryProto> entry_proto);
511 511
512 void CacheStateReceived(base::DictionaryValue* property_dict, 512 void CacheStateReceived(base::DictionaryValue* property_dict,
513 bool success, 513 bool success,
514 const gdata::DriveCacheEntry& cache_entry); 514 const drive::DriveCacheEntry& cache_entry);
515 515
516 size_t current_index_; 516 size_t current_index_;
517 base::ListValue* path_list_; 517 base::ListValue* path_list_;
518 scoped_ptr<base::ListValue> file_properties_; 518 scoped_ptr<base::ListValue> file_properties_;
519 }; 519 };
520 520
521 // Pin/unpin multiple files in the cache, returning a list of file 521 // Pin/unpin multiple files in the cache, returning a list of file
522 // properties with the updated cache state. The returned array is the 522 // properties with the updated cache state. The returned array is the
523 // same length as the input list of file URLs. If a particular file 523 // same length as the input list of file URLs. If a particular file
524 // has an error, then return a dictionary with the key "error" set to 524 // has an error, then return a dictionary with the key "error" set to
525 // the error number (gdata::DriveFileError) for that entry in the 525 // the error number (drive::DriveFileError) for that entry in the
526 // returned list. 526 // returned list.
527 class PinDriveFileFunction : public GetDriveFilePropertiesFunction { 527 class PinDriveFileFunction : public GetDriveFilePropertiesFunction {
528 public: 528 public:
529 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.pinGDataFile"); 529 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.pinGDataFile");
530 530
531 PinDriveFileFunction(); 531 PinDriveFileFunction();
532 532
533 protected: 533 protected:
534 virtual ~PinDriveFileFunction(); 534 virtual ~PinDriveFileFunction();
535 535
536 // AsyncExtensionFunction overrides. 536 // AsyncExtensionFunction overrides.
537 virtual bool RunImpl() OVERRIDE; 537 virtual bool RunImpl() OVERRIDE;
538 538
539 private: 539 private:
540 // Actually do the pinning/unpinning of each file. 540 // Actually do the pinning/unpinning of each file.
541 virtual void DoOperation( 541 virtual void DoOperation(
542 const FilePath& file_path, 542 const FilePath& file_path,
543 base::DictionaryValue* properties, 543 base::DictionaryValue* properties,
544 scoped_ptr<gdata::DriveEntryProto> entry_proto) OVERRIDE; 544 scoped_ptr<drive::DriveEntryProto> entry_proto) OVERRIDE;
545 545
546 // Callback for SetPinState. Updates properties with error. 546 // Callback for SetPinState. Updates properties with error.
547 void OnPinStateSet(const FilePath& path, 547 void OnPinStateSet(const FilePath& path,
548 base::DictionaryValue* properties, 548 base::DictionaryValue* properties,
549 scoped_ptr<gdata::DriveEntryProto> entry_proto, 549 scoped_ptr<drive::DriveEntryProto> entry_proto,
550 gdata::DriveFileError error, 550 drive::DriveFileError error,
551 const std::string& resource_id, 551 const std::string& resource_id,
552 const std::string& md5); 552 const std::string& md5);
553 553
554 // True for pin, false for unpin. 554 // True for pin, false for unpin.
555 bool set_pin_; 555 bool set_pin_;
556 }; 556 };
557 557
558 // Get file locations for the given list of file URLs. Returns a list of 558 // Get file locations for the given list of file URLs. Returns a list of
559 // location idenfitiers, like ['drive', 'local'], where 'drive' means the 559 // location idenfitiers, like ['drive', 'local'], where 'drive' means the
560 // file is on gdata, and 'local' means the file is on the local drive. 560 // 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
600 // A callback method to handle the result of 600 // A callback method to handle the result of
601 // GetLocalPathsOnFileThreadAndRunCallbackOnUIThread. 601 // GetLocalPathsOnFileThreadAndRunCallbackOnUIThread.
602 void GetLocalPathsResponseOnUIThread(const SelectedFileInfoList& files); 602 void GetLocalPathsResponseOnUIThread(const SelectedFileInfoList& files);
603 603
604 // Gets the file on the top of the |remaining_drive_paths_| or sends the 604 // Gets the file on the top of the |remaining_drive_paths_| or sends the
605 // response if the queue is empty. 605 // response if the queue is empty.
606 void GetFileOrSendResponse(); 606 void GetFileOrSendResponse();
607 607
608 // Called by DriveFileSystem::GetFile(). Pops the file from 608 // Called by DriveFileSystem::GetFile(). Pops the file from
609 // |remaining_drive_paths_|, and calls GetFileOrSendResponse(). 609 // |remaining_drive_paths_|, and calls GetFileOrSendResponse().
610 void OnFileReady(gdata::DriveFileError error, 610 void OnFileReady(drive::DriveFileError error,
611 const FilePath& local_path, 611 const FilePath& local_path,
612 const std::string& unused_mime_type, 612 const std::string& unused_mime_type,
613 gdata::DriveFileType file_type); 613 drive::DriveFileType file_type);
614 614
615 std::queue<FilePath> remaining_drive_paths_; 615 std::queue<FilePath> remaining_drive_paths_;
616 ListValue* local_paths_; 616 ListValue* local_paths_;
617 }; 617 };
618 618
619 // Implements the chrome.fileBrowserPrivate.executeTask method. 619 // Implements the chrome.fileBrowserPrivate.executeTask method.
620 class GetFileTransfersFunction : public AsyncExtensionFunction { 620 class GetFileTransfersFunction : public AsyncExtensionFunction {
621 public: 621 public:
622 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.getFileTransfers"); 622 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.getFileTransfers");
623 623
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 661
662 // AsyncExtensionFunction overrides. 662 // AsyncExtensionFunction overrides.
663 virtual bool RunImpl() OVERRIDE; 663 virtual bool RunImpl() OVERRIDE;
664 664
665 private: 665 private:
666 // Helper callback for handling response from 666 // Helper callback for handling response from
667 // GetLocalPathsOnFileThreadAndRunCallbackOnUIThread() 667 // GetLocalPathsOnFileThreadAndRunCallbackOnUIThread()
668 void GetLocalPathsResponseOnUIThread(const SelectedFileInfoList& files); 668 void GetLocalPathsResponseOnUIThread(const SelectedFileInfoList& files);
669 669
670 // Helper callback for handling response from DriveFileSystem::TransferFile(). 670 // Helper callback for handling response from DriveFileSystem::TransferFile().
671 void OnTransferCompleted(gdata::DriveFileError error); 671 void OnTransferCompleted(drive::DriveFileError error);
672 }; 672 };
673 673
674 // Read setting value. 674 // Read setting value.
675 class GetDrivePreferencesFunction : public SyncExtensionFunction { 675 class GetDrivePreferencesFunction : public SyncExtensionFunction {
676 public: 676 public:
677 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.getGDataPreferences"); 677 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.getGDataPreferences");
678 678
679 protected: 679 protected:
680 virtual ~GetDrivePreferencesFunction() {} 680 virtual ~GetDrivePreferencesFunction() {}
681 681
(...skipping 21 matching lines...) Expand all
703 virtual ~SearchDriveFunction(); 703 virtual ~SearchDriveFunction();
704 704
705 virtual bool RunImpl() OVERRIDE; 705 virtual bool RunImpl() OVERRIDE;
706 706
707 private: 707 private:
708 // Callback fo OpenFileSystem called from RunImpl. 708 // Callback fo OpenFileSystem called from RunImpl.
709 void OnFileSystemOpened(base::PlatformFileError result, 709 void OnFileSystemOpened(base::PlatformFileError result,
710 const std::string& file_system_name, 710 const std::string& file_system_name,
711 const GURL& file_system_url); 711 const GURL& file_system_url);
712 // Callback for gdata::SearchAsync called after file system is opened. 712 // Callback for gdata::SearchAsync called after file system is opened.
713 void OnSearch(gdata::DriveFileError error, 713 void OnSearch(drive::DriveFileError error,
714 const GURL& next_feed, 714 const GURL& next_feed,
715 scoped_ptr<std::vector<gdata::SearchResultInfo> > result_paths); 715 scoped_ptr<std::vector<drive::SearchResultInfo> > result_paths);
716 716
717 // Query for which the search is being performed. 717 // Query for which the search is being performed.
718 std::string query_; 718 std::string query_;
719 std::string next_feed_; 719 std::string next_feed_;
720 // Information about remote file system we will need to create file entries 720 // Information about remote file system we will need to create file entries
721 // to represent search results. 721 // to represent search results.
722 std::string file_system_name_; 722 std::string file_system_name_;
723 GURL file_system_url_; 723 GURL file_system_url_;
724 }; 724 };
725 725
(...skipping 25 matching lines...) Expand all
751 DECLARE_EXTENSION_FUNCTION_NAME( 751 DECLARE_EXTENSION_FUNCTION_NAME(
752 "fileBrowserPrivate.requestDirectoryRefresh"); 752 "fileBrowserPrivate.requestDirectoryRefresh");
753 753
754 protected: 754 protected:
755 virtual ~RequestDirectoryRefreshFunction() {} 755 virtual ~RequestDirectoryRefreshFunction() {}
756 756
757 virtual bool RunImpl() OVERRIDE; 757 virtual bool RunImpl() OVERRIDE;
758 }; 758 };
759 759
760 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_BROWSER_PRIVATE_API_H_ 760 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_BROWSER_PRIVATE_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698