Commit 6cf710fa authored by Yoichi Osato's avatar Yoichi Osato Committed by Commit Bot

Revert "WebApps: Implement unregistering file handlers on Linux."

This reverts commit 32a1f8bf.

Reason for revert: LocalNTPJavascriptTest failing on 7 builder(s)
Fixed: 1044497

Original change's description:
> WebApps: Implement unregistering file handlers on Linux.
> 
> This will allow us to disable the file handlers for an app on Linux
> without uninstalling it. This is necessary preparation for the origin
> trial, as we need to be able to disable/enable the file handlers as
> the validity of the app's origin trial changes.
> 
> Bug: 1028448
> Change-Id: I63eb6582852ff75d3d88181ede07f0cbd010df2d
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2010234
> Commit-Queue: Jay Harris <harrisjay@chromium.org>
> Reviewed-by: Alexey Baskakov <loyso@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#733859}

TBR=loyso@chromium.org,harrisjay@chromium.org

Change-Id: I67239e88d48df1d70ff1a432863b3be26d5d7bd4
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 1028448
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2014352Reviewed-by: default avatarYoichi Osato <yoichio@chromium.org>
Commit-Queue: Yoichi Osato <yoichio@chromium.org>
Cr-Commit-Position: refs/heads/master@{#733902}
parent 622b4c1f
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/bind_helpers.h" #include "base/bind_helpers.h"
#include "chrome/browser/web_applications/components/app_registrar.h"
#include "chrome/browser/web_applications/components/app_shortcut_manager.h" #include "chrome/browser/web_applications/components/app_shortcut_manager.h"
#include "chrome/browser/web_applications/components/web_app_provider_base.h" #include "chrome/browser/web_applications/components/web_app_provider_base.h"
#include "chrome/browser/web_applications/components/web_app_shortcut.h" #include "chrome/browser/web_applications/components/web_app_shortcut.h"
...@@ -27,16 +26,6 @@ void OnShortcutInfoReceived(std::unique_ptr<ShortcutInfo> info) { ...@@ -27,16 +26,6 @@ void OnShortcutInfoReceived(std::unique_ptr<ShortcutInfo> info) {
base::DoNothing()); base::DoNothing());
} }
void UpdateFileHandlerRegistrationInOs(const AppId& app_id, Profile* profile) {
// On Linux, file associations are managed through shortcuts in the app menu,
// so after enabling or disabling file handling for an app its shortcuts
// need to be recreated.
AppShortcutManager& shortcut_manager =
WebAppProviderBase::GetProviderBase(profile)->shortcut_manager();
shortcut_manager.GetShortcutInfoForApp(
app_id, base::BindOnce(&OnShortcutInfoReceived));
}
} // namespace } // namespace
bool ShouldRegisterFileHandlersWithOs() { bool ShouldRegisterFileHandlersWithOs() {
...@@ -48,18 +37,14 @@ void RegisterFileHandlersWithOs(const AppId& app_id, ...@@ -48,18 +37,14 @@ void RegisterFileHandlersWithOs(const AppId& app_id,
Profile* profile, Profile* profile,
const std::set<std::string>& file_extensions, const std::set<std::string>& file_extensions,
const std::set<std::string>& mime_types) { const std::set<std::string>& mime_types) {
UpdateFileHandlerRegistrationInOs(app_id, profile); AppShortcutManager& shortcut_manager =
WebAppProviderBase::GetProviderBase(profile)->shortcut_manager();
shortcut_manager.GetShortcutInfoForApp(
app_id, base::BindOnce(OnShortcutInfoReceived));
} }
void UnregisterFileHandlersWithOs(const AppId& app_id, Profile* profile) { void UnregisterFileHandlersWithOs(const AppId& app_id, Profile* profile) {
// If this was triggered as part of the uninstallation process, nothing more // TODO(harrisjay): Add support for unregistering file handlers.
// is needed. Uninstalling already cleans up shortcuts (and thus, file
// handlers).
auto* provider = WebAppProviderBase::GetProviderBase(profile);
if (!provider->registrar().IsInstalled(app_id))
return;
UpdateFileHandlerRegistrationInOs(app_id, profile);
} }
} // namespace web_app } // namespace web_app
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/web_applications/components/file_handler_manager.h" #include "chrome/browser/web_applications/components/file_handler_manager.h"
#include "chrome/browser/web_applications/components/web_app_helpers.h" #include "chrome/browser/web_applications/components/web_app_helpers.h"
#include "chrome/browser/web_applications/components/web_app_provider_base.h"
#include "chrome/common/extensions/manifest_handlers/app_launch_info.h" #include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
...@@ -179,18 +178,11 @@ std::unique_ptr<ShortcutInfo> ShortcutInfoForExtensionAndProfile( ...@@ -179,18 +178,11 @@ std::unique_ptr<ShortcutInfo> ShortcutInfoForExtensionAndProfile(
shortcut_info->profile_name = shortcut_info->profile_name =
profile->GetPrefs()->GetString(prefs::kProfileName); profile->GetPrefs()->GetString(prefs::kProfileName);
shortcut_info->version_for_display = app->GetVersionForDisplay(); shortcut_info->version_for_display = app->GetVersionForDisplay();
if (const auto* info = extensions::FileHandlers::GetFileHandlers(app)) {
// File Handlers should only be included in bookmark apps. shortcut_info->file_handler_extensions =
if (app->from_bookmark()) { web_app::GetFileExtensionsFromFileHandlers(*info);
FileHandlerManager& file_handler_manager = shortcut_info->file_handler_mime_types =
WebAppProviderBase::GetProviderBase(profile)->file_handler_manager(); web_app::GetMimeTypesFromFileHandlers(*info);
if (const auto* file_handlers =
file_handler_manager.GetEnabledFileHandlers(app->id())) {
shortcut_info->file_handler_extensions =
web_app::GetFileExtensionsFromFileHandlers(*file_handlers);
shortcut_info->file_handler_mime_types =
web_app::GetMimeTypesFromFileHandlers(*file_handlers);
}
} }
return shortcut_info; return shortcut_info;
......
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