Commit 6c2095e2 authored by David Bienvenu's avatar David Bienvenu Committed by Commit Bot

desktop-pwas: Add OsSupportsWebAppFileHandling() method, remove #ifdef OS_WIN

Bug: 960245
Change-Id: Ia1309ec99b1518aa7371fa24130c71662eb332cc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1823725
Commit-Queue: David Bienvenu <davidbienvenu@chromium.org>
Reviewed-by: default avatarAlexey Baskakov <loyso@chromium.org>
Cr-Commit-Position: refs/heads/master@{#700432}
parent 9891134c
...@@ -39,6 +39,7 @@ source_set("components") { ...@@ -39,6 +39,7 @@ source_set("components") {
"web_app_constants.h", "web_app_constants.h",
"web_app_data_retriever.cc", "web_app_data_retriever.cc",
"web_app_data_retriever.h", "web_app_data_retriever.h",
"web_app_file_extension_registration.cc",
"web_app_file_extension_registration.h", "web_app_file_extension_registration.h",
"web_app_file_extension_registration_win.cc", "web_app_file_extension_registration_win.cc",
"web_app_helpers.cc", "web_app_helpers.cc",
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
#include "chrome/browser/web_applications/components/file_handler_manager.h" #include "chrome/browser/web_applications/components/file_handler_manager.h"
#include "base/feature_list.h" #include "base/feature_list.h"
#include "build/build_config.h"
#include "chrome/browser/web_applications/components/web_app_file_extension_registration.h" #include "chrome/browser/web_applications/components/web_app_file_extension_registration.h"
#include "third_party/blink/public/common/features.h" #include "third_party/blink/public/common/features.h"
...@@ -22,8 +21,8 @@ void FileHandlerManager::SetSubsystems(AppRegistrar* registrar) { ...@@ -22,8 +21,8 @@ void FileHandlerManager::SetSubsystems(AppRegistrar* registrar) {
} }
void FileHandlerManager::OnWebAppInstalled(const AppId& installed_app_id) { void FileHandlerManager::OnWebAppInstalled(const AppId& installed_app_id) {
#if defined(OS_WIN) if (!base::FeatureList::IsEnabled(blink::features::kFileHandlingAPI) ||
if (!base::FeatureList::IsEnabled(blink::features::kFileHandlingAPI)) !OsSupportsWebAppFileHandling())
return; return;
std::string app_name = registrar_->GetAppShortName(installed_app_id); std::string app_name = registrar_->GetAppShortName(installed_app_id);
const std::vector<apps::FileHandlerInfo>* file_handlers = const std::vector<apps::FileHandlerInfo>* file_handlers =
...@@ -34,13 +33,13 @@ void FileHandlerManager::OnWebAppInstalled(const AppId& installed_app_id) { ...@@ -34,13 +33,13 @@ void FileHandlerManager::OnWebAppInstalled(const AppId& installed_app_id) {
GetFileExtensionsFromFileHandlers(*file_handlers); GetFileExtensionsFromFileHandlers(*file_handlers);
RegisterFileHandlersForWebApp(installed_app_id, app_name, *profile_, RegisterFileHandlersForWebApp(installed_app_id, app_name, *profile_,
file_extensions); file_extensions);
#endif // OS_WIN
} }
void FileHandlerManager::OnWebAppUninstalled(const AppId& installed_app_id) { void FileHandlerManager::OnWebAppUninstalled(const AppId& installed_app_id) {
#if defined(OS_WIN) if (base::FeatureList::IsEnabled(blink::features::kFileHandlingAPI) &&
UnregisterFileHandlersForWebApp(installed_app_id, *profile_); OsSupportsWebAppFileHandling()) {
#endif // OS_WIN UnregisterFileHandlersForWebApp(installed_app_id, *profile_);
}
} }
void FileHandlerManager::OnAppRegistrarDestroyed() { void FileHandlerManager::OnAppRegistrarDestroyed() {
......
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/web_applications/components/web_app_file_extension_registration.h"
#include "base/logging.h"
#include "build/build_config.h"
namespace web_app {
#if !defined(OS_WIN)
bool OsSupportsWebAppFileHandling() {
return false;
}
void RegisterFileHandlersForWebApp(
const AppId& app_id,
const std::string& app_name,
const Profile& profile,
const std::set<std::string>& file_extensions) {
DCHECK(OsSupportsWebAppFileHandling());
// Stub function for OS's that don't support Web App file handling yet.
}
void UnregisterFileHandlersForWebApp(const AppId& app_id,
const Profile& profile) {
DCHECK(OsSupportsWebAppFileHandling());
// Stub function for OS's that don't support Web App file handling yet.
}
#endif
} // namespace web_app
...@@ -14,6 +14,9 @@ class Profile; ...@@ -14,6 +14,9 @@ class Profile;
namespace web_app { namespace web_app {
// returns true if Chrome supports WebApp File Handling on this OS.
bool OsSupportsWebAppFileHandling();
// Do OS-specific registration to handle opening files with the specified // Do OS-specific registration to handle opening files with the specified
// |file_extensions| with the PWA with the specified |app_id|. // |file_extensions| with the PWA with the specified |app_id|.
// This may also involve creating a shim app to launch Chrome from. // This may also involve creating a shim app to launch Chrome from.
......
...@@ -8,6 +8,10 @@ ...@@ -8,6 +8,10 @@
namespace web_app { namespace web_app {
bool OsSupportsWebAppFileHandling() {
return true;
}
void RegisterFileHandlersForWebApp( void RegisterFileHandlersForWebApp(
const AppId& app_id, const AppId& app_id,
const std::string& app_name, const std::string& app_name,
......
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