Commit a5776f15 authored by mtomasz's avatar mtomasz Committed by Commit bot

[unpacker] Allow only one ZIP handler at once: either the new or the old one.

If the new ZIP unpacker flow is enabled, then it the previous avfs based
logic should be hidden from user. And the other way the same.

TEST=Tested manually with the flag enabled and disabled.
BUG=427778

Review URL: https://codereview.chromium.org/692793002

Cr-Commit-Position: refs/heads/master@{#302265}
parent 0e726250
......@@ -8,6 +8,7 @@
#include <set>
#include "base/bind.h"
#include "base/command_line.h"
#include "base/files/file_util.h"
#include "base/i18n/case_conversion.h"
#include "base/strings/utf_string_conversions.h"
......@@ -22,6 +23,7 @@
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/common/extensions/api/file_browser_handlers/file_browser_handler.h"
#include "chrome/common/extensions/api/file_manager_private.h"
#include "chromeos/chromeos_switches.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/child_process_security_policy.h"
#include "content/public/browser/render_process_host.h"
......@@ -34,6 +36,7 @@
#include "extensions/browser/lazy_background_task_queue.h"
#include "extensions/common/extension_set.h"
#include "extensions/common/manifest_handlers/background_info.h"
#include "extensions/common/url_pattern.h"
#include "net/base/escape.h"
#include "storage/browser/fileapi/file_system_context.h"
#include "storage/browser/fileapi/file_system_url.h"
......@@ -132,8 +135,18 @@ FileBrowserHandlerList FindFileBrowserHandlersForURL(
const FileBrowserHandler* handler = handler_iter->get();
if (!handler->MatchesURL(lowercase_url))
continue;
results.push_back(handler_iter->get());
// Filter out Files app from handling ZIP files via a handler, as it's
// now handled by new ZIP unpacker extension based on File System Provider
// API.
const URLPattern zip_pattern(URLPattern::SCHEME_EXTENSION,
"chrome-extension://*/*.zip");
if (handler->extension_id() == kFileManagerAppId &&
zip_pattern.MatchesURL(selected_file_url) &&
!CommandLine::ForCurrentProcess()->HasSwitch(
chromeos::switches::kDisableNewZIPUnpacker)) {
continue;
}
results.push_back(handler);
}
}
return results;
......
......@@ -26,6 +26,7 @@
#include "chrome/common/extensions/api/file_manager_private.h"
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/pref_names.h"
#include "chromeos/chromeos_switches.h"
#include "extensions/browser/extension_host.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h"
......@@ -391,6 +392,14 @@ void FindFileHandlerTasks(
if (file_handlers.empty())
continue;
// If the new ZIP unpacker is disabled, then hide its handlers, so we don't
// show both the legacy one and the new one in Files app for ZIP files.
if (extension->id() == extension_misc::kZIPUnpackerExtensionId &&
CommandLine::ForCurrentProcess()->HasSwitch(
chromeos::switches::kDisableNewZIPUnpacker)) {
continue;
}
// Only show the first matching handler from each app.
const extensions::FileHandlerInfo* file_handler = file_handlers.front();
std::string task_id = file_tasks::MakeTaskID(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment