forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnetwork_connect.h
115 lines (87 loc) · 4.27 KB
/
network_connect.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
// 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 CHROMEOS_NETWORK_NETWORK_CONNECT_H_
#define CHROMEOS_NETWORK_NETWORK_CONNECT_H_
#include <string>
#include "base/macros.h"
#include "base/strings/string16.h"
#include "chromeos/chromeos_export.h"
namespace base {
class DictionaryValue;
}
namespace chromeos {
class NetworkTypePattern;
// NetworkConnect is a state machine designed to handle the complex UI flows
// associated with connecting to a network (and related tasks). Any showing
// of UI is handled by the NetworkConnect::Delegate implementation.
class CHROMEOS_EXPORT NetworkConnect {
public:
class CHROMEOS_EXPORT Delegate {
public:
// Shows UI to configure or activate the network specified by |network_id|,
// which may include showing Payment or Portal UI when appropriate.
virtual void ShowNetworkConfigure(const std::string& network_id) = 0;
// Shows the settings related to network. If |network_id| is not empty,
// show the settings for that network.
virtual void ShowNetworkSettings(const std::string& network_id) = 0;
// Shows UI to enroll the network specified by |network_id| if appropriate
// and returns true, otherwise returns false.
virtual bool ShowEnrollNetwork(const std::string& network_id) = 0;
// Shows UI to setup a mobile network.
virtual void ShowMobileSetupDialog(const std::string& network_id) = 0;
// Shows an error notification. |error_name| is an error defined in
// NetworkConnectionHandler. |network_id| may be empty.
virtual void ShowNetworkConnectError(const std::string& error_name,
const std::string& network_id) = 0;
// Shows an error notification during mobile activation.
virtual void ShowMobileActivationError(const std::string& network_id) = 0;
protected:
virtual ~Delegate() {}
};
// Creates the global NetworkConnect object. |delegate| is owned by the
// caller.
static void Initialize(Delegate* delegate);
// Destroys the global NetworkConnect object.
static void Shutdown();
// Returns the global NetworkConnect object if initialized or NULL.
static NetworkConnect* Get();
virtual ~NetworkConnect();
// Requests a network connection and handles any errors and notifications.
virtual void ConnectToNetworkId(const std::string& network_id) = 0;
// Requests a network disconnection. Ignores any errors and notifications.
virtual void DisconnectFromNetworkId(const std::string& network_id) = 0;
// Enables or disables a network technology. If |technology| refers to
// cellular and the device cannot be enabled due to a SIM lock, this function
// will launch the SIM unlock dialog.
virtual void SetTechnologyEnabled(
const chromeos::NetworkTypePattern& technology,
bool enabled_state) = 0;
// Determines whether or not a network requires a connection to activate or
// setup and either shows a notification or opens the mobile setup dialog.
virtual void ShowMobileSetup(const std::string& network_id) = 0;
// Configures a network with a dictionary of Shill properties, then sends a
// connect request. The profile is set according to 'shared' if allowed.
// TODO(stevenjb): Use ONC properties instead of shill.
virtual void ConfigureNetworkIdAndConnect(
const std::string& network_id,
const base::DictionaryValue& shill_properties,
bool shared) = 0;
// Requests a new network configuration to be created from a dictionary of
// Shill properties and sends a connect request if the configuration succeeds.
// The profile used is determined by |shared|.
// TODO(stevenjb): Use ONC properties instead of shill.
virtual void CreateConfigurationAndConnect(
base::DictionaryValue* shill_properties,
bool shared) = 0;
// Requests a new network configuration to be created from a dictionary of
// Shill properties. The profile used is determined by |shared|.
virtual void CreateConfiguration(base::DictionaryValue* shill_properties,
bool shared) = 0;
protected:
NetworkConnect();
private:
DISALLOW_COPY_AND_ASSIGN(NetworkConnect);
};
} // namespace chromeos
#endif // CHROMEOS_NETWORK_NETWORK_CONNECT_H_