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

Unified Diff: chrome/browser/chromeos/lock_screen_apps/app_manager_impl.h

Issue 2902293002: Introduce lock screen app manager (Closed)
Patch Set: . Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/lock_screen_apps/app_manager_impl.h
diff --git a/chrome/browser/chromeos/lock_screen_apps/app_manager_impl.h b/chrome/browser/chromeos/lock_screen_apps/app_manager_impl.h
new file mode 100644
index 0000000000000000000000000000000000000000..91312c61b082db435433d1a5c4ae36824340ecfd
--- /dev/null
+++ b/chrome/browser/chromeos/lock_screen_apps/app_manager_impl.h
@@ -0,0 +1,93 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_CHROMEOS_LOCK_SCREEN_APPS_APP_MANAGER_IMPL_H_
+#define CHROME_BROWSER_CHROMEOS_LOCK_SCREEN_APPS_APP_MANAGER_IMPL_H_
+
+#include <string>
+
+#include "base/callback.h"
+#include "base/macros.h"
+#include "base/observer_list.h"
+#include "base/scoped_observer.h"
+#include "chrome/browser/chromeos/lock_screen_apps/app_manager.h"
+#include "components/prefs/pref_change_registrar.h"
+#include "extensions/browser/extension_registry_observer.h"
+
+class Profile;
+
+namespace extensions {
+class Extension;
+class ExtensionRegistry;
+}
+namespace lock_screen_apps {
xiyuan 2017/05/26 22:44:52 nit: insert an empty line
tbarzic 2017/05/27 00:48:35 Done.
+
+// The default implementation of lock_screen_apps::AppManager.
+class AppManagerImpl : public AppManager,
+ public extensions::ExtensionRegistryObserver {
+ public:
+ AppManagerImpl();
+ ~AppManagerImpl() override;
+
+ // AppManager implementation:
+ void Initialize(Profile* primary_profile,
+ Profile* lock_screen_profile) override;
+ void Start(AppManager::Observer* observer) override;
+ void Stop() override;
+ bool LaunchNoteTaking() override;
+ bool IsNoteTakingAppAvailable() const override;
+ std::string GetNoteTakingAppId() const override;
+
+ // extensions::ExtensionRegistryObserver implementation:
+ void OnExtensionLoaded(content::BrowserContext* browser_context,
+ const extensions::Extension* extension) override;
+ void OnExtensionUnloaded(content::BrowserContext* browser_context,
+ const extensions::Extension* extension,
+ extensions::UnloadedExtensionReason reason) override;
+
+ private:
+ enum class State {
+ // The manager has not yet been initialized.
+ kNotInitialized,
+ // The manager is initialized, but not started. The note taking app is
+ // considered unset at this point, and cannot be launched.
+ kInactive,
+ // The manager is started. Lock screen note taking app, if set, is loaded
+ // and ready to be launched.
+ kActive,
+ };
+
+ // Called when note taking related prefs change.
+ void OnNoteTakingExtensionChanged();
+
+ // Gets the currently enabled lock screen note taking app, is one is selected.
+ // If no such app exists, returns an empty string.
+ std::string FindLockScreenNoteTakingApp() const;
+
+ // Loads and enables the lock screen note taking app to the lock screen
+ // profile.
+ bool AddAppToLockScreenProfile(const std::string& app_id);
+
+ // Unloads lock screen note taking app from the lock screen profile.
+ void UnloadLockApp(const std::string& app_id);
+
+ Profile* primary_profile_ = nullptr;
+ Profile* lock_screen_profile_ = nullptr;
+
+ State state_ = State::kNotInitialized;
+ std::string lock_screen_app_id_;
+
+ PrefChangeRegistrar pref_change_registrar_;
+ ScopedObserver<extensions::ExtensionRegistry,
+ extensions::ExtensionRegistryObserver>
+ extensions_observer_;
+
+ AppManager::Observer* observer_ = nullptr;
+
+ DISALLOW_COPY_AND_ASSIGN(AppManagerImpl);
+};
+
+} // namespace lock_screen_apps
+
+#endif // CHROME_BROWSER_CHROMEOS_LOCK_SCREEN_APPS_APP_MANAGER_IMPL_H_

Powered by Google App Engine
This is Rietveld 408576698