Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(284)

Side by Side Diff: chrome/browser/chromeos/lock_screen_apps/app_manager_impl.h

Issue 2902293002: Introduce lock screen app manager (Closed)
Patch Set: rebase Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_CHROMEOS_LOCK_SCREEN_APPS_APP_MANAGER_IMPL_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_LOCK_SCREEN_APPS_APP_MANAGER_IMPL_H_
6 #define CHROME_BROWSER_CHROMEOS_LOCK_SCREEN_APPS_APP_MANAGER_IMPL_H_ 6 #define CHROME_BROWSER_CHROMEOS_LOCK_SCREEN_APPS_APP_MANAGER_IMPL_H_
7 7
8 #include <string>
9
8 #include "base/callback.h" 10 #include "base/callback.h"
9 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/weak_ptr.h"
13 #include "base/scoped_observer.h"
10 #include "chrome/browser/chromeos/lock_screen_apps/app_manager.h" 14 #include "chrome/browser/chromeos/lock_screen_apps/app_manager.h"
15 #include "components/prefs/pref_change_registrar.h"
16 #include "extensions/browser/extension_registry_observer.h"
11 17
12 class Profile; 18 class Profile;
13 19
20 namespace extensions {
21 class Extension;
22 class ExtensionRegistry;
23 } // namespace extensions
24
14 namespace lock_screen_apps { 25 namespace lock_screen_apps {
15 26
16 // The default implementation of lock_screen_apps::AppManager. 27 // The default implementation of lock_screen_apps::AppManager.
17 class AppManagerImpl : public AppManager { 28 class AppManagerImpl : public AppManager,
29 public extensions::ExtensionRegistryObserver {
18 public: 30 public:
19 AppManagerImpl(); 31 AppManagerImpl();
20 ~AppManagerImpl() override; 32 ~AppManagerImpl() override;
21 33
22 // AppManager implementation: 34 // AppManager implementation:
23 void Initialize(Profile* primary_profile, 35 void Initialize(Profile* primary_profile,
24 Profile* lock_screen_profile) override; 36 Profile* lock_screen_profile) override;
25 void Start(const base::Closure& note_taking_changed_callback) override; 37 void Start(const base::Closure& note_taking_changed_callback) override;
26 void Stop() override; 38 void Stop() override;
27 bool LaunchNoteTaking() override; 39 bool LaunchNoteTaking() override;
28 bool IsNoteTakingAppAvailable() const override; 40 bool IsNoteTakingAppAvailable() const override;
29 std::string GetNoteTakingAppId() const override; 41 std::string GetNoteTakingAppId() const override;
30 42
43 // extensions::ExtensionRegistryObserver implementation:
44 void OnExtensionLoaded(content::BrowserContext* browser_context,
45 const extensions::Extension* extension) override;
46 void OnExtensionUnloaded(content::BrowserContext* browser_context,
47 const extensions::Extension* extension,
48 extensions::UnloadedExtensionReason reason) override;
49
31 private: 50 private:
51 enum class State {
52 // The manager has not yet been initialized.
53 kNotInitialized,
54 // The manager is initialized, but not started. The note taking app is
55 // considered unset at this point, and cannot be launched.
56 kInactive,
57 // The manager is started. Lock screen note taking app, if set, is loaded
58 // and ready to be launched.
59 kActive,
60 // The manager is started, but app is still being installed into the lock
61 // screen apps profile.
62 kActivating,
63 // The manager is started, and there is no available lock screen enabled
64 // app.
65 kAppUnavailable,
66 };
67
68 // Called on UI thread when the lock screen app profile is initialized with
69 // lock screen app assets. It completes the app installation to the lock
70 // screen app profile.
71 // |app| - the installing app. Cann be nullptr in case the app assets
72 // installation failed.
73 void CompleteLockScreenAppInstall(
74 int install_id,
75 const scoped_refptr<const extensions::Extension>& app);
76
77 // Installs app to the lock screen profile's extension service and enables
78 // the app.
79 void InstallAndEnableLockScreenAppInLockScreenProfile(
80 const extensions::Extension* app);
81
82 // Called when note taking related prefs change.
83 void OnNoteTakingExtensionChanged();
84
85 // Gets the currently enabled lock screen note taking app, is one is selected.
86 // If no such app exists, returns an empty string.
87 std::string FindLockScreenNoteTakingApp() const;
88
89 // Starts installing the lock screen note taking app to the lock screen
90 // profile.
91 // Returns the state to which the app manager should move as a result of this
92 // method.
93 State AddAppToLockScreenProfile(const std::string& app_id);
94
95 // Uninstalls lock screen note taking app from the lock screen profile.
96 void RemoveAppFromLockScreenProfile(const std::string& app_id);
97
32 Profile* primary_profile_ = nullptr; 98 Profile* primary_profile_ = nullptr;
33 Profile* lock_screen_profile_ = nullptr; 99 Profile* lock_screen_profile_ = nullptr;
34 100
101 State state_ = State::kNotInitialized;
102 std::string lock_screen_app_id_;
103
104 PrefChangeRegistrar pref_change_registrar_;
105 ScopedObserver<extensions::ExtensionRegistry,
106 extensions::ExtensionRegistryObserver>
107 extensions_observer_;
108
35 base::Closure note_taking_changed_callback_; 109 base::Closure note_taking_changed_callback_;
36 110
111 // Counts app installs. Passed to app install callback as install request
112 // identifier to determine whether the completed install is stale.
113 int install_count_ = 0;
114
115 base::WeakPtrFactory<AppManagerImpl> weak_ptr_factory_;
116
37 DISALLOW_COPY_AND_ASSIGN(AppManagerImpl); 117 DISALLOW_COPY_AND_ASSIGN(AppManagerImpl);
38 }; 118 };
39 119
40 } // namespace lock_screen_apps 120 } // namespace lock_screen_apps
41 121
42 #endif // CHROME_BROWSER_CHROMEOS_LOCK_SCREEN_APPS_APP_MANAGER_IMPL_H_ 122 #endif // CHROME_BROWSER_CHROMEOS_LOCK_SCREEN_APPS_APP_MANAGER_IMPL_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/BUILD.gn ('k') | chrome/browser/chromeos/lock_screen_apps/app_manager_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698