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 #include "chrome/browser/chromeos/policy/recommendation_restorer.h" | 5 #include "chrome/browser/chromeos/policy/recommendation_restorer.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/wm/user_activity_detector.h" | 8 #include "ash/wm/user_activity_detector.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 base::Unretained(this), true)); | 42 base::Unretained(this), true)); |
43 pref_change_registrar_.Add(prefs::kHighContrastEnabled, | 43 pref_change_registrar_.Add(prefs::kHighContrastEnabled, |
44 base::Bind(&RecommendationRestorer::Restore, | 44 base::Bind(&RecommendationRestorer::Restore, |
45 base::Unretained(this), true)); | 45 base::Unretained(this), true)); |
46 pref_change_registrar_.Add(prefs::kScreenMagnifierEnabled, | 46 pref_change_registrar_.Add(prefs::kScreenMagnifierEnabled, |
47 base::Bind(&RecommendationRestorer::Restore, | 47 base::Bind(&RecommendationRestorer::Restore, |
48 base::Unretained(this), true)); | 48 base::Unretained(this), true)); |
49 pref_change_registrar_.Add(prefs::kScreenMagnifierType, | 49 pref_change_registrar_.Add(prefs::kScreenMagnifierType, |
50 base::Bind(&RecommendationRestorer::Restore, | 50 base::Bind(&RecommendationRestorer::Restore, |
51 base::Unretained(this), true)); | 51 base::Unretained(this), true)); |
| 52 pref_change_registrar_.Add(prefs::kVirtualKeyboardEnabled, |
| 53 base::Bind(&RecommendationRestorer::Restore, |
| 54 base::Unretained(this), true)); |
52 | 55 |
53 notification_registrar_.Add(this, chrome::NOTIFICATION_LOGIN_USER_CHANGED, | 56 notification_registrar_.Add(this, chrome::NOTIFICATION_LOGIN_USER_CHANGED, |
54 content::NotificationService::AllSources()); | 57 content::NotificationService::AllSources()); |
55 | 58 |
56 RestoreAll(); | 59 RestoreAll(); |
57 } | 60 } |
58 | 61 |
59 RecommendationRestorer::~RecommendationRestorer() { | 62 RecommendationRestorer::~RecommendationRestorer() { |
60 } | 63 } |
61 | 64 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 else | 113 else |
111 pref_change_registrar_.prefs()->ClearPref(pref->name().c_str()); | 114 pref_change_registrar_.prefs()->ClearPref(pref->name().c_str()); |
112 } | 115 } |
113 | 116 |
114 void RecommendationRestorer::RestoreAll() { | 117 void RecommendationRestorer::RestoreAll() { |
115 Restore(false, prefs::kLargeCursorEnabled); | 118 Restore(false, prefs::kLargeCursorEnabled); |
116 Restore(false, prefs::kSpokenFeedbackEnabled); | 119 Restore(false, prefs::kSpokenFeedbackEnabled); |
117 Restore(false, prefs::kHighContrastEnabled); | 120 Restore(false, prefs::kHighContrastEnabled); |
118 Restore(false, prefs::kScreenMagnifierEnabled); | 121 Restore(false, prefs::kScreenMagnifierEnabled); |
119 Restore(false, prefs::kScreenMagnifierType); | 122 Restore(false, prefs::kScreenMagnifierType); |
| 123 Restore(false, prefs::kVirtualKeyboardEnabled); |
120 } | 124 } |
121 | 125 |
122 void RecommendationRestorer::StartTimer() { | 126 void RecommendationRestorer::StartTimer() { |
123 // Listen for user activity so that the timer can be reset while the user is | 127 // Listen for user activity so that the timer can be reset while the user is |
124 // active, causing it to fire only when the user remains idle for | 128 // active, causing it to fire only when the user remains idle for |
125 // |kRestoreDelayInMs|. | 129 // |kRestoreDelayInMs|. |
126 if (ash::Shell::HasInstance()) { | 130 if (ash::Shell::HasInstance()) { |
127 ash::UserActivityDetector* user_activity_detector = | 131 ash::UserActivityDetector* user_activity_detector = |
128 ash::Shell::GetInstance()->user_activity_detector(); | 132 ash::Shell::GetInstance()->user_activity_detector(); |
129 if (!user_activity_detector->HasObserver(this)) | 133 if (!user_activity_detector->HasObserver(this)) |
(...skipping 14 matching lines...) Expand all Loading... |
144 base::Unretained(this))); | 148 base::Unretained(this))); |
145 } | 149 } |
146 | 150 |
147 void RecommendationRestorer::StopTimer() { | 151 void RecommendationRestorer::StopTimer() { |
148 restore_timer_.Stop(); | 152 restore_timer_.Stop(); |
149 if (ash::Shell::HasInstance()) | 153 if (ash::Shell::HasInstance()) |
150 ash::Shell::GetInstance()->user_activity_detector()->RemoveObserver(this); | 154 ash::Shell::GetInstance()->user_activity_detector()->RemoveObserver(this); |
151 } | 155 } |
152 | 156 |
153 } // namespace policy | 157 } // namespace policy |
OLD | NEW |