Commit deda8fa5 authored by David Bienvenu's avatar David Bienvenu Committed by Commit Bot

desktop-pwas: Make FileHandlerManager observe AppRegistrar.

This is the first step in registering Windows file associations
for web apps, when a web app is installed whose manifest specifies
that it can handle specific file extensions.

Bug: 960245
Change-Id: I8a2c8932cb69af5caf7c79f11f7881fad0687b3f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1788117Reviewed-by: default avatarAlexey Baskakov <loyso@chromium.org>
Commit-Queue: David Bienvenu <davidbienvenu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#695123}
parent 309656ca
......@@ -13,6 +13,7 @@ source_set("components") {
"external_install_options.h",
"externally_installed_web_app_prefs.cc",
"externally_installed_web_app_prefs.h",
"file_handler_manager.cc",
"file_handler_manager.h",
"install_bounce_metric.cc",
"install_bounce_metric.h",
......
// 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/file_handler_manager.h"
namespace web_app {
FileHandlerManager::FileHandlerManager(Profile* profile)
: profile_(profile), registrar_observer_(this) {}
FileHandlerManager::~FileHandlerManager() = default;
void FileHandlerManager::SetSubsystems(AppRegistrar* registrar) {
registrar_ = registrar;
registrar_observer_.Add(registrar);
}
void FileHandlerManager::OnWebAppInstalled(const AppId& installed_app_id) {
// TODO(davidbienvenu): Hook up with file association registration code on
// windows.
}
void FileHandlerManager::OnWebAppUninstalled(const AppId& installed_app_id) {
// TODO(davidbienvenu): Hook up to file association de-registration code on
// windows.
}
void FileHandlerManager::OnAppRegistrarDestroyed() {
registrar_observer_.RemoveAll();
}
} // namespace web_app
......@@ -8,6 +8,9 @@
#include <vector>
#include "base/macros.h"
#include "base/scoped_observer.h"
#include "chrome/browser/web_applications/components/app_registrar.h"
#include "chrome/browser/web_applications/components/app_registrar_observer.h"
#include "chrome/browser/web_applications/components/web_app_helpers.h"
#include "components/services/app_service/public/cpp/file_handler_info.h"
......@@ -15,10 +18,13 @@ class Profile;
namespace web_app {
class FileHandlerManager {
class FileHandlerManager : public AppRegistrarObserver {
public:
explicit FileHandlerManager(Profile* profile) : profile_(profile) {}
virtual ~FileHandlerManager() = default;
explicit FileHandlerManager(Profile* profile);
~FileHandlerManager() override;
// |registrar| is used to observe OnWebAppInstalled/Uninstalled events.
void SetSubsystems(AppRegistrar* registrar);
// Gets all file handlers for |app_id|. |nullptr| if the app has no file
// handlers.
......@@ -31,6 +37,14 @@ class FileHandlerManager {
private:
Profile* const profile_;
AppRegistrar* registrar_ = nullptr;
// AppRegistrarObserver:
void OnWebAppInstalled(const AppId& app_id) override;
void OnWebAppUninstalled(const AppId& app_id) override;
void OnAppRegistrarDestroyed() override;
ScopedObserver<AppRegistrar, AppRegistrarObserver> registrar_observer_;
DISALLOW_COPY_AND_ASSIGN(FileHandlerManager);
};
......
......@@ -190,6 +190,7 @@ void WebAppProvider::ConnectSubsystems() {
system_web_app_manager_->SetSubsystems(pending_app_manager_.get(),
registrar_.get(), ui_manager_.get());
web_app_policy_manager_->SetSubsystems(pending_app_manager_.get());
file_handler_manager_->SetSubsystems(registrar_.get());
connected_ = true;
}
......
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