Componentize component_updater: Copy over test data with executable bit.
[chromium-blink-merge.git] / chrome / browser / web_resource / eula_accepted_notifier.h
blobec4d81506ca8878871d26425b1528fafa175a4d6
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 CHROME_BROWSER_WEB_RESOURCE_EULA_ACCEPTED_NOTIFIER_H_
6 #define CHROME_BROWSER_WEB_RESOURCE_EULA_ACCEPTED_NOTIFIER_H_
8 #include "base/basictypes.h"
9 #include "base/prefs/pref_change_registrar.h"
11 class PrefService;
13 // Helper class for querying the EULA accepted state and receiving a
14 // notification when the EULA is accepted.
15 class EulaAcceptedNotifier {
16 public:
17 // Observes EULA accepted state changes.
18 class Observer {
19 public:
20 virtual void OnEulaAccepted() = 0;
23 explicit EulaAcceptedNotifier(PrefService* local_state);
24 virtual ~EulaAcceptedNotifier();
26 // Initializes this class with the given |observer|. Must be called before
27 // the class is used.
28 void Init(Observer* observer);
30 // Returns true if the EULA has been accepted. If the EULA has not yet been
31 // accepted, begins monitoring the EULA state and will notify the observer
32 // once the EULA has been accepted.
33 virtual bool IsEulaAccepted();
35 // Factory method for this class.
36 static EulaAcceptedNotifier* Create();
38 protected:
39 // Notifies the observer that the EULA has been updated, made protected for
40 // testing.
41 void NotifyObserver();
43 private:
44 // Callback for EULA accepted pref change notification.
45 void OnPrefChanged();
47 // Local state pref service for querying the EULA accepted pref.
48 PrefService* local_state_;
50 // Used to listen for the EULA accepted pref change notification.
51 PrefChangeRegistrar registrar_;
53 // Observer of the EULA accepted notification.
54 Observer* observer_;
56 DISALLOW_COPY_AND_ASSIGN(EulaAcceptedNotifier);
59 #endif // CHROME_BROWSER_WEB_RESOURCE_EULA_ACCEPTED_NOTIFIER_H_