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.
4
5#ifndef CHROME_BROWSER_CHROMEOS_POWER_POWER_PREFS_H_
6#define CHROME_BROWSER_CHROMEOS_POWER_POWER_PREFS_H_
7
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"
13
14class PrefChangeRegistrar;
15class Profile;
16
17namespace user_prefs {
18class PrefRegistrySyncable;
19}
20
21namespace chromeos {
22
23class PowerPolicyController;
24
25// Sends an updated power policy to the |power_policy_controller| whenever one
26// of the power-related prefs changes.
27class PowerPrefs : public content::NotificationObserver {
28 public:
29  explicit PowerPrefs(PowerPolicyController* power_policy_controller);
30  virtual ~PowerPrefs();
31
32  // Register power prefs with default values applicable to a user profile.
33  static void RegisterUserProfilePrefs(
34      user_prefs::PrefRegistrySyncable* registry);
35
36  // Register power prefs with default values applicable to the login profile.
37  static void RegisterLoginProfilePrefs(
38      user_prefs::PrefRegistrySyncable* registry);
39
40  // content::NotificationObserver:
41  virtual void Observe(int type,
42                       const content::NotificationSource& source,
43                       const content::NotificationDetails& details) OVERRIDE;
44
45  void UpdatePowerPolicyFromPrefs();
46
47 private:
48  friend class PowerPrefsTest;
49
50  // Register power prefs whose default values are the same in user profiles and
51  // the login profile.
52  static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
53
54  void SetProfile(Profile* profile);
55
56  PowerPolicyController* power_policy_controller_;  // Not owned.
57
58  content::NotificationRegistrar notification_registrar_;
59
60  Profile* profile_;  // Not owned.
61  scoped_ptr<PrefChangeRegistrar> pref_change_registrar_;
62
63  DISALLOW_COPY_AND_ASSIGN(PowerPrefs);
64};
65
66}  // namespace chromeos
67
68#endif  // CHROME_BROWSER_CHROMEOS_POWER_POWER_PREFS_H_
69