1 // Copyright 2013 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.
5 #ifndef CHROME_BROWSER_CHROMEOS_POWER_POWER_PREFS_H_
6 #define CHROME_BROWSER_CHROMEOS_POWER_POWER_PREFS_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "content/public/browser/notification_observer.h"
12 #include "content/public/browser/notification_registrar.h"
14 class PrefChangeRegistrar
;
17 namespace user_prefs
{
18 class PrefRegistrySyncable
;
23 class PowerPolicyController
;
25 // Sends an updated power policy to the |power_policy_controller| whenever one
26 // of the power-related prefs changes.
27 class PowerPrefs
: public content::NotificationObserver
{
29 explicit PowerPrefs(PowerPolicyController
* power_policy_controller
);
30 ~PowerPrefs() override
;
32 // Register power prefs with default values applicable to a user profile.
33 static void RegisterUserProfilePrefs(
34 user_prefs::PrefRegistrySyncable
* registry
);
36 // Register power prefs with default values applicable to the login profile.
37 static void RegisterLoginProfilePrefs(
38 user_prefs::PrefRegistrySyncable
* registry
);
40 // content::NotificationObserver:
41 void Observe(int type
,
42 const content::NotificationSource
& source
,
43 const content::NotificationDetails
& details
) override
;
45 void UpdatePowerPolicyFromPrefs();
48 friend class PowerPrefsTest
;
50 // Register power prefs whose default values are the same in user profiles and
52 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable
* registry
);
54 void SetProfile(Profile
* profile
);
56 PowerPolicyController
* power_policy_controller_
; // Not owned.
58 content::NotificationRegistrar notification_registrar_
;
60 Profile
* profile_
; // Not owned.
61 scoped_ptr
<PrefChangeRegistrar
> pref_change_registrar_
;
63 // True while the screen is locked (but not while the login screen is shown).
64 bool screen_is_locked_
;
66 DISALLOW_COPY_AND_ASSIGN(PowerPrefs
);
69 } // namespace chromeos
71 #endif // CHROME_BROWSER_CHROMEOS_POWER_POWER_PREFS_H_