OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_RECOMMENDATION_RESTORER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_RECOMMENDATION_RESTORER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_POLICY_RECOMMENDATION_RESTORER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_POLICY_RECOMMENDATION_RESTORER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "ash/wm/user_activity_observer.h" | 10 #include "ash/wm/user_activity_observer.h" |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/prefs/pref_change_registrar.h" | 13 #include "base/prefs/pref_change_registrar.h" |
| 14 #include "base/prefs/pref_service.h" |
14 #include "base/timer/timer.h" | 15 #include "base/timer/timer.h" |
15 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" | 16 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" |
16 #include "content/public/browser/notification_observer.h" | 17 #include "content/public/browser/notification_observer.h" |
17 #include "content/public/browser/notification_registrar.h" | 18 #include "content/public/browser/notification_registrar.h" |
18 | 19 |
19 class Profile; | 20 class Profile; |
20 | 21 |
21 namespace policy { | 22 namespace policy { |
22 | 23 |
23 // Observes a set of prefs in the login profile. If any of the prefs has a | 24 // Observes a set of prefs in the login profile. If any of the prefs has a |
(...skipping 18 matching lines...) Expand all Loading... |
42 const content::NotificationDetails& details) OVERRIDE; | 43 const content::NotificationDetails& details) OVERRIDE; |
43 | 44 |
44 // ash::UserActivityObserver: | 45 // ash::UserActivityObserver: |
45 virtual void OnUserActivity(const ui::Event* event) OVERRIDE; | 46 virtual void OnUserActivity(const ui::Event* event) OVERRIDE; |
46 | 47 |
47 // If a recommended value and a user setting exist for |pref_name|, clears the | 48 // If a recommended value and a user setting exist for |pref_name|, clears the |
48 // user setting so that the recommended value can take effect. If | 49 // user setting so that the recommended value can take effect. If |
49 // |allow_delay| is |true| and the login screen is being shown, a timer is | 50 // |allow_delay| is |true| and the login screen is being shown, a timer is |
50 // started that will clear the setting when the user becomes idle for one | 51 // started that will clear the setting when the user becomes idle for one |
51 // minute. Otherwise, the setting is cleared immediately. | 52 // minute. Otherwise, the setting is cleared immediately. |
52 void Restore(bool allow_delay, const std::string& pref_name); | 53 // |
| 54 // RestoreGlobalPref for the global pref, RestoreUserPref for user pref. |
| 55 void RestoreGlobalPref(bool allow_delay, const std::string& pref_name); |
| 56 void RestoreUserPref(bool allow_delay, const std::string& pref_name); |
53 | 57 |
54 private: | 58 private: |
55 friend class RecommendationRestorerTest; | 59 friend class RecommendationRestorerTest; |
56 | 60 |
| 61 void RestorePrefInternal(bool allow_delay, |
| 62 PrefService* pref, |
| 63 const std::string& pref_name); |
57 void RestoreAll(); | 64 void RestoreAll(); |
58 | 65 |
59 void StartTimer(); | 66 void StartTimer(); |
60 void StopTimer(); | 67 void StopTimer(); |
61 | 68 |
62 PrefChangeRegistrar pref_change_registrar_; | 69 PrefChangeRegistrar pref_change_registrar_; |
| 70 PrefChangeRegistrar global_pref_change_registrar_; |
63 content::NotificationRegistrar notification_registrar_; | 71 content::NotificationRegistrar notification_registrar_; |
64 | 72 |
65 bool logged_in_; | 73 bool logged_in_; |
66 | 74 |
67 base::OneShotTimer<RecommendationRestorer> restore_timer_; | 75 base::OneShotTimer<RecommendationRestorer> restore_timer_; |
68 | 76 |
69 DISALLOW_COPY_AND_ASSIGN(RecommendationRestorer); | 77 DISALLOW_COPY_AND_ASSIGN(RecommendationRestorer); |
70 }; | 78 }; |
71 | 79 |
72 } // namespace policy | 80 } // namespace policy |
73 | 81 |
74 #endif // CHROME_BROWSER_CHROMEOS_POLICY_RECOMMENDATION_RESTORER_H_ | 82 #endif // CHROME_BROWSER_CHROMEOS_POLICY_RECOMMENDATION_RESTORER_H_ |
OLD | NEW |