Chromium Code Reviews| Index: chrome/browser/chromeos/policy/recommendation_restorer.h |
| diff --git a/chrome/browser/chromeos/policy/recommendation_restorer.h b/chrome/browser/chromeos/policy/recommendation_restorer.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..51888ec302442928366a0d4989756ba2e4140821 |
| --- /dev/null |
| +++ b/chrome/browser/chromeos/policy/recommendation_restorer.h |
| @@ -0,0 +1,84 @@ |
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_CHROMEOS_POLICY_RECOMMENDATION_RESTORER_H_ |
| +#define CHROME_BROWSER_CHROMEOS_POLICY_RECOMMENDATION_RESTORER_H_ |
| + |
| +#include <map> |
| +#include <string> |
| + |
| +#include "ash/wm/user_activity_observer.h" |
| +#include "base/basictypes.h" |
| +#include "base/compiler_specific.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/prefs/pref_change_registrar.h" |
| +#include "base/timer.h" |
| +#include "components/browser_context_keyed_service/browser_context_keyed_service.h" |
| +#include "content/public/browser/notification_observer.h" |
| +#include "content/public/browser/notification_registrar.h" |
| + |
| +class PrefService; |
| +class Profile; |
| + |
| +namespace base { |
| +class Value; |
| +} |
| + |
| +namespace policy { |
| + |
| +// Clears user-set prefs in the login profile to restore recommended values. The |
| +// recommended values are restored when the login screen is first shown and |
| +// whenever the user becomes idle for one minute. |
| +class RecommendationRestorerInternal : public ash::UserActivityObserver { |
| + public: |
| + explicit RecommendationRestorerInternal(PrefService* prefs); |
| + virtual ~RecommendationRestorerInternal(); |
| + |
| + // ash::UserActivityObserver::Observer: |
| + virtual void OnUserActivity() OVERRIDE; |
| + |
| + 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.
|
| + |
| + private: |
| + void RestoreAll(); |
| + |
| + PrefChangeRegistrar registrar_; |
| + |
| + 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.
|
| + |
| + base::OneShotTimer<RecommendationRestorerInternal> restore_timer_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(RecommendationRestorerInternal); |
| +}; |
| + |
| +// BCKS that is instantiated for all profiles. Ensures that a |
| +// RecommendationRestorerInternal exists only for the login profile and only |
| +// while the login screen is being shown. |
| +class RecommendationRestorer : public BrowserContextKeyedService, |
| + public content::NotificationObserver { |
| + public: |
| + explicit RecommendationRestorer(Profile* profile); |
| + virtual ~RecommendationRestorer(); |
| + |
| + // BrowserContextKeyedService: |
| + virtual void Shutdown() OVERRIDE; |
| + |
| + // content::NotificationObserver: |
| + virtual void Observe(int type, |
| + const content::NotificationSource& source, |
| + const content::NotificationDetails& details) OVERRIDE; |
| + |
| + private: |
| + friend class RecommendationRestorerTest; |
| + |
| + scoped_ptr<RecommendationRestorerInternal> recommendation_restorer_internal_; |
| + |
| + content::NotificationRegistrar registrar_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(RecommendationRestorer); |
| +}; |
| + |
| +} // namespace policy |
| + |
| +#endif // CHROME_BROWSER_CHROMEOS_POLICY_RECOMMENDATION_RESTORER_H_ |