OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/file_manager/file_tasks.h" | 5 #include "chrome/browser/chromeos/file_manager/file_tasks.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/prefs/pref_registry_simple.h" | 10 #include "base/prefs/pref_registry_simple.h" |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 // Foo.app can handle "text/plain" and "text/html" | 184 // Foo.app can handle "text/plain" and "text/html" |
185 scoped_ptr<google_apis::AppResource> foo_app(new google_apis::AppResource); | 185 scoped_ptr<google_apis::AppResource> foo_app(new google_apis::AppResource); |
186 foo_app->set_product_url( | 186 foo_app->set_product_url( |
187 GURL("https://chrome.google.com/webstore/detail/foo_app_id")); | 187 GURL("https://chrome.google.com/webstore/detail/foo_app_id")); |
188 foo_app->set_application_id("foo_app_id"); | 188 foo_app->set_application_id("foo_app_id"); |
189 foo_app->set_name("Foo"); | 189 foo_app->set_name("Foo"); |
190 foo_app->set_object_type("foo_object_type"); | 190 foo_app->set_object_type("foo_object_type"); |
191 ScopedVector<std::string> foo_mime_types; | 191 ScopedVector<std::string> foo_mime_types; |
192 foo_mime_types.push_back(new std::string("text/plain")); | 192 foo_mime_types.push_back(new std::string("text/plain")); |
193 foo_mime_types.push_back(new std::string("text/html")); | 193 foo_mime_types.push_back(new std::string("text/html")); |
194 foo_app->set_primary_mimetypes(&foo_mime_types); | 194 foo_app->set_primary_mimetypes(foo_mime_types.Pass()); |
195 | 195 |
196 // Bar.app can only handle "text/plain". | 196 // Bar.app can only handle "text/plain". |
197 scoped_ptr<google_apis::AppResource> bar_app(new google_apis::AppResource); | 197 scoped_ptr<google_apis::AppResource> bar_app(new google_apis::AppResource); |
198 bar_app->set_product_url( | 198 bar_app->set_product_url( |
199 GURL("https://chrome.google.com/webstore/detail/bar_app_id")); | 199 GURL("https://chrome.google.com/webstore/detail/bar_app_id")); |
200 bar_app->set_application_id("bar_app_id"); | 200 bar_app->set_application_id("bar_app_id"); |
201 bar_app->set_name("Bar"); | 201 bar_app->set_name("Bar"); |
202 bar_app->set_object_type("bar_object_type"); | 202 bar_app->set_object_type("bar_object_type"); |
203 ScopedVector<std::string> bar_mime_types; | 203 ScopedVector<std::string> bar_mime_types; |
204 bar_mime_types.push_back(new std::string("text/plain")); | 204 bar_mime_types.push_back(new std::string("text/plain")); |
205 bar_app->set_primary_mimetypes(&bar_mime_types); | 205 bar_app->set_primary_mimetypes(bar_mime_types.Pass()); |
206 | 206 |
207 // Prepare DriveAppRegistry from Foo.app and Bar.app. | 207 // Prepare DriveAppRegistry from Foo.app and Bar.app. |
208 ScopedVector<google_apis::AppResource> app_resources; | 208 ScopedVector<google_apis::AppResource> app_resources; |
209 app_resources.push_back(foo_app.release()); | 209 app_resources.push_back(foo_app.release()); |
210 app_resources.push_back(bar_app.release()); | 210 app_resources.push_back(bar_app.release()); |
211 google_apis::AppList app_list; | 211 google_apis::AppList app_list; |
212 app_list.set_items(&app_resources); | 212 app_list.set_items(app_resources.Pass()); |
213 drive::DriveAppRegistry drive_app_registry(NULL); | 213 drive::DriveAppRegistry drive_app_registry(NULL); |
214 drive_app_registry.UpdateFromAppList(app_list); | 214 drive_app_registry.UpdateFromAppList(app_list); |
215 | 215 |
216 // Find apps for a "text/plain" file. Foo.app and Bar.app should be found. | 216 // Find apps for a "text/plain" file. Foo.app and Bar.app should be found. |
217 PathAndMimeTypeSet path_mime_set; | 217 PathAndMimeTypeSet path_mime_set; |
218 path_mime_set.insert( | 218 path_mime_set.insert( |
219 std::make_pair( | 219 std::make_pair( |
220 drive::util::GetDriveMountPointPath().AppendASCII("foo.txt"), | 220 drive::util::GetDriveMountPointPath().AppendASCII("foo.txt"), |
221 "text/plain")); | 221 "text/plain")); |
222 std::vector<FullTaskDescriptor> tasks; | 222 std::vector<FullTaskDescriptor> tasks; |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 "text/plain")); | 356 "text/plain")); |
357 | 357 |
358 // The internal file browser handler should be chosen as default, as it's a | 358 // The internal file browser handler should be chosen as default, as it's a |
359 // fallback file browser handler. | 359 // fallback file browser handler. |
360 ChooseAndSetDefaultTask(pref_service, path_mime_set, &tasks); | 360 ChooseAndSetDefaultTask(pref_service, path_mime_set, &tasks); |
361 EXPECT_TRUE(tasks[0].is_default()); | 361 EXPECT_TRUE(tasks[0].is_default()); |
362 } | 362 } |
363 | 363 |
364 } // namespace file_tasks | 364 } // namespace file_tasks |
365 } // namespace file_manager. | 365 } // namespace file_manager. |
OLD | NEW |