| 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_browser_handlers.h" | 5 #include "chrome/browser/chromeos/file_manager/file_browser_handlers.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/command_line.h" |
| 11 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
| 12 #include "base/i18n/case_conversion.h" | 13 #include "base/i18n/case_conversion.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 14 #include "chrome/browser/chromeos/drive/file_system_util.h" | 15 #include "chrome/browser/chromeos/drive/file_system_util.h" |
| 15 #include "chrome/browser/chromeos/file_manager/app_id.h" | 16 #include "chrome/browser/chromeos/file_manager/app_id.h" |
| 16 #include "chrome/browser/chromeos/file_manager/fileapi_util.h" | 17 #include "chrome/browser/chromeos/file_manager/fileapi_util.h" |
| 17 #include "chrome/browser/chromeos/file_manager/open_with_browser.h" | 18 #include "chrome/browser/chromeos/file_manager/open_with_browser.h" |
| 18 #include "chrome/browser/chromeos/fileapi/file_system_backend.h" | 19 #include "chrome/browser/chromeos/fileapi/file_system_backend.h" |
| 19 #include "chrome/browser/extensions/extension_service.h" | 20 #include "chrome/browser/extensions/extension_service.h" |
| 20 #include "chrome/browser/extensions/extension_util.h" | 21 #include "chrome/browser/extensions/extension_util.h" |
| 21 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
| 22 #include "chrome/browser/ui/browser_finder.h" | 23 #include "chrome/browser/ui/browser_finder.h" |
| 23 #include "chrome/common/extensions/api/file_browser_handlers/file_browser_handle
r.h" | 24 #include "chrome/common/extensions/api/file_browser_handlers/file_browser_handle
r.h" |
| 24 #include "chrome/common/extensions/api/file_manager_private.h" | 25 #include "chrome/common/extensions/api/file_manager_private.h" |
| 26 #include "chromeos/chromeos_switches.h" |
| 25 #include "content/public/browser/browser_thread.h" | 27 #include "content/public/browser/browser_thread.h" |
| 26 #include "content/public/browser/child_process_security_policy.h" | 28 #include "content/public/browser/child_process_security_policy.h" |
| 27 #include "content/public/browser/render_process_host.h" | 29 #include "content/public/browser/render_process_host.h" |
| 28 #include "content/public/browser/site_instance.h" | 30 #include "content/public/browser/site_instance.h" |
| 29 #include "content/public/browser/web_contents.h" | 31 #include "content/public/browser/web_contents.h" |
| 30 #include "extensions/browser/event_router.h" | 32 #include "extensions/browser/event_router.h" |
| 31 #include "extensions/browser/extension_host.h" | 33 #include "extensions/browser/extension_host.h" |
| 32 #include "extensions/browser/extension_system.h" | 34 #include "extensions/browser/extension_system.h" |
| 33 #include "extensions/browser/extension_util.h" | 35 #include "extensions/browser/extension_util.h" |
| 34 #include "extensions/browser/lazy_background_task_queue.h" | 36 #include "extensions/browser/lazy_background_task_queue.h" |
| 35 #include "extensions/common/extension_set.h" | 37 #include "extensions/common/extension_set.h" |
| 36 #include "extensions/common/manifest_handlers/background_info.h" | 38 #include "extensions/common/manifest_handlers/background_info.h" |
| 39 #include "extensions/common/url_pattern.h" |
| 37 #include "net/base/escape.h" | 40 #include "net/base/escape.h" |
| 38 #include "storage/browser/fileapi/file_system_context.h" | 41 #include "storage/browser/fileapi/file_system_context.h" |
| 39 #include "storage/browser/fileapi/file_system_url.h" | 42 #include "storage/browser/fileapi/file_system_url.h" |
| 40 #include "storage/common/fileapi/file_system_info.h" | 43 #include "storage/common/fileapi/file_system_info.h" |
| 41 #include "storage/common/fileapi/file_system_util.h" | 44 #include "storage/common/fileapi/file_system_util.h" |
| 42 | 45 |
| 43 using content::BrowserThread; | 46 using content::BrowserThread; |
| 44 using content::ChildProcessSecurityPolicy; | 47 using content::ChildProcessSecurityPolicy; |
| 45 using content::SiteInstance; | 48 using content::SiteInstance; |
| 46 using content::WebContents; | 49 using content::WebContents; |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 FileBrowserHandler::GetHandlers(extension); | 128 FileBrowserHandler::GetHandlers(extension); |
| 126 if (!handler_list) | 129 if (!handler_list) |
| 127 continue; | 130 continue; |
| 128 for (FileBrowserHandler::List::const_iterator handler_iter = | 131 for (FileBrowserHandler::List::const_iterator handler_iter = |
| 129 handler_list->begin(); | 132 handler_list->begin(); |
| 130 handler_iter != handler_list->end(); | 133 handler_iter != handler_list->end(); |
| 131 ++handler_iter) { | 134 ++handler_iter) { |
| 132 const FileBrowserHandler* handler = handler_iter->get(); | 135 const FileBrowserHandler* handler = handler_iter->get(); |
| 133 if (!handler->MatchesURL(lowercase_url)) | 136 if (!handler->MatchesURL(lowercase_url)) |
| 134 continue; | 137 continue; |
| 135 | 138 // Filter out Files app from handling ZIP files via a handler, as it's |
| 136 results.push_back(handler_iter->get()); | 139 // now handled by new ZIP unpacker extension based on File System Provider |
| 140 // API. |
| 141 const URLPattern zip_pattern(URLPattern::SCHEME_EXTENSION, |
| 142 "chrome-extension://*/*.zip"); |
| 143 if (handler->extension_id() == kFileManagerAppId && |
| 144 zip_pattern.MatchesURL(selected_file_url) && |
| 145 !CommandLine::ForCurrentProcess()->HasSwitch( |
| 146 chromeos::switches::kDisableNewZIPUnpacker)) { |
| 147 continue; |
| 148 } |
| 149 results.push_back(handler); |
| 137 } | 150 } |
| 138 } | 151 } |
| 139 return results; | 152 return results; |
| 140 } | 153 } |
| 141 | 154 |
| 142 // This class is used to execute a file browser handler task. Here's how this | 155 // This class is used to execute a file browser handler task. Here's how this |
| 143 // works: | 156 // works: |
| 144 // | 157 // |
| 145 // 1) Open the "external" file system | 158 // 1) Open the "external" file system |
| 146 // 2) Set up permissions for the target files on the external file system. | 159 // 2) Set up permissions for the target files on the external file system. |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 if (common_handlers.empty()) | 530 if (common_handlers.empty()) |
| 518 return FileBrowserHandlerList(); | 531 return FileBrowserHandlerList(); |
| 519 } | 532 } |
| 520 } | 533 } |
| 521 | 534 |
| 522 return common_handlers; | 535 return common_handlers; |
| 523 } | 536 } |
| 524 | 537 |
| 525 } // namespace file_browser_handlers | 538 } // namespace file_browser_handlers |
| 526 } // namespace file_manager | 539 } // namespace file_manager |
| OLD | NEW |