| 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 #include "components/drive/drive_app_registry.h" | 5 #include "components/drive/drive_app_registry.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <set> | 10 #include <set> |
| 11 #include <utility> | 11 #include <utility> |
| 12 | 12 |
| 13 #include "base/callback.h" | 13 #include "base/callback.h" |
| 14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
| 15 #include "components/drive/drive_app_registry_observer.h" | 15 #include "components/drive/drive_app_registry_observer.h" |
| 16 #include "components/drive/service/drive_service_interface.h" | 16 #include "components/drive/service/drive_service_interface.h" |
| 17 #include "google_apis/drive/drive_api_parser.h" | 17 #include "google_apis/drive/drive_api_parser.h" |
| 18 #include "google_apis/google_api_keys.h" | 18 #include "google_apis/google_api_keys.h" |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 // Add {selector -> app_id} mapping to |map|. | 22 // Add {selector -> app_id} mapping to |map|. |
| 23 void AddAppSelectorList(const ScopedVector<std::string>& selectors, | 23 void AddAppSelectorList( |
| 24 const std::string& app_id, | 24 const std::vector<std::unique_ptr<std::string>>& selectors, |
| 25 std::multimap<std::string, std::string>* map) { | 25 const std::string& app_id, |
| 26 std::multimap<std::string, std::string>* map) { |
| 26 for (size_t i = 0; i < selectors.size(); ++i) | 27 for (size_t i = 0; i < selectors.size(); ++i) |
| 27 map->insert(std::make_pair(*selectors[i], app_id)); | 28 map->insert(std::make_pair(*selectors[i], app_id)); |
| 28 } | 29 } |
| 29 | 30 |
| 30 // Append list of app ids in |map| looked up by |selector| to |matched_apps|. | 31 // Append list of app ids in |map| looked up by |selector| to |matched_apps|. |
| 31 void FindAppsForSelector(const std::string& selector, | 32 void FindAppsForSelector(const std::string& selector, |
| 32 const std::multimap<std::string, std::string>& map, | 33 const std::multimap<std::string, std::string>& map, |
| 33 std::vector<std::string>* matched_apps) { | 34 std::vector<std::string>* matched_apps) { |
| 34 typedef std::multimap<std::string, std::string>::const_iterator iterator; | 35 typedef std::multimap<std::string, std::string>::const_iterator iterator; |
| 35 std::pair<iterator, iterator> range = map.equal_range(selector); | 36 std::pair<iterator, iterator> range = map.equal_range(selector); |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 | 241 |
| 241 // Go forward while the size is larger or equal to preferred_size. | 242 // Go forward while the size is larger or equal to preferred_size. |
| 242 size_t i = 1; | 243 size_t i = 1; |
| 243 while (i < sorted_icons.size() && sorted_icons[i].first >= preferred_size) | 244 while (i < sorted_icons.size() && sorted_icons[i].first >= preferred_size) |
| 244 ++i; | 245 ++i; |
| 245 return sorted_icons[i - 1].second; | 246 return sorted_icons[i - 1].second; |
| 246 } | 247 } |
| 247 | 248 |
| 248 } // namespace util | 249 } // namespace util |
| 249 } // namespace drive | 250 } // namespace drive |
| OLD | NEW |