Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(673)

Unified Diff: chrome/browser/chromeos/policy/recommendation_restorer.h

Issue 16658015: Add device policies to control accessibility settings on the login screen (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed leaky tests. Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..ba843d5abc1ed5a7da811b7a4e20de0ff02d1d0e
--- /dev/null
+++ b/chrome/browser/chromeos/policy/recommendation_restorer.h
@@ -0,0 +1,74 @@
+// 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 <string>
+
+#include "ash/wm/user_activity_observer.h"
+#include "base/basictypes.h"
+#include "base/compiler_specific.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 Profile;
+
+namespace policy {
+
+// Observes a set of prefs in the login profile. If any of the prefs has a
+// recommended value, its user setting is cleared so that the recommendation can
+// take effect. This happens immediately when the login screen is shown, when
+// a session is being started and whenever recommended values change during a
+// user session. On the login screen, user settings are cleared when the user
+// becomes idle for one minute.
+class RecommendationRestorer : public BrowserContextKeyedService,
+ public content::NotificationObserver,
+ public ash::UserActivityObserver {
+ 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;
+
+ // ash::UserActivityObserver::Observer:
+ virtual void OnUserActivity() OVERRIDE;
+
+ // If a recommended value and a user setting exist for |pref_name|, clears the
+ // user setting so that the recommended value can take effect. If
+ // |allow_delay| is |true| and the login screen is being shown, a timer is
+ // started that will clear the setting when the user becomes idle for one
+ // minute. Otherwise, the setting is cleared immediately.
+ void Restore(bool allow_delay, const std::string& pref_name);
+
+ private:
+ friend class RecommendationRestorerTest;
+
+ void RestoreAll();
+
+ void StartTimer();
+ void StopTimer();
+
+ PrefChangeRegistrar pref_change_registrar_;
+ content::NotificationRegistrar notification_registrar_;
+
+ bool logged_in_;
+
+ base::OneShotTimer<RecommendationRestorer> restore_timer_;
+
+ DISALLOW_COPY_AND_ASSIGN(RecommendationRestorer);
+};
+
+} // namespace policy
+
+#endif // CHROME_BROWSER_CHROMEOS_POLICY_RECOMMENDATION_RESTORER_H_

Powered by Google App Engine
This is Rietveld 408576698