blob: 3dcdf1e31647d4730249e28a6d9ad4cedc7e2c3f [file] [log] [blame]
[email protected]1aabf592013-06-07 08:53:011// Copyright 2013 The Chromium Authors. All rights reserved.
[email protected]05d242d2013-04-08 21:49:492// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
drogerf8479942014-11-21 17:47:535#ifndef COMPONENTS_WEB_RESOURCE_EULA_ACCEPTED_NOTIFIER_H_
6#define COMPONENTS_WEB_RESOURCE_EULA_ACCEPTED_NOTIFIER_H_
[email protected]05d242d2013-04-08 21:49:497
avi5dd91f82015-12-25 22:30:468#include "base/macros.h"
brettwf00b9b42016-02-01 22:11:389#include "components/prefs/pref_change_registrar.h"
[email protected]05d242d2013-04-08 21:49:4910
[email protected]80373b62013-06-04 20:37:0611class PrefService;
12
drogerc4ccb832014-11-27 16:10:4913namespace web_resource {
14
[email protected]80373b62013-06-04 20:37:0615// Helper class for querying the EULA accepted state and receiving a
16// notification when the EULA is accepted.
[email protected]05d242d2013-04-08 21:49:4917class EulaAcceptedNotifier {
18 public:
19 // Observes EULA accepted state changes.
20 class Observer {
21 public:
Sky Maliceeffb9082018-07-18 15:44:4422 virtual ~Observer() {}
[email protected]05d242d2013-04-08 21:49:4923 virtual void OnEulaAccepted() = 0;
24 };
25
[email protected]80373b62013-06-04 20:37:0626 explicit EulaAcceptedNotifier(PrefService* local_state);
[email protected]05d242d2013-04-08 21:49:4927 virtual ~EulaAcceptedNotifier();
28
29 // Initializes this class with the given |observer|. Must be called before
30 // the class is used.
31 void Init(Observer* observer);
32
33 // Returns true if the EULA has been accepted. If the EULA has not yet been
34 // accepted, begins monitoring the EULA state and will notify the observer
35 // once the EULA has been accepted.
[email protected]80373b62013-06-04 20:37:0636 virtual bool IsEulaAccepted();
[email protected]05d242d2013-04-08 21:49:4937
38 // Factory method for this class.
drogerf4455482014-11-21 09:50:1839 static EulaAcceptedNotifier* Create(PrefService* local_state);
[email protected]05d242d2013-04-08 21:49:4940
41 protected:
[email protected]80373b62013-06-04 20:37:0642 // Notifies the observer that the EULA has been updated, made protected for
43 // testing.
[email protected]05d242d2013-04-08 21:49:4944 void NotifyObserver();
45
46 private:
[email protected]80373b62013-06-04 20:37:0647 // Callback for EULA accepted pref change notification.
48 void OnPrefChanged();
49
50 // Local state pref service for querying the EULA accepted pref.
51 PrefService* local_state_;
52
53 // Used to listen for the EULA accepted pref change notification.
54 PrefChangeRegistrar registrar_;
55
[email protected]05d242d2013-04-08 21:49:4956 // Observer of the EULA accepted notification.
57 Observer* observer_;
58
59 DISALLOW_COPY_AND_ASSIGN(EulaAcceptedNotifier);
60};
61
drogerc4ccb832014-11-27 16:10:4962} // namespace web_resource
63
drogerf8479942014-11-21 17:47:5364#endif // COMPONENTS_WEB_RESOURCE_EULA_ACCEPTED_NOTIFIER_H_