Commit f1e782a1 authored by Jay Harris's avatar Jay Harris Committed by Commit Bot

WebApps: Creates an AppShortcutManager and specific Bookmark and Web subclasses.

This CL is just the boilerplate of creating new classes and wiring them
up to WebAppProvider.

Eventually, the functionality from web_app_extension_shortcut should be
migrated into this class. A WIP CL for beginning this is available here:
https://crrev.com/c/1846422.

The motivation for beginning this now is file handling on Linux, as
registering and unregistering file handlers in the OS is tightly
coupled to shortcut management.

Bug: 860581
Change-Id: I3e28018d6fd6656fccd3c22ed62b9576db43f51c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1847708
Commit-Queue: Jay Harris <harrisjay@chromium.org>
Reviewed-by: default avatarAlexey Baskakov <loyso@chromium.org>
Cr-Commit-Position: refs/heads/master@{#704484}
parent f21ce881
...@@ -43,6 +43,8 @@ source_set("web_applications") { ...@@ -43,6 +43,8 @@ source_set("web_applications") {
"web_app_registrar.h", "web_app_registrar.h",
"web_app_registry_update.cc", "web_app_registry_update.cc",
"web_app_registry_update.h", "web_app_registry_update.h",
"web_app_shortcut_manager.cc",
"web_app_shortcut_manager.h",
"web_app_sync_bridge.cc", "web_app_sync_bridge.cc",
"web_app_sync_bridge.h", "web_app_sync_bridge.h",
"web_app_sync_install_delegate.h", "web_app_sync_install_delegate.h",
......
...@@ -11,6 +11,8 @@ source_set("components") { ...@@ -11,6 +11,8 @@ source_set("components") {
"app_registrar_observer.h", "app_registrar_observer.h",
"app_registry_controller.cc", "app_registry_controller.cc",
"app_registry_controller.h", "app_registry_controller.h",
"app_shortcut_manager.cc",
"app_shortcut_manager.h",
"external_install_options.cc", "external_install_options.cc",
"external_install_options.h", "external_install_options.h",
"externally_installed_web_app_prefs.cc", "externally_installed_web_app_prefs.cc",
......
// 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/app_shortcut_manager.h"
namespace web_app {
AppShortcutManager::AppShortcutManager(Profile* profile) : profile_(profile) {}
AppShortcutManager::~AppShortcutManager() = default;
void AppShortcutManager::SetSubsystems(AppRegistrar* registrar) {
registrar_ = registrar;
}
} // namespace web_app
// 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.
#ifndef CHROME_BROWSER_WEB_APPLICATIONS_COMPONENTS_APP_SHORTCUT_MANAGER_H_
#define CHROME_BROWSER_WEB_APPLICATIONS_COMPONENTS_APP_SHORTCUT_MANAGER_H_
#include "base/macros.h"
class Profile;
namespace web_app {
class AppRegistrar;
// TODO(crbug.com/860581): Migrate functions from
// web_app_extension_shortcut.(h|cc) and
// platform_apps/shortcut_manager.(h|cc) to the AppShortcutManager, so web app
// shortcuts can be managed in an extensions agnostic way.
class AppShortcutManager {
public:
explicit AppShortcutManager(Profile* profile);
virtual ~AppShortcutManager();
void SetSubsystems(AppRegistrar* registrar);
protected:
AppRegistrar* registrar() { return registrar_; }
Profile* profile() { return profile_; }
private:
AppRegistrar* registrar_ = nullptr;
Profile* const profile_;
DISALLOW_COPY_AND_ASSIGN(AppShortcutManager);
};
} // namespace web_app
#endif // CHROME_BROWSER_WEB_APPLICATIONS_COMPONENTS_APP_SHORTCUT_MANAGER_H_
...@@ -20,6 +20,7 @@ class AppRegistrar; ...@@ -20,6 +20,7 @@ class AppRegistrar;
class AppRegistryController; class AppRegistryController;
class FileHandlerManager; class FileHandlerManager;
class AppIconManager; class AppIconManager;
class AppShortcutManager;
class WebAppPolicyManager; class WebAppPolicyManager;
class ManifestUpdateManager; class ManifestUpdateManager;
class WebAppAudioFocusIdMap; class WebAppAudioFocusIdMap;
...@@ -58,6 +59,8 @@ class WebAppProviderBase : public KeyedService { ...@@ -58,6 +59,8 @@ class WebAppProviderBase : public KeyedService {
// Implements fetching of app icons. // Implements fetching of app icons.
virtual AppIconManager& icon_manager() = 0; virtual AppIconManager& icon_manager() = 0;
virtual AppShortcutManager& shortcut_manager() = 0;
DISALLOW_COPY_AND_ASSIGN(WebAppProviderBase); DISALLOW_COPY_AND_ASSIGN(WebAppProviderBase);
}; };
......
...@@ -20,6 +20,8 @@ source_set("extensions") { ...@@ -20,6 +20,8 @@ source_set("extensions") {
"bookmark_app_registrar.h", "bookmark_app_registrar.h",
"bookmark_app_registry_controller.cc", "bookmark_app_registry_controller.cc",
"bookmark_app_registry_controller.h", "bookmark_app_registry_controller.h",
"bookmark_app_shortcut_manager.cc",
"bookmark_app_shortcut_manager.h",
"bookmark_app_util.cc", "bookmark_app_util.cc",
"bookmark_app_util.h", "bookmark_app_util.h",
"web_app_extension_shortcut.cc", "web_app_extension_shortcut.cc",
......
// 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/extensions/bookmark_app_shortcut_manager.h"
namespace extensions {
BookmarkAppShortcutManager::BookmarkAppShortcutManager(Profile* profile)
: web_app::AppShortcutManager(profile) {}
BookmarkAppShortcutManager::~BookmarkAppShortcutManager() = default;
} // namespace extensions
// 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.
#ifndef CHROME_BROWSER_WEB_APPLICATIONS_EXTENSIONS_BOOKMARK_APP_SHORTCUT_MANAGER_H_
#define CHROME_BROWSER_WEB_APPLICATIONS_EXTENSIONS_BOOKMARK_APP_SHORTCUT_MANAGER_H_
#include "base/macros.h"
#include "chrome/browser/web_applications/components/app_shortcut_manager.h"
class Profile;
namespace extensions {
class BookmarkAppShortcutManager : public web_app::AppShortcutManager {
public:
explicit BookmarkAppShortcutManager(Profile* profile);
~BookmarkAppShortcutManager() override;
private:
DISALLOW_COPY_AND_ASSIGN(BookmarkAppShortcutManager);
};
} // namespace extensions
#endif // CHROME_BROWSER_WEB_APPLICATIONS_EXTENSIONS_BOOKMARK_APP_SHORTCUT_MANAGER_H_
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "chrome/browser/web_applications/extensions/bookmark_app_install_finalizer.h" #include "chrome/browser/web_applications/extensions/bookmark_app_install_finalizer.h"
#include "chrome/browser/web_applications/extensions/bookmark_app_registrar.h" #include "chrome/browser/web_applications/extensions/bookmark_app_registrar.h"
#include "chrome/browser/web_applications/extensions/bookmark_app_registry_controller.h" #include "chrome/browser/web_applications/extensions/bookmark_app_registry_controller.h"
#include "chrome/browser/web_applications/extensions/bookmark_app_shortcut_manager.h"
#include "chrome/browser/web_applications/external_web_app_manager.h" #include "chrome/browser/web_applications/external_web_app_manager.h"
#include "chrome/browser/web_applications/file_utils_wrapper.h" #include "chrome/browser/web_applications/file_utils_wrapper.h"
#include "chrome/browser/web_applications/pending_app_manager_impl.h" #include "chrome/browser/web_applications/pending_app_manager_impl.h"
...@@ -32,6 +33,7 @@ ...@@ -32,6 +33,7 @@
#include "chrome/browser/web_applications/web_app_install_manager.h" #include "chrome/browser/web_applications/web_app_install_manager.h"
#include "chrome/browser/web_applications/web_app_provider_factory.h" #include "chrome/browser/web_applications/web_app_provider_factory.h"
#include "chrome/browser/web_applications/web_app_registrar.h" #include "chrome/browser/web_applications/web_app_registrar.h"
#include "chrome/browser/web_applications/web_app_shortcut_manager.h"
#include "chrome/browser/web_applications/web_app_sync_bridge.h" #include "chrome/browser/web_applications/web_app_sync_bridge.h"
#include "chrome/common/chrome_features.h" #include "chrome/common/chrome_features.h"
#include "components/pref_registry/pref_registry_syncable.h" #include "components/pref_registry/pref_registry_syncable.h"
...@@ -133,6 +135,11 @@ AppIconManager& WebAppProvider::icon_manager() { ...@@ -133,6 +135,11 @@ AppIconManager& WebAppProvider::icon_manager() {
return *icon_manager_; return *icon_manager_;
} }
AppShortcutManager& WebAppProvider::shortcut_manager() {
CheckIsConnected();
return *shortcut_manager_;
}
SystemWebAppManager& WebAppProvider::system_web_app_manager() { SystemWebAppManager& WebAppProvider::system_web_app_manager() {
CheckIsConnected(); CheckIsConnected();
return *system_web_app_manager_; return *system_web_app_manager_;
...@@ -182,6 +189,7 @@ void WebAppProvider::CreateWebAppsSubsystems(Profile* profile) { ...@@ -182,6 +189,7 @@ void WebAppProvider::CreateWebAppsSubsystems(Profile* profile) {
install_finalizer_ = std::make_unique<WebAppInstallFinalizer>( install_finalizer_ = std::make_unique<WebAppInstallFinalizer>(
sync_bridge.get(), icon_manager.get()); sync_bridge.get(), icon_manager.get());
file_handler_manager_ = std::make_unique<WebAppFileHandlerManager>(profile); file_handler_manager_ = std::make_unique<WebAppFileHandlerManager>(profile);
shortcut_manager_ = std::make_unique<WebAppShortcutManager>(profile);
// Upcast to unified subsystem types: // Upcast to unified subsystem types:
registrar_ = std::move(registrar); registrar_ = std::move(registrar);
...@@ -198,6 +206,8 @@ void WebAppProvider::CreateBookmarkAppsSubsystems(Profile* profile) { ...@@ -198,6 +206,8 @@ void WebAppProvider::CreateBookmarkAppsSubsystems(Profile* profile) {
std::make_unique<extensions::BookmarkAppInstallFinalizer>(profile); std::make_unique<extensions::BookmarkAppInstallFinalizer>(profile);
file_handler_manager_ = file_handler_manager_ =
std::make_unique<extensions::BookmarkAppFileHandlerManager>(profile); std::make_unique<extensions::BookmarkAppFileHandlerManager>(profile);
shortcut_manager_ =
std::make_unique<extensions::BookmarkAppShortcutManager>(profile);
} }
void WebAppProvider::ConnectSubsystems() { void WebAppProvider::ConnectSubsystems() {
...@@ -214,6 +224,7 @@ void WebAppProvider::ConnectSubsystems() { ...@@ -214,6 +224,7 @@ void WebAppProvider::ConnectSubsystems() {
registrar_.get(), ui_manager_.get()); registrar_.get(), ui_manager_.get());
web_app_policy_manager_->SetSubsystems(pending_app_manager_.get()); web_app_policy_manager_->SetSubsystems(pending_app_manager_.get());
file_handler_manager_->SetSubsystems(registrar_.get()); file_handler_manager_->SetSubsystems(registrar_.get());
shortcut_manager_->SetSubsystems(registrar_.get());
connected_ = true; connected_ = true;
} }
......
...@@ -31,6 +31,7 @@ namespace web_app { ...@@ -31,6 +31,7 @@ namespace web_app {
// Forward declarations of generalized interfaces. // Forward declarations of generalized interfaces.
class AppRegistryController; class AppRegistryController;
class AppIconManager; class AppIconManager;
class AppShortcutManager;
class ExternalWebAppManager; class ExternalWebAppManager;
class FileHandlerManager; class FileHandlerManager;
class InstallFinalizer; class InstallFinalizer;
...@@ -77,6 +78,7 @@ class WebAppProvider : public WebAppProviderBase { ...@@ -77,6 +78,7 @@ class WebAppProvider : public WebAppProviderBase {
WebAppAudioFocusIdMap& audio_focus_id_map() override; WebAppAudioFocusIdMap& audio_focus_id_map() override;
FileHandlerManager& file_handler_manager() override; FileHandlerManager& file_handler_manager() override;
AppIconManager& icon_manager() override; AppIconManager& icon_manager() override;
AppShortcutManager& shortcut_manager() override;
SystemWebAppManager& system_web_app_manager(); SystemWebAppManager& system_web_app_manager();
...@@ -121,6 +123,7 @@ class WebAppProvider : public WebAppProviderBase { ...@@ -121,6 +123,7 @@ class WebAppProvider : public WebAppProviderBase {
std::unique_ptr<InstallFinalizer> install_finalizer_; std::unique_ptr<InstallFinalizer> install_finalizer_;
std::unique_ptr<ManifestUpdateManager> manifest_update_manager_; std::unique_ptr<ManifestUpdateManager> manifest_update_manager_;
std::unique_ptr<PendingAppManager> pending_app_manager_; std::unique_ptr<PendingAppManager> pending_app_manager_;
std::unique_ptr<AppShortcutManager> shortcut_manager_;
std::unique_ptr<SystemWebAppManager> system_web_app_manager_; std::unique_ptr<SystemWebAppManager> system_web_app_manager_;
std::unique_ptr<WebAppAudioFocusIdMap> audio_focus_id_map_; std::unique_ptr<WebAppAudioFocusIdMap> audio_focus_id_map_;
std::unique_ptr<WebAppInstallManager> install_manager_; std::unique_ptr<WebAppInstallManager> install_manager_;
......
// 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/web_app_shortcut_manager.h"
namespace web_app {
WebAppShortcutManager::WebAppShortcutManager(Profile* profile)
: AppShortcutManager(profile) {}
WebAppShortcutManager::~WebAppShortcutManager() = default;
} // namespace web_app
// 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.
#ifndef CHROME_BROWSER_WEB_APPLICATIONS_WEB_APP_SHORTCUT_MANAGER_H_
#define CHROME_BROWSER_WEB_APPLICATIONS_WEB_APP_SHORTCUT_MANAGER_H_
#include "base/macros.h"
#include "chrome/browser/web_applications/components/app_shortcut_manager.h"
class Profile;
namespace web_app {
class WebAppShortcutManager : public AppShortcutManager {
public:
explicit WebAppShortcutManager(Profile* profile);
~WebAppShortcutManager() override;
private:
DISALLOW_COPY_AND_ASSIGN(WebAppShortcutManager);
};
} // namespace web_app
#endif // CHROME_BROWSER_WEB_APPLICATIONS_WEB_APP_SHORTCUT_MANAGER_H_
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