1 // Copyright 2020 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include <utility>
6 
7 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/web_applications/extensions/bookmark_app_file_handler_manager.h"
9 #include "chrome/browser/web_applications/extensions/bookmark_app_icon_manager.h"
10 #include "chrome/browser/web_applications/extensions/bookmark_app_install_finalizer.h"
11 #include "chrome/browser/web_applications/extensions/bookmark_app_registrar.h"
12 #include "chrome/browser/web_applications/extensions/bookmark_app_registry_controller.h"
13 #include "chrome/browser/web_applications/extensions/bookmark_app_shortcut_manager.h"
14 #include "chrome/browser/web_applications/web_app_provider.h"
15 #include "chrome/browser/web_applications/web_app_provider_factory.h"
16 #include "extensions/browser/extension_system_provider.h"
17 #include "extensions/browser/extensions_browser_client.h"
18 
19 namespace web_app {
20 
CreateBookmarkAppsSubsystems(Profile * profile)21 void WebAppProvider::CreateBookmarkAppsSubsystems(Profile* profile) {
22   std::unique_ptr<extensions::BookmarkAppRegistrar> registrar =
23       std::make_unique<extensions::BookmarkAppRegistrar>(profile);
24   std::unique_ptr<extensions::BookmarkAppRegistryController>
25       registry_controller =
26           std::make_unique<extensions::BookmarkAppRegistryController>(
27               profile, registrar.get());
28   icon_manager_ = std::make_unique<extensions::BookmarkAppIconManager>(profile);
29   install_finalizer_ =
30       std::make_unique<extensions::BookmarkAppInstallFinalizer>(profile);
31 
32   auto file_handler_manager =
33       std::make_unique<extensions::BookmarkAppFileHandlerManager>(profile);
34   auto shortcut_manager =
35       std::make_unique<extensions::BookmarkAppShortcutManager>(profile);
36   os_integration_manager_ = std::make_unique<OsIntegrationManager>(
37       profile, std::move(shortcut_manager), std::move(file_handler_manager));
38 
39   // Upcast to unified subsystem types:
40   registrar_ = std::move(registrar);
41   registry_controller_ = std::move(registry_controller);
42 }
43 
44 std::unique_ptr<InstallFinalizer>
CreateBookmarkAppInstallFinalizer(Profile * profile)45 WebAppProvider::CreateBookmarkAppInstallFinalizer(Profile* profile) {
46   return std::make_unique<extensions::BookmarkAppInstallFinalizer>(profile);
47 }
48 
DependsOnExtensionsSystem()49 void WebAppProviderFactory::DependsOnExtensionsSystem() {
50   DependsOn(
51       extensions::ExtensionsBrowserClient::Get()->GetExtensionSystemFactory());
52 }
53 
54 }  // namespace web_app
55