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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
// Copyright (c) 2011 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_CHROMEOS_WEBUI_INTERNET_OPTIONS_HANDLER_H_
#define CHROME_BROWSER_CHROMEOS_WEBUI_INTERNET_OPTIONS_HANDLER_H_
#include <string>
#include "chrome/browser/chromeos/cros/network_library.h"
#include "chrome/browser/dom_ui/options/options_ui.h"
class SkBitmap;
namespace views {
class WindowDelegate;
}
// ChromeOS internet options page UI handler.
class InternetOptionsHandler
: public OptionsPageUIHandler,
public chromeos::NetworkLibrary::NetworkManagerObserver,
public chromeos::NetworkLibrary::NetworkObserver,
public chromeos::NetworkLibrary::CellularDataPlanObserver {
public:
InternetOptionsHandler();
virtual ~InternetOptionsHandler();
// OptionsUIHandler implementation.
virtual void GetLocalizedValues(DictionaryValue* localized_strings);
// WebUIMessageHandler implementation.
virtual void RegisterMessages();
// NetworkLibrary::NetworkManagerObserver implementation.
virtual void OnNetworkManagerChanged(chromeos::NetworkLibrary* network_lib);
// NetworkLibrary::NetworkObserver implementation.
virtual void OnNetworkChanged(chromeos::NetworkLibrary* network_lib,
const chromeos::Network* network);
// NetworkLibrary::CellularDataPlanObserver implementation.
virtual void OnCellularDataPlanChanged(chromeos::NetworkLibrary* network_lib);
private:
// Opens a modal popup dialog.
void CreateModalPopup(views::WindowDelegate* view);
// Passes data needed to show details overlay for network.
// |args| will be [ network_type, service_path, command ]
// And command is one of 'options', 'connect', disconnect', 'activate' or
// 'forget'
// Handle{Wifi,Cellular}ButtonClick handles button click on a wireless
// network item and a cellular network item respectively.
void ButtonClickCallback(const ListValue* args);
void HandleWifiButtonClick(const std::string& service_path,
const std::string& command);
void HandleCellularButtonClick(const std::string& service_path,
const std::string& command);
// Initiates cellular plan data refresh. The results from libcros will be
// passed through CellularDataPlanChanged() callback method.
// |args| will be [ service_path ]
void RefreshCellularPlanCallback(const ListValue* args);
void SetActivationButtonVisibility(
const chromeos::CellularNetwork* cellular,
DictionaryValue* dictionary);
void LoginCallback(const ListValue* args);
void LoginCertCallback(const ListValue* args);
void LoginToOtherCallback(const ListValue* args);
void SetDetailsCallback(const ListValue* args);
void EnableWifiCallback(const ListValue* args);
void DisableWifiCallback(const ListValue* args);
void EnableCellularCallback(const ListValue* args);
void DisableCellularCallback(const ListValue* args);
void BuyDataPlanCallback(const ListValue* args);
// Parses 'path' to determine if the certificate is stored in a pkcs#11
// device. flimflam recognizes the string "SETTINGS:" to specify
// authentication parameters. 'key_id=' indicates that the certificate is
// stored in a pkcs#11 device.
// See src/third_party/flimflam/files/doc/service-api.txt.
bool IsCertificateInPkcs11(const std::string& path);
// Populates the ui with the details of the given device path. This forces
// an overlay to be displayed in the UI.
void PopulateDictionaryDetails(const chromeos::Network* net,
chromeos::NetworkLibrary* cros);
void PopulateWifiDetails(const chromeos::WifiNetwork* wifi,
DictionaryValue* dictionary);
void PopulateCellularDetails(const chromeos::CellularNetwork* cellular,
DictionaryValue* dictionary);
// Converts CellularDataPlan structure into dictionary for JS. Formats plan
// settings into human readable texts.
DictionaryValue* CellularDataPlanToDictionary(
const chromeos::CellularDataPlan* plan);
// Creates the map of a network.
ListValue* GetNetwork(const std::string& service_path,
const SkBitmap& icon,
const std::string& name,
bool connecting,
bool connected,
bool connectable,
chromeos::ConnectionType connection_type,
bool remembered,
chromeos::ActivationState activation_state,
bool restricted_ip);
// Creates the map of wired networks.
ListValue* GetWiredList();
// Creates the map of wireless networks.
ListValue* GetWirelessList();
// Creates the map of remembered networks.
ListValue* GetRememberedList();
// Fills network information into JS dictionary for displaying network lists.
void FillNetworkInfo(DictionaryValue* dictionary,
chromeos::NetworkLibrary* cros);
// Refreshes the display of network information.
void RefreshNetworkData(chromeos::NetworkLibrary* cros);
// Adds observers for wireless networks, if any, so that we can dynamically
// display the correct icon for that network's signal strength and, in the
// case of cellular networks, network technology and roaming status.
void MonitorNetworks(chromeos::NetworkLibrary* cros);
// A boolean flag of whether to use WebUI for connect UI. True to use WebUI
// and false to use Views dialogs.
bool use_settings_ui_;
DISALLOW_COPY_AND_ASSIGN(InternetOptionsHandler);
};
#endif // CHROME_BROWSER_CHROMEOS_WEBUI_INTERNET_OPTIONS_HANDLER_H_
|