OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 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_POLICY_RECOMMENDATION_RESTORER_H_ | |
6 #define CHROME_BROWSER_CHROMEOS_POLICY_RECOMMENDATION_RESTORER_H_ | |
7 | |
8 #include <map> | |
9 #include <string> | |
10 | |
11 #include "ash/wm/user_activity_observer.h" | |
12 #include "base/basictypes.h" | |
13 #include "base/compiler_specific.h" | |
14 #include "base/memory/scoped_ptr.h" | |
15 #include "base/prefs/pref_change_registrar.h" | |
16 #include "base/timer.h" | |
17 #include "components/browser_context_keyed_service/browser_context_keyed_service .h" | |
18 #include "content/public/browser/notification_observer.h" | |
19 #include "content/public/browser/notification_registrar.h" | |
20 | |
21 class PrefService; | |
22 class Profile; | |
23 | |
24 namespace base { | |
25 class Value; | |
26 } | |
27 | |
28 namespace policy { | |
29 | |
30 // Clears user-set prefs in the login profile to restore recommended values. The | |
31 // recommended values are restored when the login screen is first shown and | |
32 // whenever the user becomes idle for one minute. | |
33 class RecommendationRestorerInternal : public ash::UserActivityObserver { | |
34 public: | |
35 explicit RecommendationRestorerInternal(PrefService* prefs); | |
36 virtual ~RecommendationRestorerInternal(); | |
37 | |
38 // ash::UserActivityObserver::Observer: | |
39 virtual void OnUserActivity() OVERRIDE; | |
40 | |
41 void CheckPref(const std::string& pref_name); | |
Mattias Nissler (ping if slow)
2013/06/12 13:55:16
needs doc
bartfab (slow)
2013/06/12 18:57:49
Done.
| |
42 | |
43 private: | |
44 void RestoreAll(); | |
45 | |
46 PrefChangeRegistrar registrar_; | |
47 | |
48 std::map<std::string, base::Value*> recommended_values_; | |
Mattias Nissler (ping if slow)
2013/06/12 13:55:16
what is this good for?
bartfab (slow)
2013/06/12 18:57:49
Adeed a comment explaining the purpose.
| |
49 | |
50 base::OneShotTimer<RecommendationRestorerInternal> restore_timer_; | |
51 | |
52 DISALLOW_COPY_AND_ASSIGN(RecommendationRestorerInternal); | |
53 }; | |
54 | |
55 // BCKS that is instantiated for all profiles. Ensures that a | |
56 // RecommendationRestorerInternal exists only for the login profile and only | |
57 // while the login screen is being shown. | |
58 class RecommendationRestorer : public BrowserContextKeyedService, | |
59 public content::NotificationObserver { | |
60 public: | |
61 explicit RecommendationRestorer(Profile* profile); | |
62 virtual ~RecommendationRestorer(); | |
63 | |
64 // BrowserContextKeyedService: | |
65 virtual void Shutdown() OVERRIDE; | |
66 | |
67 // content::NotificationObserver: | |
68 virtual void Observe(int type, | |
69 const content::NotificationSource& source, | |
70 const content::NotificationDetails& details) OVERRIDE; | |
71 | |
72 private: | |
73 friend class RecommendationRestorerTest; | |
74 | |
75 scoped_ptr<RecommendationRestorerInternal> recommendation_restorer_internal_; | |
76 | |
77 content::NotificationRegistrar registrar_; | |
78 | |
79 DISALLOW_COPY_AND_ASSIGN(RecommendationRestorer); | |
80 }; | |
81 | |
82 } // namespace policy | |
83 | |
84 #endif // CHROME_BROWSER_CHROMEOS_POLICY_RECOMMENDATION_RESTORER_H_ | |
OLD | NEW |