| 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_DRIVE_DRIVE_APP_REGISTRY_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_APP_REGISTRY_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_APP_REGISTRY_H_ | 6 #define CHROME_BROWSER_CHROMEOS_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 15 matching lines...) Expand all Loading... |
| 26 class JobScheduler; | 26 class JobScheduler; |
| 27 | 27 |
| 28 // Data structure that defines Drive app. See | 28 // Data structure that defines Drive app. See |
| 29 // https://chrome.google.com/webstore/category/collection/drive_apps for | 29 // https://chrome.google.com/webstore/category/collection/drive_apps for |
| 30 // Drive apps available on the webstore. | 30 // Drive apps available on the webstore. |
| 31 struct DriveAppInfo { | 31 struct DriveAppInfo { |
| 32 DriveAppInfo(); | 32 DriveAppInfo(); |
| 33 DriveAppInfo(const std::string& app_id, | 33 DriveAppInfo(const std::string& app_id, |
| 34 const google_apis::InstalledApp::IconList& app_icons, | 34 const google_apis::InstalledApp::IconList& app_icons, |
| 35 const google_apis::InstalledApp::IconList& document_icons, | 35 const google_apis::InstalledApp::IconList& document_icons, |
| 36 const std::string& web_store_id, | |
| 37 const std::string& app_name, | 36 const std::string& app_name, |
| 38 const std::string& object_type, | |
| 39 bool is_primary_selector, | |
| 40 const GURL& create_url); | 37 const GURL& create_url); |
| 41 ~DriveAppInfo(); | 38 ~DriveAppInfo(); |
| 42 | 39 |
| 43 // Drive app id. | 40 // Drive app id. |
| 44 std::string app_id; | 41 std::string app_id; |
| 45 // Drive application icon URLs for this app, paired with their size (length of | 42 // Drive application icon URLs for this app, paired with their size (length of |
| 46 // a side in pixels). | 43 // a side in pixels). |
| 47 google_apis::InstalledApp::IconList app_icons; | 44 google_apis::InstalledApp::IconList app_icons; |
| 48 // Drive document icon URLs for this app, paired with their size (length of | 45 // Drive document icon URLs for this app, paired with their size (length of |
| 49 // a side in pixels). | 46 // a side in pixels). |
| 50 google_apis::InstalledApp::IconList document_icons; | 47 google_apis::InstalledApp::IconList document_icons; |
| 51 // Web store id/extension id; | |
| 52 std::string web_store_id; | |
| 53 // App name. | 48 // App name. |
| 54 std::string app_name; | 49 std::string app_name; |
| 55 // Object (file) type description handled by this app. | |
| 56 std::string object_type; | |
| 57 // Is app the primary selector for file (default open action). | |
| 58 bool is_primary_selector; | |
| 59 // URL for opening a new file in the app. | 50 // URL for opening a new file in the app. |
| 60 GURL create_url; | 51 GURL create_url; |
| 61 }; | 52 }; |
| 62 | 53 |
| 63 // Keeps the track of installed drive applications in-memory. | 54 // Keeps the track of installed drive applications in-memory. |
| 64 class DriveAppRegistry { | 55 class DriveAppRegistry { |
| 65 public: | 56 public: |
| 66 explicit DriveAppRegistry(JobScheduler* scheduler); | 57 explicit DriveAppRegistry(JobScheduler* scheduler); |
| 67 ~DriveAppRegistry(); | 58 ~DriveAppRegistry(); |
| 68 | 59 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 85 typedef std::multimap<std::string, DriveAppInfo*> DriveAppFileSelectorMap; | 76 typedef std::multimap<std::string, DriveAppInfo*> DriveAppFileSelectorMap; |
| 86 | 77 |
| 87 // Part of Update(). Runs upon the completion of fetching the Drive apps | 78 // Part of Update(). Runs upon the completion of fetching the Drive apps |
| 88 // data from the server. | 79 // data from the server. |
| 89 void UpdateAfterGetAppList(google_apis::GDataErrorCode gdata_error, | 80 void UpdateAfterGetAppList(google_apis::GDataErrorCode gdata_error, |
| 90 scoped_ptr<google_apis::AppList> app_list); | 81 scoped_ptr<google_apis::AppList> app_list); |
| 91 | 82 |
| 92 // Helper function for loading Drive application file |selectors| into | 83 // Helper function for loading Drive application file |selectors| into |
| 93 // corresponding |map|. | 84 // corresponding |map|. |
| 94 static void AddAppSelectorList( | 85 static void AddAppSelectorList( |
| 95 const std::string& web_store_id, | |
| 96 const std::string& app_name, | 86 const std::string& app_name, |
| 97 const google_apis::InstalledApp::IconList& app_icons, | 87 const google_apis::InstalledApp::IconList& app_icons, |
| 98 const google_apis::InstalledApp::IconList& document_icons, | 88 const google_apis::InstalledApp::IconList& document_icons, |
| 99 const std::string& object_type, | |
| 100 const std::string& app_id, | 89 const std::string& app_id, |
| 101 bool is_primary_selector, | |
| 102 const GURL& create_url, | 90 const GURL& create_url, |
| 103 const ScopedVector<std::string>& selectors, | 91 const ScopedVector<std::string>& selectors, |
| 104 DriveAppFileSelectorMap* map); | 92 DriveAppFileSelectorMap* map); |
| 105 | 93 |
| 106 // Finds matching |apps| from |map| based on provided file |selector|. | 94 // Finds matching |apps| from |map| based on provided file |selector|. |
| 107 void FindAppsForSelector(const std::string& selector, | 95 void FindAppsForSelector(const std::string& selector, |
| 108 const DriveAppFileSelectorMap& map, | 96 const DriveAppFileSelectorMap& map, |
| 109 std::vector<DriveAppInfo*>* matched_apps) const; | 97 std::vector<DriveAppInfo*>* matched_apps) const; |
| 110 | 98 |
| 111 JobScheduler* scheduler_; | 99 JobScheduler* scheduler_; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 135 // Icons do not have to be sorted by the icon size. If there are no icons in | 123 // Icons do not have to be sorted by the icon size. If there are no icons in |
| 136 // the list, returns an empty URL. | 124 // the list, returns an empty URL. |
| 137 GURL FindPreferredIcon(const google_apis::InstalledApp::IconList& icons, | 125 GURL FindPreferredIcon(const google_apis::InstalledApp::IconList& icons, |
| 138 int preferred_size); | 126 int preferred_size); |
| 139 | 127 |
| 140 } // namespace util | 128 } // namespace util |
| 141 | 129 |
| 142 } // namespace drive | 130 } // namespace drive |
| 143 | 131 |
| 144 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_APP_REGISTRY_H_ | 132 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_APP_REGISTRY_H_ |
| OLD | NEW |