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> |
11 | 11 |
12 #include "base/callback_forward.h" | 12 #include "base/callback_forward.h" |
13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
16 #include "base/observer_list.h" | 16 #include "base/observer_list.h" |
17 #include "base/threading/thread_checker.h" | 17 #include "base/threading/thread_checker.h" |
18 #include "google_apis/drive/gdata_errorcode.h" | 18 #include "google_apis/drive/drive_api_error_codes.h" |
19 #include "url/gurl.h" | 19 #include "url/gurl.h" |
20 | 20 |
21 namespace google_apis { | 21 namespace google_apis { |
22 class AppList; | 22 class AppList; |
23 } // namespace google_apis | 23 } // namespace google_apis |
24 | 24 |
25 namespace drive { | 25 namespace drive { |
26 | 26 |
27 class DriveAppRegistryObserver; | 27 class DriveAppRegistryObserver; |
28 class DriveServiceInterface; | 28 class DriveServiceInterface; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 std::string app_name; | 60 std::string app_name; |
61 // URL for opening a new file in the app. Empty if the app does not support | 61 // URL for opening a new file in the app. Empty if the app does not support |
62 // new file creation. | 62 // new file creation. |
63 GURL create_url; | 63 GURL create_url; |
64 // Returns if UninstallApp() is allowed for the app. Built-in apps have this | 64 // Returns if UninstallApp() is allowed for the app. Built-in apps have this |
65 // field set false. | 65 // field set false. |
66 bool is_removable; | 66 bool is_removable; |
67 }; | 67 }; |
68 | 68 |
69 // Callback type for UninstallApp(). | 69 // Callback type for UninstallApp(). |
70 typedef base::Callback<void(google_apis::GDataErrorCode)> UninstallCallback; | 70 typedef base::Callback<void(google_apis::DriveApiErrorCode)> UninstallCallback; |
71 | 71 |
72 // Keeps the track of installed drive applications in-memory. | 72 // Keeps the track of installed drive applications in-memory. |
73 class DriveAppRegistry { | 73 class DriveAppRegistry { |
74 public: | 74 public: |
75 explicit DriveAppRegistry(DriveServiceInterface* scheduler); | 75 explicit DriveAppRegistry(DriveServiceInterface* scheduler); |
76 ~DriveAppRegistry(); | 76 ~DriveAppRegistry(); |
77 | 77 |
78 // Returns a list of Drive app information for the |file_extension| with | 78 // Returns a list of Drive app information for the |file_extension| with |
79 // |mime_type|. | 79 // |mime_type|. |
80 void GetAppsForFile(const base::FilePath::StringType& file_extension, | 80 void GetAppsForFile(const base::FilePath::StringType& file_extension, |
(...skipping 19 matching lines...) Expand all Loading... |
100 | 100 |
101 // Updates this registry from the |app_list|. | 101 // Updates this registry from the |app_list|. |
102 void UpdateFromAppList(const google_apis::AppList& app_list); | 102 void UpdateFromAppList(const google_apis::AppList& app_list); |
103 | 103 |
104 void AddObserver(DriveAppRegistryObserver* observer); | 104 void AddObserver(DriveAppRegistryObserver* observer); |
105 void RemoveObserver(DriveAppRegistryObserver* observer); | 105 void RemoveObserver(DriveAppRegistryObserver* observer); |
106 | 106 |
107 private: | 107 private: |
108 // Part of Update(). Runs upon the completion of fetching the Drive apps | 108 // Part of Update(). Runs upon the completion of fetching the Drive apps |
109 // data from the server. | 109 // data from the server. |
110 void UpdateAfterGetAppList(google_apis::GDataErrorCode gdata_error, | 110 void UpdateAfterGetAppList(google_apis::DriveApiErrorCode gdata_error, |
111 scoped_ptr<google_apis::AppList> app_list); | 111 scoped_ptr<google_apis::AppList> app_list); |
112 | 112 |
113 // Part of UninstallApp(). Receives the response from the server. | 113 // Part of UninstallApp(). Receives the response from the server. |
114 void OnAppUninstalled(const std::string& app_id, | 114 void OnAppUninstalled(const std::string& app_id, |
115 const UninstallCallback& callback, | 115 const UninstallCallback& callback, |
116 google_apis::GDataErrorCode error); | 116 google_apis::DriveApiErrorCode error); |
117 | 117 |
118 // The class is expected to run on UI thread. | 118 // The class is expected to run on UI thread. |
119 base::ThreadChecker thread_checker_; | 119 base::ThreadChecker thread_checker_; |
120 | 120 |
121 // Map of application id to each app's info. | 121 // Map of application id to each app's info. |
122 std::map<std::string, DriveAppInfo> all_apps_; | 122 std::map<std::string, DriveAppInfo> all_apps_; |
123 | 123 |
124 // Defines mapping between file content type selectors (extensions, MIME | 124 // Defines mapping between file content type selectors (extensions, MIME |
125 // types) and corresponding app. | 125 // types) and corresponding app. |
126 typedef std::multimap<std::string, std::string> DriveAppFileSelectorMap; | 126 typedef std::multimap<std::string, std::string> DriveAppFileSelectorMap; |
(...skipping 24 matching lines...) Expand all Loading... |
151 // Icons do not have to be sorted by the icon size. If there are no icons in | 151 // Icons do not have to be sorted by the icon size. If there are no icons in |
152 // the list, returns an empty URL. | 152 // the list, returns an empty URL. |
153 GURL FindPreferredIcon(const DriveAppInfo::IconList& icons, | 153 GURL FindPreferredIcon(const DriveAppInfo::IconList& icons, |
154 int preferred_size); | 154 int preferred_size); |
155 | 155 |
156 } // namespace util | 156 } // namespace util |
157 | 157 |
158 } // namespace drive | 158 } // namespace drive |
159 | 159 |
160 #endif // CHROME_BROWSER_DRIVE_DRIVE_APP_REGISTRY_H_ | 160 #endif // CHROME_BROWSER_DRIVE_DRIVE_APP_REGISTRY_H_ |
OLD | NEW |