Chromium Code Reviews| Index: chrome/browser/chromeos/arc/arc_play_store_enabled_preference_handler.h |
| diff --git a/chrome/browser/chromeos/arc/arc_play_store_enabled_preference_handler.h b/chrome/browser/chromeos/arc/arc_play_store_enabled_preference_handler.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..776ead6fd523260bd7ee7431d7be22599667a7b9 |
| --- /dev/null |
| +++ b/chrome/browser/chromeos/arc/arc_play_store_enabled_preference_handler.h |
| @@ -0,0 +1,59 @@ |
| +// 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_ARC_ARC_PLAY_STORE_ENABLED_PREFERENCE_HANDLER_H_ |
| +#define CHROME_BROWSER_CHROMEOS_ARC_ARC_PLAY_STORE_ENABLED_PREFERENCE_HANDLER_H_ |
| + |
| +#include "base/macros.h" |
| +#include "base/memory/weak_ptr.h" |
| +#include "components/prefs/pref_change_registrar.h" |
| +#include "components/sync_preferences/pref_service_syncable_observer.h" |
| + |
| +class Profile; |
|
Yusuke Sato
2017/03/01 18:09:26
nit: As you know, https://google.github.io/stylegu
hidehiko
2017/03/01 19:21:31
AFAIK, in Chromium, the rule is overriden by https
Luis Héctor Chávez
2017/03/02 00:09:17
Yes, Chromium is considered to be a single project
|
| + |
| +namespace arc { |
| + |
| +class ArcSessionManager; |
| + |
| +// Observes Google Play Store enabled preference (whose key is "arc.enabled" |
| +// for historical reason), and controls ARC via ArcSessionManager. |
| +// In addition, this controls showing/hiding a notification to enable Google |
| +// Play Store. |
| +class ArcPlayStoreEnabledPreferenceHandler |
| + : public sync_preferences::PrefServiceSyncableObserver { |
| + public: |
| + ArcPlayStoreEnabledPreferenceHandler(Profile* profile, |
| + ArcSessionManager* arc_session_manager); |
| + ~ArcPlayStoreEnabledPreferenceHandler() override; |
| + |
| + // Starts observing Google Play Store enabled preference change. |
| + // Also, based on its initial value, this may start ArcSession, or may start |
| + // removing the data, as initial state. |
| + // In addition, this triggers to show ArcAuthNotification, if necessary. |
| + void Start(); |
| + |
| + private: |
| + // Called when Google Play Store enabled preference is changed. |
| + void OnPreferenceChanged(); |
| + |
| + // sync_preferences::PrefServiceSyncableObserver: |
| + void OnIsSyncingChanged() override; |
| + |
| + Profile* const profile_; |
| + |
| + // Owned by ArcServiceLauncher. |
| + ArcSessionManager* const arc_session_manager_; |
| + |
| + // Registrar used to monitor ARC enabled state. |
| + PrefChangeRegistrar pref_change_registrar_; |
| + |
| + // Must be the last member. |
| + base::WeakPtrFactory<ArcPlayStoreEnabledPreferenceHandler> weak_ptr_factory_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ArcPlayStoreEnabledPreferenceHandler); |
| +}; |
| + |
| +} // namespace arc |
| + |
| +#endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_PLAY_STORE_ENABLED_PREFERENCE_HANDLER_H_ |