| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_DRIVE_DRIVE_APP_REGISTRY_H_ | 5 #ifndef CHROME_BROWSER_DRIVE_DRIVE_APP_REGISTRY_H_ |
| 6 #define CHROME_BROWSER_DRIVE_DRIVE_APP_REGISTRY_H_ | 6 #define CHROME_BROWSER_DRIVE_DRIVE_APP_REGISTRY_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 // Drive document icon URLs for this app, paired with their size (length of | 44 // Drive document icon URLs for this app, paired with their size (length of |
| 45 // a side in pixels). | 45 // a side in pixels). |
| 46 google_apis::InstalledApp::IconList document_icons; | 46 google_apis::InstalledApp::IconList document_icons; |
| 47 // App name. | 47 // App name. |
| 48 std::string app_name; | 48 std::string app_name; |
| 49 // URL for opening a new file in the app. Empty if the app does not support | 49 // URL for opening a new file in the app. Empty if the app does not support |
| 50 // new file creation. | 50 // new file creation. |
| 51 GURL create_url; | 51 GURL create_url; |
| 52 }; | 52 }; |
| 53 | 53 |
| 54 // Callback type for UninstallApp(). | |
| 55 typedef base::Callback<void(google_apis::GDataErrorCode)> UninstallCallback; | |
| 56 | |
| 57 // Keeps the track of installed drive applications in-memory. | 54 // Keeps the track of installed drive applications in-memory. |
| 58 class DriveAppRegistry { | 55 class DriveAppRegistry { |
| 59 public: | 56 public: |
| 60 explicit DriveAppRegistry(DriveServiceInterface* scheduler); | 57 explicit DriveAppRegistry(DriveServiceInterface* scheduler); |
| 61 ~DriveAppRegistry(); | 58 ~DriveAppRegistry(); |
| 62 | 59 |
| 63 // Returns a list of Drive app information for the |file_extension| with | 60 // Returns a list of Drive app information for the |file_extension| with |
| 64 // |mime_type|. | 61 // |mime_type|. |
| 65 void GetAppsForFile(const base::FilePath::StringType& file_extension, | 62 void GetAppsForFile(const base::FilePath::StringType& file_extension, |
| 66 const std::string& mime_type, | 63 const std::string& mime_type, |
| 67 std::vector<DriveAppInfo>* apps) const; | 64 std::vector<DriveAppInfo>* apps) const; |
| 68 | 65 |
| 69 // Returns the list of all Drive apps installed. | |
| 70 void GetAppList(std::vector<DriveAppInfo>* apps) const; | |
| 71 | |
| 72 // Uninstalls the app specified by |app_id|. This method sends requests to the | |
| 73 // remote server, and returns the result to |callback| asynchronously. | |
| 74 // |callback| must not be null. | |
| 75 void UninstallApp(const std::string& app_id, | |
| 76 const UninstallCallback& callback); | |
| 77 | |
| 78 // Checks whether UinstallApp is supported. The feature is available only for | |
| 79 // clients with whitelisted API keys (like Official Google Chrome build). | |
| 80 static bool IsAppUninstallSupported(); | |
| 81 | |
| 82 // Updates this registry by fetching the data from the server. | 66 // Updates this registry by fetching the data from the server. |
| 83 void Update(); | 67 void Update(); |
| 84 | 68 |
| 85 // Updates this registry from the |app_list|. | 69 // Updates this registry from the |app_list|. |
| 86 void UpdateFromAppList(const google_apis::AppList& app_list); | 70 void UpdateFromAppList(const google_apis::AppList& app_list); |
| 87 | 71 |
| 88 private: | 72 private: |
| 89 // Part of Update(). Runs upon the completion of fetching the Drive apps | 73 // Part of Update(). Runs upon the completion of fetching the Drive apps |
| 90 // data from the server. | 74 // data from the server. |
| 91 void UpdateAfterGetAppList(google_apis::GDataErrorCode gdata_error, | 75 void UpdateAfterGetAppList(google_apis::GDataErrorCode gdata_error, |
| 92 scoped_ptr<google_apis::AppList> app_list); | 76 scoped_ptr<google_apis::AppList> app_list); |
| 93 | 77 |
| 94 // Part of UninstallApp(). Receives the response from the server. | |
| 95 void OnAppUninstalled(const std::string& app_id, | |
| 96 const UninstallCallback& callback, | |
| 97 google_apis::GDataErrorCode error); | |
| 98 | |
| 99 // Map of application id to each app's info. | 78 // Map of application id to each app's info. |
| 100 std::map<std::string, DriveAppInfo> all_apps_; | 79 std::map<std::string, DriveAppInfo> all_apps_; |
| 101 | 80 |
| 102 // Defines mapping between file content type selectors (extensions, MIME | 81 // Defines mapping between file content type selectors (extensions, MIME |
| 103 // types) and corresponding app. | 82 // types) and corresponding app. |
| 104 typedef std::multimap<std::string, std::string> DriveAppFileSelectorMap; | 83 typedef std::multimap<std::string, std::string> DriveAppFileSelectorMap; |
| 105 DriveAppFileSelectorMap extension_map_; | 84 DriveAppFileSelectorMap extension_map_; |
| 106 DriveAppFileSelectorMap mimetype_map_; | 85 DriveAppFileSelectorMap mimetype_map_; |
| 107 | 86 |
| 108 DriveServiceInterface* drive_service_; | 87 DriveServiceInterface* drive_service_; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 126 // Icons do not have to be sorted by the icon size. If there are no icons in | 105 // Icons do not have to be sorted by the icon size. If there are no icons in |
| 127 // the list, returns an empty URL. | 106 // the list, returns an empty URL. |
| 128 GURL FindPreferredIcon(const google_apis::InstalledApp::IconList& icons, | 107 GURL FindPreferredIcon(const google_apis::InstalledApp::IconList& icons, |
| 129 int preferred_size); | 108 int preferred_size); |
| 130 | 109 |
| 131 } // namespace util | 110 } // namespace util |
| 132 | 111 |
| 133 } // namespace drive | 112 } // namespace drive |
| 134 | 113 |
| 135 #endif // CHROME_BROWSER_DRIVE_DRIVE_APP_REGISTRY_H_ | 114 #endif // CHROME_BROWSER_DRIVE_DRIVE_APP_REGISTRY_H_ |
| OLD | NEW |