| 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 #include "chrome/browser/chromeos/drive/drive_app_registry.h" | 5 #include "chrome/browser/chromeos/drive/drive_app_registry.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 DriveAppInfo::DriveAppInfo() { | 46 DriveAppInfo::DriveAppInfo() { |
| 47 } | 47 } |
| 48 | 48 |
| 49 DriveAppInfo::DriveAppInfo( | 49 DriveAppInfo::DriveAppInfo( |
| 50 const std::string& app_id, | 50 const std::string& app_id, |
| 51 const google_apis::InstalledApp::IconList& app_icons, | 51 const google_apis::InstalledApp::IconList& app_icons, |
| 52 const google_apis::InstalledApp::IconList& document_icons, | 52 const google_apis::InstalledApp::IconList& document_icons, |
| 53 const std::string& web_store_id, | 53 const std::string& web_store_id, |
| 54 const std::string& app_name, | 54 const std::string& app_name, |
| 55 const std::string& object_type, | 55 const std::string& object_type, |
| 56 bool is_primary_selector) | 56 bool is_primary_selector, |
| 57 const GURL& create_url) |
| 57 : app_id(app_id), | 58 : app_id(app_id), |
| 58 app_icons(app_icons), | 59 app_icons(app_icons), |
| 59 document_icons(document_icons), | 60 document_icons(document_icons), |
| 60 web_store_id(web_store_id), | 61 web_store_id(web_store_id), |
| 61 app_name(app_name), | 62 app_name(app_name), |
| 62 object_type(object_type), | 63 object_type(object_type), |
| 63 is_primary_selector(is_primary_selector) { | 64 is_primary_selector(is_primary_selector), |
| 65 create_url(create_url) { |
| 64 } | 66 } |
| 65 | 67 |
| 66 DriveAppInfo::~DriveAppInfo() { | 68 DriveAppInfo::~DriveAppInfo() { |
| 67 } | 69 } |
| 68 | 70 |
| 69 DriveAppRegistry::DriveAppRegistry(JobScheduler* scheduler) | 71 DriveAppRegistry::DriveAppRegistry(JobScheduler* scheduler) |
| 70 : scheduler_(scheduler), | 72 : scheduler_(scheduler), |
| 71 is_updating_(false), | 73 is_updating_(false), |
| 72 weak_ptr_factory_(this) { | 74 weak_ptr_factory_(this) { |
| 73 } | 75 } |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 icon.icon_url())); | 162 icon.icon_url())); |
| 161 } | 163 } |
| 162 | 164 |
| 163 AddAppSelectorList(web_store_id, | 165 AddAppSelectorList(web_store_id, |
| 164 app.name(), | 166 app.name(), |
| 165 app_icons, | 167 app_icons, |
| 166 document_icons, | 168 document_icons, |
| 167 app.object_type(), | 169 app.object_type(), |
| 168 app.application_id(), | 170 app.application_id(), |
| 169 true, // primary | 171 true, // primary |
| 172 app.create_url(), |
| 170 app.primary_mimetypes(), | 173 app.primary_mimetypes(), |
| 171 &app_mimetypes_map_); | 174 &app_mimetypes_map_); |
| 172 AddAppSelectorList(web_store_id, | 175 AddAppSelectorList(web_store_id, |
| 173 app.name(), | 176 app.name(), |
| 174 app_icons, | 177 app_icons, |
| 175 document_icons, | 178 document_icons, |
| 176 app.object_type(), | 179 app.object_type(), |
| 177 app.application_id(), | 180 app.application_id(), |
| 178 false, // primary | 181 false, // primary |
| 182 app.create_url(), |
| 179 app.secondary_mimetypes(), | 183 app.secondary_mimetypes(), |
| 180 &app_mimetypes_map_); | 184 &app_mimetypes_map_); |
| 181 AddAppSelectorList(web_store_id, | 185 AddAppSelectorList(web_store_id, |
| 182 app.name(), | 186 app.name(), |
| 183 app_icons, | 187 app_icons, |
| 184 document_icons, | 188 document_icons, |
| 185 app.object_type(), | 189 app.object_type(), |
| 186 app.application_id(), | 190 app.application_id(), |
| 187 true, // primary | 191 true, // primary |
| 192 app.create_url(), |
| 188 app.primary_file_extensions(), | 193 app.primary_file_extensions(), |
| 189 &app_extension_map_); | 194 &app_extension_map_); |
| 190 AddAppSelectorList(web_store_id, | 195 AddAppSelectorList(web_store_id, |
| 191 app.name(), | 196 app.name(), |
| 192 app_icons, | 197 app_icons, |
| 193 document_icons, | 198 document_icons, |
| 194 app.object_type(), | 199 app.object_type(), |
| 195 app.application_id(), | 200 app.application_id(), |
| 196 false, // primary | 201 false, // primary |
| 202 app.create_url(), |
| 197 app.secondary_file_extensions(), | 203 app.secondary_file_extensions(), |
| 198 &app_extension_map_); | 204 &app_extension_map_); |
| 199 } | 205 } |
| 200 } | 206 } |
| 201 | 207 |
| 202 // static. | 208 // static. |
| 203 void DriveAppRegistry::AddAppSelectorList( | 209 void DriveAppRegistry::AddAppSelectorList( |
| 204 const std::string& web_store_id, | 210 const std::string& web_store_id, |
| 205 const std::string& app_name, | 211 const std::string& app_name, |
| 206 const google_apis::InstalledApp::IconList& app_icons, | 212 const google_apis::InstalledApp::IconList& app_icons, |
| 207 const google_apis::InstalledApp::IconList& document_icons, | 213 const google_apis::InstalledApp::IconList& document_icons, |
| 208 const std::string& object_type, | 214 const std::string& object_type, |
| 209 const std::string& app_id, | 215 const std::string& app_id, |
| 210 bool is_primary_selector, | 216 bool is_primary_selector, |
| 217 const GURL& create_url, |
| 211 const ScopedVector<std::string>& selectors, | 218 const ScopedVector<std::string>& selectors, |
| 212 DriveAppFileSelectorMap* map) { | 219 DriveAppFileSelectorMap* map) { |
| 213 for (ScopedVector<std::string>::const_iterator it = selectors.begin(); | 220 for (ScopedVector<std::string>::const_iterator it = selectors.begin(); |
| 214 it != selectors.end(); ++it) { | 221 it != selectors.end(); ++it) { |
| 215 std::string* value = *it; | 222 std::string* value = *it; |
| 216 map->insert(std::make_pair( | 223 map->insert(std::make_pair( |
| 217 *value, new DriveAppInfo(app_id, | 224 *value, new DriveAppInfo(app_id, |
| 218 app_icons, | 225 app_icons, |
| 219 document_icons, | 226 document_icons, |
| 220 web_store_id, | 227 web_store_id, |
| 221 app_name, | 228 app_name, |
| 222 object_type, | 229 object_type, |
| 223 is_primary_selector))); | 230 is_primary_selector, |
| 231 create_url))); |
| 224 } | 232 } |
| 225 } | 233 } |
| 226 | 234 |
| 227 void DriveAppRegistry::FindAppsForSelector( | 235 void DriveAppRegistry::FindAppsForSelector( |
| 228 const std::string& file_selector, | 236 const std::string& file_selector, |
| 229 const DriveAppFileSelectorMap& map, | 237 const DriveAppFileSelectorMap& map, |
| 230 std::vector<DriveAppInfo*>* matched_apps) const { | 238 std::vector<DriveAppInfo*>* matched_apps) const { |
| 231 for (DriveAppFileSelectorMap::const_iterator it = map.find(file_selector); | 239 for (DriveAppFileSelectorMap::const_iterator it = map.find(file_selector); |
| 232 it != map.end() && it->first == file_selector; ++it) { | 240 it != map.end() && it->first == file_selector; ++it) { |
| 233 matched_apps->push_back(it->second); | 241 matched_apps->push_back(it->second); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 248 for (google_apis::InstalledApp::IconList::const_reverse_iterator | 256 for (google_apis::InstalledApp::IconList::const_reverse_iterator |
| 249 iter = sorted_icons.rbegin(); | 257 iter = sorted_icons.rbegin(); |
| 250 iter != sorted_icons.rend() && iter->first >= preferred_size; ++iter) { | 258 iter != sorted_icons.rend() && iter->first >= preferred_size; ++iter) { |
| 251 result = iter->second; | 259 result = iter->second; |
| 252 } | 260 } |
| 253 return result; | 261 return result; |
| 254 } | 262 } |
| 255 | 263 |
| 256 } // namespace util | 264 } // namespace util |
| 257 } // namespace drive | 265 } // namespace drive |
| OLD | NEW |