blob: fd11c930389e10aa8f8657bd4e6b6ca4266c3af0 [file] [log] [blame]
Nigel Tao192c3302018-07-19 15:17:281// Copyright 2018 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#ifndef CHROME_BROWSER_WEB_APPLICATIONS_WEB_APP_PROVIDER_H_
6#define CHROME_BROWSER_WEB_APPLICATIONS_WEB_APP_PROVIDER_H_
7
8#include <memory>
Dominick Ng7b4ad0b82018-08-03 15:29:109#include <vector>
Nigel Tao192c3302018-07-19 15:17:2810
11#include "base/macros.h"
Dominick Ng7b4ad0b82018-08-03 15:29:1012#include "base/memory/weak_ptr.h"
13#include "chrome/browser/web_applications/components/pending_app_manager.h"
Nigel Tao192c3302018-07-19 15:17:2814#include "components/keyed_service/core/keyed_service.h"
Giovanni Ortuño Urquidifd7ed2862018-08-29 13:26:4915#include "content/public/browser/notification_observer.h"
16#include "content/public/browser/notification_registrar.h"
Nigel Tao192c3302018-07-19 15:17:2817
18class Profile;
19
Alexey Baskakov396edb92018-08-02 05:11:4220namespace user_prefs {
21class PrefRegistrySyncable;
22}
23
Nigel Tao192c3302018-07-19 15:17:2824namespace web_app {
25
Giovanni Ortuño Urquidi4f86bf272018-07-31 02:09:0326class PendingAppManager;
Nigel Tao192c3302018-07-19 15:17:2827class WebAppPolicyManager;
Christopher Lam0999fe352018-09-24 05:01:2628class SystemWebAppManager;
Nigel Tao192c3302018-07-19 15:17:2829
30// Connects Web App features, such as the installation of default and
31// policy-managed web apps, with Profiles (as WebAppProvider is a
32// Profile-linked KeyedService) and their associated PrefService.
Giovanni Ortuño Urquidifd7ed2862018-08-29 13:26:4933class WebAppProvider : public KeyedService,
34 public content::NotificationObserver {
Nigel Tao192c3302018-07-19 15:17:2835 public:
36 static WebAppProvider* Get(Profile* profile);
37
Giovanni Ortuño Urquidi8ea2f1e2018-08-06 01:13:0538 explicit WebAppProvider(Profile* profile);
Nigel Tao192c3302018-07-19 15:17:2839
Giovanni Ortuño Urquidi4f86bf272018-07-31 02:09:0340 // Clients can use PendingAppManager to install, uninstall, and update
41 // Web Apps.
42 PendingAppManager& pending_app_manager() { return *pending_app_manager_; }
43
Nigel Tao192c3302018-07-19 15:17:2844 ~WebAppProvider() override;
45
Alexey Baskakov396edb92018-08-02 05:11:4246 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
47
Giovanni Ortuño Urquidifd7ed2862018-08-29 13:26:4948 void Reset();
49
50 // content::NotificationObserver
51 void Observe(int type,
52 const content::NotificationSource& source,
53 const content::NotificationDetails& details) override;
Giovanni Ortuño Urquidi2fb415b02018-08-22 07:18:5154
Nigel Tao192c3302018-07-19 15:17:2855 private:
Dominick Ng4b176fd2018-08-20 16:15:5656 void OnScanForExternalWebApps(
Dominick Ng7b4ad0b82018-08-03 15:29:1057 std::vector<web_app::PendingAppManager::AppInfo>);
58
Giovanni Ortuño Urquidi4f86bf272018-07-31 02:09:0359 std::unique_ptr<PendingAppManager> pending_app_manager_;
Nigel Tao192c3302018-07-19 15:17:2860 std::unique_ptr<WebAppPolicyManager> web_app_policy_manager_;
Christopher Lam0999fe352018-09-24 05:01:2661 std::unique_ptr<SystemWebAppManager> system_web_app_manager_;
Nigel Tao192c3302018-07-19 15:17:2862
Giovanni Ortuño Urquidifd7ed2862018-08-29 13:26:4963 content::NotificationRegistrar registrar_;
64
Dominick Ng7b4ad0b82018-08-03 15:29:1065 base::WeakPtrFactory<WebAppProvider> weak_ptr_factory_{this};
66
Nigel Tao192c3302018-07-19 15:17:2867 DISALLOW_COPY_AND_ASSIGN(WebAppProvider);
68};
69
70} // namespace web_app
71
72#endif // CHROME_BROWSER_WEB_APPLICATIONS_WEB_APP_PROVIDER_H_