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

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

Issue 2902293002: Introduce lock screen app manager (Closed)
Patch Set: . Created 3 years, 6 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
(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
25 namespace lock_screen_apps {
26
27 // The default implementation of lock_screen_apps::AppManager.
28 class AppManagerImpl : public AppManager,
29 public extensions::ExtensionRegistryObserver {
30 public:
31 AppManagerImpl();
32 ~AppManagerImpl() override;
33
34 // AppManager implementation:
35 void Initialize(Profile* primary_profile,
36 Profile* lock_screen_profile) override;
37 void Start(const base::Closure& note_taking_changed_callback) override;
38 void Stop() override;
39 bool LaunchNoteTaking() override;
40 bool IsNoteTakingAppAvailable() const override;
41 std::string GetNoteTakingAppId() const override;
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
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 };
61
62 // Called when note taking related prefs change.
63 void OnNoteTakingExtensionChanged();
64
65 // Gets the currently enabled lock screen note taking app, is one is selected.
66 // If no such app exists, returns an empty string.
67 std::string FindLockScreenNoteTakingApp() const;
68
69 // Loads and enables the lock screen note taking app to the lock screen
70 // profile.
71 bool AddAppToLockScreenProfile(const std::string& app_id);
72
73 // Unloads lock screen note taking app from the lock screen profile.
74 void UnloadLockApp(const std::string& app_id);
75
76 Profile* primary_profile_ = nullptr;
77 Profile* lock_screen_profile_ = nullptr;
78
79 State state_ = State::kNotInitialized;
80 std::string lock_screen_app_id_;
81
82 PrefChangeRegistrar pref_change_registrar_;
83 ScopedObserver<extensions::ExtensionRegistry,
84 extensions::ExtensionRegistryObserver>
85 extensions_observer_;
86
87 base::Closure note_taking_changed_callback_;
88
89 DISALLOW_COPY_AND_ASSIGN(AppManagerImpl);
90 };
91
92 } // namespace lock_screen_apps
93
94 #endif // CHROME_BROWSER_CHROMEOS_LOCK_SCREEN_APPS_APP_MANAGER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698