Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / components / web_resource / eula_accepted_notifier.h
blob552b53ca048f0407296acdd5a5f6cffee9524c31
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
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_WEB_RESOURCE_EULA_ACCEPTED_NOTIFIER_H_
6 #define COMPONENTS_WEB_RESOURCE_EULA_ACCEPTED_NOTIFIER_H_
8 #include "base/basictypes.h"
9 #include "base/prefs/pref_change_registrar.h"
11 class PrefService;
13 namespace web_resource {
15 // Helper class for querying the EULA accepted state and receiving a
16 // notification when the EULA is accepted.
17 class EulaAcceptedNotifier {
18 public:
19 // Observes EULA accepted state changes.
20 class Observer {
21 public:
22 virtual void OnEulaAccepted() = 0;
25 explicit EulaAcceptedNotifier(PrefService* local_state);
26 virtual ~EulaAcceptedNotifier();
28 // Initializes this class with the given |observer|. Must be called before
29 // the class is used.
30 void Init(Observer* observer);
32 // Returns true if the EULA has been accepted. If the EULA has not yet been
33 // accepted, begins monitoring the EULA state and will notify the observer
34 // once the EULA has been accepted.
35 virtual bool IsEulaAccepted();
37 // Factory method for this class.
38 static EulaAcceptedNotifier* Create(PrefService* local_state);
40 protected:
41 // Notifies the observer that the EULA has been updated, made protected for
42 // testing.
43 void NotifyObserver();
45 private:
46 // Callback for EULA accepted pref change notification.
47 void OnPrefChanged();
49 // Local state pref service for querying the EULA accepted pref.
50 PrefService* local_state_;
52 // Used to listen for the EULA accepted pref change notification.
53 PrefChangeRegistrar registrar_;
55 // Observer of the EULA accepted notification.
56 Observer* observer_;
58 DISALLOW_COPY_AND_ASSIGN(EulaAcceptedNotifier);
61 } // namespace web_resource
63 #endif // COMPONENTS_WEB_RESOURCE_EULA_ACCEPTED_NOTIFIER_H_