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/file_manager/file_tasks.h" | 5 #include "chrome/browser/chromeos/file_manager/file_tasks.h" |
6 | 6 |
7 #include "apps/launcher.h" | 7 #include "apps/launcher.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "base/prefs/scoped_user_pref_update.h" | 10 #include "base/prefs/scoped_user_pref_update.h" |
11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
12 #include "chrome/browser/chromeos/drive/file_system_util.h" | 12 #include "chrome/browser/chromeos/drive/file_system_util.h" |
13 #include "chrome/browser/chromeos/drive/file_task_executor.h" | 13 #include "chrome/browser/chromeos/drive/file_task_executor.h" |
14 #include "chrome/browser/chromeos/file_manager/app_id.h" | 14 #include "chrome/browser/chromeos/file_manager/app_id.h" |
15 #include "chrome/browser/chromeos/file_manager/file_browser_handlers.h" | 15 #include "chrome/browser/chromeos/file_manager/file_browser_handlers.h" |
16 #include "chrome/browser/chromeos/file_manager/fileapi_util.h" | 16 #include "chrome/browser/chromeos/file_manager/fileapi_util.h" |
17 #include "chrome/browser/chromeos/file_manager/open_util.h" | 17 #include "chrome/browser/chromeos/file_manager/open_util.h" |
18 #include "chrome/browser/drive/drive_api_util.h" | 18 #include "chrome/browser/drive/drive_api_util.h" |
19 #include "chrome/browser/drive/drive_app_registry.h" | 19 #include "chrome/browser/drive/drive_app_registry.h" |
20 #include "chrome/browser/extensions/extension_tab_util.h" | 20 #include "chrome/browser/extensions/extension_tab_util.h" |
21 #include "chrome/browser/extensions/extension_util.h" | 21 #include "chrome/browser/extensions/extension_util.h" |
22 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
23 #include "chrome/browser/ui/extensions/application_launch.h" | 23 #include "chrome/browser/ui/extensions/application_launch.h" |
24 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" | 24 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" |
25 #include "chrome/common/extensions/api/file_browser_handlers/file_browser_handle
r.h" | 25 #include "chrome/common/extensions/api/file_browser_handlers/file_browser_handle
r.h" |
26 #include "chrome/common/extensions/api/file_manager_private.h" | 26 #include "chrome/common/extensions/api/file_manager_private.h" |
27 #include "chrome/common/extensions/extension_constants.h" | 27 #include "chrome/common/extensions/extension_constants.h" |
28 #include "chrome/common/pref_names.h" | 28 #include "chrome/common/pref_names.h" |
| 29 #include "chromeos/chromeos_switches.h" |
29 #include "extensions/browser/extension_host.h" | 30 #include "extensions/browser/extension_host.h" |
30 #include "extensions/browser/extension_registry.h" | 31 #include "extensions/browser/extension_registry.h" |
31 #include "extensions/browser/extension_system.h" | 32 #include "extensions/browser/extension_system.h" |
32 #include "extensions/browser/extension_util.h" | 33 #include "extensions/browser/extension_util.h" |
33 #include "extensions/common/constants.h" | 34 #include "extensions/common/constants.h" |
34 #include "extensions/common/extension_set.h" | 35 #include "extensions/common/extension_set.h" |
35 #include "storage/browser/fileapi/file_system_url.h" | 36 #include "storage/browser/fileapi/file_system_url.h" |
36 | 37 |
37 using extensions::Extension; | 38 using extensions::Extension; |
38 using extensions::app_file_handler_util::FindFileHandlersForFiles; | 39 using extensions::app_file_handler_util::FindFileHandlersForFiles; |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 if (profile->IsOffTheRecord() && | 385 if (profile->IsOffTheRecord() && |
385 !extensions::util::IsIncognitoEnabled(extension->id(), profile)) | 386 !extensions::util::IsIncognitoEnabled(extension->id(), profile)) |
386 continue; | 387 continue; |
387 | 388 |
388 typedef std::vector<const extensions::FileHandlerInfo*> FileHandlerList; | 389 typedef std::vector<const extensions::FileHandlerInfo*> FileHandlerList; |
389 FileHandlerList file_handlers = | 390 FileHandlerList file_handlers = |
390 FindFileHandlersForFiles(*extension, path_mime_set); | 391 FindFileHandlersForFiles(*extension, path_mime_set); |
391 if (file_handlers.empty()) | 392 if (file_handlers.empty()) |
392 continue; | 393 continue; |
393 | 394 |
| 395 // If the new ZIP unpacker is disabled, then hide its handlers, so we don't |
| 396 // show both the legacy one and the new one in Files app for ZIP files. |
| 397 if (extension->id() == extension_misc::kZIPUnpackerExtensionId && |
| 398 CommandLine::ForCurrentProcess()->HasSwitch( |
| 399 chromeos::switches::kDisableNewZIPUnpacker)) { |
| 400 continue; |
| 401 } |
| 402 |
394 // Only show the first matching handler from each app. | 403 // Only show the first matching handler from each app. |
395 const extensions::FileHandlerInfo* file_handler = file_handlers.front(); | 404 const extensions::FileHandlerInfo* file_handler = file_handlers.front(); |
396 std::string task_id = file_tasks::MakeTaskID( | 405 std::string task_id = file_tasks::MakeTaskID( |
397 extension->id(), file_tasks::TASK_TYPE_FILE_HANDLER, file_handler->id); | 406 extension->id(), file_tasks::TASK_TYPE_FILE_HANDLER, file_handler->id); |
398 | 407 |
399 GURL best_icon = extensions::ExtensionIconSource::GetIconURL( | 408 GURL best_icon = extensions::ExtensionIconSource::GetIconURL( |
400 extension, | 409 extension, |
401 drive::util::kPreferredIconSize, | 410 drive::util::kPreferredIconSize, |
402 ExtensionIconSet::MATCH_BIGGER, | 411 ExtensionIconSet::MATCH_BIGGER, |
403 false, // grayscale | 412 false, // grayscale |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 DCHECK(!task->is_default()); | 527 DCHECK(!task->is_default()); |
519 if (IsFallbackFileHandler(task->task_descriptor())) { | 528 if (IsFallbackFileHandler(task->task_descriptor())) { |
520 task->set_is_default(true); | 529 task->set_is_default(true); |
521 return; | 530 return; |
522 } | 531 } |
523 } | 532 } |
524 } | 533 } |
525 | 534 |
526 } // namespace file_tasks | 535 } // namespace file_tasks |
527 } // namespace file_manager | 536 } // namespace file_manager |
OLD | NEW |