OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_CHROMEOS_LOCK_SCREEN_APPS_APP_MANAGER_IMPL_H_ | |
6 #define CHROME_BROWSER_CHROMEOS_LOCK_SCREEN_APPS_APP_MANAGER_IMPL_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "base/callback.h" | |
11 #include "base/macros.h" | |
12 #include "base/observer_list.h" | |
13 #include "base/scoped_observer.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" | |
17 | |
18 class Profile; | |
19 | |
20 namespace extensions { | |
21 class Extension; | |
22 class ExtensionRegistry; | |
23 } | |
24 namespace lock_screen_apps { | |
25 | |
26 // The default implementation of lock_screen_apps::AppManager. | |
27 class AppManagerImpl : public AppManager, | |
28 public extensions::ExtensionRegistryObserver { | |
29 public: | |
30 AppManagerImpl(); | |
31 ~AppManagerImpl() override; | |
32 | |
33 // AppManager implementation: | |
34 void Initialize(Profile* primary_profile, | |
35 Profile* lock_screen_profile) override; | |
36 void Start(AppManager::Observer* observer) override; | |
37 void Stop() override; | |
38 bool LaunchNoteTaking() override; | |
39 bool IsNoteTakingAppAvailable() const override; | |
40 std::string GetNoteTakingAppId() const override; | |
41 | |
42 // extensions::ExtensionRegistryObserver implementation: | |
43 void OnExtensionLoaded(content::BrowserContext* browser_context, | |
44 const extensions::Extension* extension) override; | |
45 void OnExtensionUnloaded(content::BrowserContext* browser_context, | |
46 const extensions::Extension* extension, | |
47 extensions::UnloadedExtensionReason reason) override; | |
48 | |
49 private: | |
50 enum class State { | |
51 // The manager has not yet been initialized. | |
52 kNotInitialized, | |
53 // The manager is initialized, but not started. The note taking app is | |
54 // considered unset at this point, and cannot be launched. | |
55 kIdle, | |
jdufault
2017/05/26 19:15:53
kInitializing?
Idle implies that this class activ
tbarzic
2017/05/26 19:34:14
Changed name to kInactive
| |
56 // The manager is started. Lock screen note taking app, if set, is loaded | |
57 // and ready to be launched. | |
58 kStarted, | |
59 }; | |
60 | |
61 // Called when note taking related prefs change. | |
62 void OnNoteTakingExtensionChanged(); | |
63 | |
64 // Gets the currently enabled lock screen note taking app, is one is selected. | |
65 // If no such app exists, returns an empty string. | |
66 std::string FindLockScreenNoteTakingApp() const; | |
67 | |
68 // Loads and enables the lock screen note taking app to the lock screen | |
69 // profile. | |
70 bool AddAppToLockScreenProfile(const std::string& app_id); | |
71 | |
72 // Unloads lock screen note taking app from the lock screen profile. | |
73 void UnloadLockApp(const std::string& app_id); | |
74 | |
75 Profile* primary_profile_ = nullptr; | |
76 Profile* lock_screen_profile_ = nullptr; | |
77 | |
78 State state_ = State::kNotInitialized; | |
79 std::string lock_screen_app_id_; | |
80 | |
81 PrefChangeRegistrar pref_change_registrar_; | |
82 ScopedObserver<extensions::ExtensionRegistry, | |
83 extensions::ExtensionRegistryObserver> | |
84 extensions_observer_; | |
85 | |
86 AppManager::Observer* observer_ = nullptr; | |
87 | |
88 DISALLOW_COPY_AND_ASSIGN(AppManagerImpl); | |
89 }; | |
90 | |
91 } // namespace lock_screen_apps | |
92 | |
93 #endif // CHROME_BROWSER_CHROMEOS_LOCK_SCREEN_APPS_APP_MANAGER_IMPL_H_ | |
OLD | NEW |