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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 void RecommendationRestorer::Shutdown() { | 70 void RecommendationRestorer::Shutdown() { |
71 StopTimer(); | 71 StopTimer(); |
72 pref_change_registrar_.RemoveAll(); | 72 pref_change_registrar_.RemoveAll(); |
73 notification_registrar_.RemoveAll(); | 73 notification_registrar_.RemoveAll(); |
74 } | 74 } |
75 | 75 |
76 void RecommendationRestorer::Observe( | 76 void RecommendationRestorer::Observe( |
77 int type, | 77 int type, |
78 const content::NotificationSource& source, | 78 const content::NotificationSource& source, |
79 const content::NotificationDetails& details) { | 79 const content::NotificationDetails& details) { |
80 if (type == chrome::NOTIFICATION_LOGIN_USER_CHANGED) { | 80 DCHECK_EQ(chrome::NOTIFICATION_LOGIN_USER_CHANGED, type); |
81 logged_in_ = true; | 81 |
82 notification_registrar_.RemoveAll(); | 82 logged_in_ = true; |
83 StopTimer(); | 83 notification_registrar_.RemoveAll(); |
84 RestoreAll(); | 84 StopTimer(); |
85 } else { | 85 RestoreAll(); |
86 NOTREACHED(); | |
87 } | |
88 } | 86 } |
89 | 87 |
90 void RecommendationRestorer::OnUserActivity(const ui::Event* event) { | 88 void RecommendationRestorer::OnUserActivity(const ui::Event* event) { |
91 if (restore_timer_.IsRunning()) | 89 if (restore_timer_.IsRunning()) |
92 restore_timer_.Reset(); | 90 restore_timer_.Reset(); |
93 } | 91 } |
94 | 92 |
95 void RecommendationRestorer::Restore(bool allow_delay, | 93 void RecommendationRestorer::Restore(bool allow_delay, |
96 const std::string& pref_name) { | 94 const std::string& pref_name) { |
97 const PrefService::Preference* pref = | 95 const PrefService::Preference* pref = |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 base::Unretained(this))); | 152 base::Unretained(this))); |
155 } | 153 } |
156 | 154 |
157 void RecommendationRestorer::StopTimer() { | 155 void RecommendationRestorer::StopTimer() { |
158 restore_timer_.Stop(); | 156 restore_timer_.Stop(); |
159 if (ui::UserActivityDetector::Get()) | 157 if (ui::UserActivityDetector::Get()) |
160 ui::UserActivityDetector::Get()->RemoveObserver(this); | 158 ui::UserActivityDetector::Get()->RemoveObserver(this); |
161 } | 159 } |
162 | 160 |
163 } // namespace policy | 161 } // namespace policy |
OLD | NEW |