| Index: chrome/browser/resource_request_allowed_notifier.h
|
| diff --git a/chrome/browser/resource_request_allowed_notifier.h b/chrome/browser/resource_request_allowed_notifier.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..17ba40ecac3dc31b0dde60044f43f31f7f2328ee
|
| --- /dev/null
|
| +++ b/chrome/browser/resource_request_allowed_notifier.h
|
| @@ -0,0 +1,69 @@
|
| +// Copyright (c) 2012 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_RESOURCE_REQUEST_ALLOWED_NOTIFIER_H_
|
| +#define CHROME_BROWSER_RESOURCE_REQUEST_ALLOWED_NOTIFIER_H_
|
| +
|
| +#include "base/observer_list.h"
|
| +#include "net/base/network_change_notifier.h"
|
| +
|
| +#if defined(OS_CHROMEOS)
|
| +#include "content/public/browser/notification_observer.h"
|
| +#include "content/public/browser/notification_registrar.h"
|
| +#endif
|
| +
|
| +// Services that need to request resources over the network should use this
|
| +// helper class to check if they can perform their requests. They should check
|
| +// both IsNetworkAccessAllowed and IsEulaAccepted before requesting their data.
|
| +// If either is false, the service can add themselves as an observer of this
|
| +// class and be notified when the network is up, or the EULA is accepted.
|
| +class ResourceRequestAllowedNotifier :
|
| +#if defined(OS_CHROMEOS)
|
| + public content::NotificationObserver,
|
| +#endif
|
| + public net::NetworkChangeNotifier::ConnectionTypeObserver {
|
| + public:
|
| + // Observes network and EULA state changes.
|
| + class Observer {
|
| + public:
|
| + // Called after the network changes to an active connection.
|
| + virtual void OnNetworkChangedToActiveConnection() = 0;
|
| +
|
| +#if defined(OS_CHROMEOS)
|
| + // Called after the EULA has been accepted.
|
| + virtual void OnEulaAccepted() = 0;
|
| +#endif
|
| + };
|
| +
|
| + ResourceRequestAllowedNotifier();
|
| + virtual ~ResourceRequestAllowedNotifier();
|
| +
|
| + void AddObserver(Observer* observer);
|
| + void RemoveObserver(Observer* observer);
|
| +
|
| + // Returns true iff the network is currently inaccessible.
|
| + static bool IsNetworkOffline();
|
| +
|
| +#if defined(OS_CHROMEOS)
|
| + // Returns true iff the EULA was accepted by the user.
|
| + static bool IsEulaAccepted();
|
| +
|
| + // content::NotificationObserver overrides:
|
| + virtual void Observe(int type,
|
| + const content::NotificationSource& source,
|
| + const content::NotificationDetails& details) OVERRIDE;
|
| +#endif
|
| +
|
| + // net::NetworkChangeNotifier::ConnectionTypeObserver implementation.
|
| + virtual void OnConnectionTypeChanged(
|
| + net::NetworkChangeNotifier::ConnectionType type) OVERRIDE;
|
| +
|
| + private:
|
| + // List of observers interested in request permissions.
|
| + ObserverList<Observer> observer_list_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(ResourceRequestAllowedNotifier);
|
| +};
|
| +
|
| +#endif // CHROME_BROWSER_RESOURCE_REQUEST_ALLOWED_NOTIFIER_H_
|
|
|