Pepper: Fix PPB_TrueTypeFont GetFontsInFamily function.
[chromium-blink-merge.git] / extensions / shell / browser / shell_network_controller_chromeos.h
blob1f36a7443a11461fe035cd51106a704d2681d350
1 // Copyright 2014 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 EXTENSIONS_SHELL_BROWSER_SHELL_NETWORK_CONTROLLER_CHROMEOS_H_
6 #define EXTENSIONS_SHELL_BROWSER_SHELL_NETWORK_CONTROLLER_CHROMEOS_H_
8 #include <string>
10 #include "base/compiler_specific.h"
11 #include "base/macros.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h"
14 #include "base/timer/timer.h"
15 #include "base/values.h"
16 #include "chromeos/network/network_state_handler_observer.h"
18 namespace extensions {
20 // Handles network-related tasks for app_shell on Chrome OS.
21 class ShellNetworkController : public chromeos::NetworkStateHandlerObserver {
22 public:
23 // This class must be instantiated after chromeos::DBusThreadManager and
24 // destroyed before it.
25 explicit ShellNetworkController(const std::string& preferred_network_name);
26 ~ShellNetworkController() override;
28 // chromeos::NetworkStateHandlerObserver overrides:
29 void NetworkListChanged() override;
30 void NetworkConnectionStateChanged(
31 const chromeos::NetworkState* state) override;
33 private:
34 // State of communication with the connection manager.
35 enum State {
36 // No in-progress requests.
37 STATE_IDLE = 0,
38 // Waiting for the result of an attempt to connect to the preferred network.
39 STATE_WAITING_FOR_PREFERRED_RESULT,
40 // Waiting for the result of an attempt to connect to a non-preferred
41 // network.
42 STATE_WAITING_FOR_NON_PREFERRED_RESULT,
45 // Returns the connected or connecting WiFi network or NULL if no network
46 // matches that description.
47 const chromeos::NetworkState* GetActiveWiFiNetwork();
49 // Controls whether scanning is performed periodically.
50 void SetScanningEnabled(bool enabled);
52 // Asks the connection manager to scan for networks.
53 void RequestScan();
55 // If not currently connected or connecting, chooses a wireless network and
56 // asks the connection manager to connect to it. Also switches to
57 // |preferred_network_name_| if possible.
58 void ConnectIfUnconnected();
60 // Handles a successful or failed connection attempt.
61 void HandleConnectionSuccess();
62 void HandleConnectionError(const std::string& error_name,
63 scoped_ptr<base::DictionaryValue> error_data);
65 // Current status of communication with the chromeos::NetworkStateHandler.
66 // This is tracked to avoid sending duplicate requests before the handler has
67 // acknowledged the initial connection attempt.
68 State state_;
70 // Invokes RequestScan() periodically.
71 base::RepeatingTimer<ShellNetworkController> scan_timer_;
73 // Optionally-supplied name of the preferred network.
74 std::string preferred_network_name_;
76 // True if the preferred network is connected or connecting.
77 bool preferred_network_is_active_;
79 base::WeakPtrFactory<ShellNetworkController> weak_ptr_factory_;
81 DISALLOW_COPY_AND_ASSIGN(ShellNetworkController);
84 } // namespace extensions
86 #endif // EXTENSIONS_SHELL_BROWSER_SHELL_NETWORK_CONTROLLER_CHROMEOS_H_