blob: b386e1f3dfe0d69c4de8d58c8e48711a047b9af6 [file] [log] [blame]
// Copyright 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.
#include "base/macros.h"
#include "components/prefs/pref_change_registrar.h"
class PrefService;
namespace web_resource {
// Helper class for querying the EULA accepted state and receiving a
// notification when the EULA is accepted.
class EulaAcceptedNotifier {
// Observes EULA accepted state changes.
class Observer {
virtual void OnEulaAccepted() = 0;
explicit EulaAcceptedNotifier(PrefService* local_state);
virtual ~EulaAcceptedNotifier();
// Initializes this class with the given |observer|. Must be called before
// the class is used.
void Init(Observer* observer);
// Returns true if the EULA has been accepted. If the EULA has not yet been
// accepted, begins monitoring the EULA state and will notify the observer
// once the EULA has been accepted.
virtual bool IsEulaAccepted();
// Factory method for this class.
static EulaAcceptedNotifier* Create(PrefService* local_state);
// Notifies the observer that the EULA has been updated, made protected for
// testing.
void NotifyObserver();
// Callback for EULA accepted pref change notification.
void OnPrefChanged();
// Local state pref service for querying the EULA accepted pref.
PrefService* local_state_;
// Used to listen for the EULA accepted pref change notification.
PrefChangeRegistrar registrar_;
// Observer of the EULA accepted notification.
Observer* observer_;
} // namespace web_resource