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/drive/drive_app_registry.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "chrome/browser/drive/drive_service_interface.h" | 12 #include "chrome/browser/drive/drive_service_interface.h" |
13 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
14 #include "google_apis/drive/drive_api_parser.h" | 14 #include "google_apis/drive/drive_api_parser.h" |
15 | 15 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 } | 68 } |
69 | 69 |
70 void DriveAppRegistry::GetAppsForFile( | 70 void DriveAppRegistry::GetAppsForFile( |
71 const base::FilePath::StringType& file_extension, | 71 const base::FilePath::StringType& file_extension, |
72 const std::string& mime_type, | 72 const std::string& mime_type, |
73 std::vector<DriveAppInfo>* apps) const { | 73 std::vector<DriveAppInfo>* apps) const { |
74 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 74 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
75 | 75 |
76 std::vector<std::string> matched_apps; | 76 std::vector<std::string> matched_apps; |
77 if (!file_extension.empty()) { | 77 if (!file_extension.empty()) { |
78 const base::FilePath::StringType without_dot = file_extension.substr(1); | 78 const std::string without_dot = |
| 79 base::FilePath(file_extension.substr(1)).AsUTF8Unsafe(); |
79 FindAppsForSelector(without_dot, extension_map_, &matched_apps); | 80 FindAppsForSelector(without_dot, extension_map_, &matched_apps); |
80 } | 81 } |
81 if (!mime_type.empty()) | 82 if (!mime_type.empty()) |
82 FindAppsForSelector(mime_type, mimetype_map_, &matched_apps); | 83 FindAppsForSelector(mime_type, mimetype_map_, &matched_apps); |
83 | 84 |
84 // Insert found Drive apps into |apps|, but skip duplicate results. | 85 // Insert found Drive apps into |apps|, but skip duplicate results. |
85 std::set<std::string> inserted_app_ids; | 86 std::set<std::string> inserted_app_ids; |
86 for (size_t i = 0; i < matched_apps.size(); ++i) { | 87 for (size_t i = 0; i < matched_apps.size(); ++i) { |
87 if (inserted_app_ids.count(matched_apps[i]) == 0) { | 88 if (inserted_app_ids.count(matched_apps[i]) == 0) { |
88 inserted_app_ids.insert(matched_apps[i]); | 89 inserted_app_ids.insert(matched_apps[i]); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 | 172 |
172 // Go forward while the size is larger or equal to preferred_size. | 173 // Go forward while the size is larger or equal to preferred_size. |
173 size_t i = 1; | 174 size_t i = 1; |
174 while (i < sorted_icons.size() && sorted_icons[i].first >= preferred_size) | 175 while (i < sorted_icons.size() && sorted_icons[i].first >= preferred_size) |
175 ++i; | 176 ++i; |
176 return sorted_icons[i - 1].second; | 177 return sorted_icons[i - 1].second; |
177 } | 178 } |
178 | 179 |
179 } // namespace util | 180 } // namespace util |
180 } // namespace drive | 181 } // namespace drive |
OLD | NEW |