| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 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. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_NET_CONNECTIVITY_STATE_HELPER_H_ | |
| 6 #define CHROME_BROWSER_CHROMEOS_NET_CONNECTIVITY_STATE_HELPER_H_ | |
| 7 | |
| 8 #include "base/observer_list.h" | |
| 9 #include "chrome/browser/chromeos/cros/network_library.h" | |
| 10 #include "chrome/browser/chromeos/net/connectivity_state_helper_observer.h" | |
| 11 #include "chromeos/network/network_state_handler.h" | |
| 12 | |
| 13 namespace chromeos { | |
| 14 | |
| 15 // This class provides an interface for consumers to query the connectivity | |
| 16 // state on Chrome OS. Subclasses must implement the query methods using an | |
| 17 // appropriate source (e.g. NetworkStateHandler). | |
| 18 class ConnectivityStateHelper { | |
| 19 public: | |
| 20 virtual ~ConnectivityStateHelper(); | |
| 21 | |
| 22 // Initializes the state helper singleton to use the default (network state | |
| 23 // handler) implementation or the network library implementation based | |
| 24 // on the value of command line flag. | |
| 25 static void Initialize(); | |
| 26 static bool IsInitialized(); | |
| 27 static void Shutdown(); | |
| 28 static ConnectivityStateHelper* Get(); | |
| 29 | |
| 30 // Sets up Get() to return |impl| for testing (e.g. with a mock | |
| 31 // implementation). Call SetForTest(NUL) when |impl| is deleted. | |
| 32 static void SetForTest(ConnectivityStateHelper* impl); | |
| 33 | |
| 34 // Returns true if in a connected state. | |
| 35 virtual bool IsConnected() = 0; | |
| 36 | |
| 37 // Returns true if in a connecting state. | |
| 38 virtual bool IsConnecting() = 0; | |
| 39 | |
| 40 // Returns true if there's a network of |type| in connected state. | |
| 41 virtual bool IsConnectedType(const std::string& type) = 0; | |
| 42 | |
| 43 // Returns true if there's a network of |type| in connecting state. | |
| 44 virtual bool IsConnectingType(const std::string& type) = 0; | |
| 45 | |
| 46 // Get the name for the primary network of type |type| which is not | |
| 47 // in non-idle state (i.e. connecting or connected state). | |
| 48 virtual std::string NetworkNameForType(const std::string& type) = 0; | |
| 49 | |
| 50 // Returns the name of the default network. | |
| 51 virtual std::string DefaultNetworkName() = 0; | |
| 52 | |
| 53 // Returns true if we have a default network and are in online state. | |
| 54 virtual bool DefaultNetworkOnline() = 0; | |
| 55 | |
| 56 // Request a network scan. | |
| 57 virtual void RequestScan() const = 0; | |
| 58 | |
| 59 // Add/remove observers for listening to connection manager changes. | |
| 60 virtual void AddNetworkManagerObserver( | |
| 61 ConnectivityStateHelperObserver* observer); | |
| 62 virtual void RemoveNetworkManagerObserver( | |
| 63 ConnectivityStateHelperObserver* observer); | |
| 64 | |
| 65 protected: | |
| 66 ConnectivityStateHelper(); | |
| 67 ObserverList<ConnectivityStateHelperObserver> connectivity_observers_; | |
| 68 }; | |
| 69 | |
| 70 } // namespace chromeos | |
| 71 | |
| 72 #endif // CHROME_BROWSER_CHROMEOS_NET_CONNECTIVITY_STATE_HELPER_H_ | |
| OLD | NEW |