| 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 const std::string& mime_type, | 63 const std::string& mime_type, |
| 64 ScopedVector<DriveAppInfo>* apps) const; | 64 ScopedVector<DriveAppInfo>* apps) const; |
| 65 | 65 |
| 66 // Updates this registry by fetching the data from the server. | 66 // Updates this registry by fetching the data from the server. |
| 67 void Update(); | 67 void Update(); |
| 68 | 68 |
| 69 // Updates this registry from the |app_list|. | 69 // Updates this registry from the |app_list|. |
| 70 void UpdateFromAppList(const google_apis::AppList& app_list); | 70 void UpdateFromAppList(const google_apis::AppList& app_list); |
| 71 | 71 |
| 72 private: | 72 private: |
| 73 | |
| 74 // Defines mapping between file content type selectors (extensions, MIME | |
| 75 // types) and corresponding app. | |
| 76 typedef std::multimap<std::string, DriveAppInfo*> DriveAppFileSelectorMap; | |
| 77 | |
| 78 // 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 |
| 79 // data from the server. | 74 // data from the server. |
| 80 void UpdateAfterGetAppList(google_apis::GDataErrorCode gdata_error, | 75 void UpdateAfterGetAppList(google_apis::GDataErrorCode gdata_error, |
| 81 scoped_ptr<google_apis::AppList> app_list); | 76 scoped_ptr<google_apis::AppList> app_list); |
| 82 | 77 |
| 83 // Helper function for loading Drive application file |selectors| into | 78 // Map of application id to each app's info. |
| 84 // corresponding |map|. | 79 std::map<std::string, DriveAppInfo> all_apps_; |
| 85 static void AddAppSelectorList( | |
| 86 const std::string& app_name, | |
| 87 const google_apis::InstalledApp::IconList& app_icons, | |
| 88 const google_apis::InstalledApp::IconList& document_icons, | |
| 89 const std::string& app_id, | |
| 90 const GURL& create_url, | |
| 91 const ScopedVector<std::string>& selectors, | |
| 92 DriveAppFileSelectorMap* map); | |
| 93 | 80 |
| 94 // Finds matching |apps| from |map| based on provided file |selector|. | 81 // Defines mapping between file content type selectors (extensions, MIME |
| 95 void FindAppsForSelector(const std::string& selector, | 82 // types) and corresponding app. |
| 96 const DriveAppFileSelectorMap& map, | 83 typedef std::multimap<std::string, std::string> DriveAppFileSelectorMap; |
| 97 std::vector<DriveAppInfo*>* matched_apps) const; | 84 DriveAppFileSelectorMap extension_map_; |
| 85 DriveAppFileSelectorMap mimetype_map_; |
| 98 | 86 |
| 99 JobScheduler* scheduler_; | 87 JobScheduler* scheduler_; |
| 100 | 88 |
| 101 // Map of filename extension to application info. | |
| 102 DriveAppFileSelectorMap app_extension_map_; | |
| 103 | |
| 104 // Map of MIME type to application info. | |
| 105 DriveAppFileSelectorMap app_mimetypes_map_; | |
| 106 | |
| 107 bool is_updating_; | 89 bool is_updating_; |
| 108 | 90 |
| 109 // Note: This should remain the last member so it'll be destroyed and | 91 // Note: This should remain the last member so it'll be destroyed and |
| 110 // invalidate the weak pointers before any other members are destroyed. | 92 // invalidate the weak pointers before any other members are destroyed. |
| 111 base::WeakPtrFactory<DriveAppRegistry> weak_ptr_factory_; | 93 base::WeakPtrFactory<DriveAppRegistry> weak_ptr_factory_; |
| 112 DISALLOW_COPY_AND_ASSIGN(DriveAppRegistry); | 94 DISALLOW_COPY_AND_ASSIGN(DriveAppRegistry); |
| 113 }; | 95 }; |
| 114 | 96 |
| 115 namespace util { | 97 namespace util { |
| 116 | 98 |
| 117 // The preferred icon size, which should usually be used for FindPreferredIcon; | 99 // The preferred icon size, which should usually be used for FindPreferredIcon; |
| 118 const int kPreferredIconSize = 16; | 100 const int kPreferredIconSize = 16; |
| 119 | 101 |
| 120 // Finds an icon in the list of icons. If unable to find an icon of the exact | 102 // Finds an icon in the list of icons. If unable to find an icon of the exact |
| 121 // size requested, returns one with the next larger size. If all icons are | 103 // size requested, returns one with the next larger size. If all icons are |
| 122 // smaller than the preferred size, we'll return the largest one available. | 104 // smaller than the preferred size, we'll return the largest one available. |
| 123 // 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 |
| 124 // the list, returns an empty URL. | 106 // the list, returns an empty URL. |
| 125 GURL FindPreferredIcon(const google_apis::InstalledApp::IconList& icons, | 107 GURL FindPreferredIcon(const google_apis::InstalledApp::IconList& icons, |
| 126 int preferred_size); | 108 int preferred_size); |
| 127 | 109 |
| 128 } // namespace util | 110 } // namespace util |
| 129 | 111 |
| 130 } // namespace drive | 112 } // namespace drive |
| 131 | 113 |
| 132 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_APP_REGISTRY_H_ | 114 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_APP_REGISTRY_H_ |
| OLD | NEW |