Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(373)

Side by Side Diff: chrome/browser/chromeos/options/network_connect.cc

Issue 16512003: Configure networks requiring a certificate. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Apply Feedback Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/options/network_connect.h" 5 #include "chrome/browser/chromeos/options/network_connect.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/shell_delegate.h" 8 #include "ash/shell_delegate.h"
9 #include "ash/system/chromeos/network/network_connect.h" 9 #include "ash/system/chromeos/network/network_connect.h"
10 #include "ash/system/chromeos/network/network_observer.h" 10 #include "ash/system/chromeos/network/network_observer.h"
11 #include "ash/system/tray/system_tray_notifier.h" 11 #include "ash/system/tray/system_tray_notifier.h"
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/stringprintf.h"
13 #include "base/utf_string_conversions.h" 14 #include "base/utf_string_conversions.h"
14 #include "chrome/browser/chromeos/cros/cros_library.h" 15 #include "chrome/browser/chromeos/cros/cros_library.h"
15 #include "chrome/browser/chromeos/cros/network_library.h" 16 #include "chrome/browser/chromeos/cros/network_library.h"
16 #include "chrome/browser/chromeos/enrollment_dialog_view.h" 17 #include "chrome/browser/chromeos/enrollment_dialog_view.h"
17 #include "chrome/browser/chromeos/options/network_config_view.h" 18 #include "chrome/browser/chromeos/options/network_config_view.h"
19 #include "chrome/browser/chromeos/system/ash_system_tray_delegate.h"
pneubeck (no reviews) 2013/06/07 12:05:47 unused?
stevenjb 2013/06/07 18:50:40 Done.
18 #include "chrome/browser/profiles/profile_manager.h" 20 #include "chrome/browser/profiles/profile_manager.h"
21 #include "chrome/browser/ui/browser_finder.h"
22 #include "chrome/browser/ui/chrome_pages.h"
19 #include "chrome/browser/ui/webui/chromeos/mobile_setup_dialog.h" 23 #include "chrome/browser/ui/webui/chromeos/mobile_setup_dialog.h"
24 #include "chrome/common/url_constants.h"
20 #include "chromeos/chromeos_switches.h" 25 #include "chromeos/chromeos_switches.h"
26 #include "content/public/browser/user_metrics.h"
21 #include "grit/generated_resources.h" 27 #include "grit/generated_resources.h"
28 #include "net/base/escape.h"
22 #include "third_party/cros_system_api/dbus/service_constants.h" 29 #include "third_party/cros_system_api/dbus/service_constants.h"
23 #include "ui/base/l10n/l10n_util.h" 30 #include "ui/base/l10n/l10n_util.h"
24 31
25 namespace chromeos { 32 namespace chromeos {
26 namespace network_connect { 33 namespace network_connect {
27 34
28 namespace { 35 namespace {
29 36
30 void DoConnect(Network* network, gfx::NativeWindow parent_window) { 37 void DoConnect(Network* network, gfx::NativeWindow parent_window) {
31 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary(); 38 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary();
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 Network* network = cros->FindNetworkByPath(service_path); 135 Network* network = cros->FindNetworkByPath(service_path);
129 if (!network) 136 if (!network)
130 return NETWORK_NOT_FOUND; 137 return NETWORK_NOT_FOUND;
131 138
132 if (network->connecting_or_connected()) 139 if (network->connecting_or_connected())
133 return CONNECT_NOT_STARTED; 140 return CONNECT_NOT_STARTED;
134 141
135 if (network->type() == TYPE_ETHERNET) 142 if (network->type() == TYPE_ETHERNET)
136 return CONNECT_NOT_STARTED; // Normally this shouldn't happen 143 return CONNECT_NOT_STARTED; // Normally this shouldn't happen
137 144
138 if (network->type() == TYPE_WIFI) { 145 if (network->type() == TYPE_WIFI || network->type() == TYPE_VPN) {
139 WifiNetwork* wifi = static_cast<WifiNetwork*>(network); 146 network->SetEnrollmentDelegate(chromeos::CreateEnrollmentDelegate(
140 wifi->SetEnrollmentDelegate( 147 parent_window, network->name(), ProfileManager::GetLastUsedProfile()));
141 chromeos::CreateEnrollmentDelegate( 148 network->AttemptConnection(base::Bind(&DoConnect, network, parent_window));
142 parent_window,
143 wifi->name(),
144 ProfileManager::GetLastUsedProfile()));
145 wifi->AttemptConnection(base::Bind(&DoConnect, wifi, parent_window));
146 return CONNECT_STARTED; 149 return CONNECT_STARTED;
147 } 150 }
148 151
149 if (network->type() == TYPE_WIMAX) { 152 if (network->type() == TYPE_WIMAX) {
150 WimaxNetwork* wimax = static_cast<WimaxNetwork*>(network); 153 WimaxNetwork* wimax = static_cast<WimaxNetwork*>(network);
151 wimax->AttemptConnection(base::Bind(&DoConnect, wimax, parent_window)); 154 wimax->AttemptConnection(base::Bind(&DoConnect, wimax, parent_window));
152 return CONNECT_STARTED; 155 return CONNECT_STARTED;
153 } 156 }
154 157
155 if (network->type() == TYPE_CELLULAR) { 158 if (network->type() == TYPE_CELLULAR) {
156 CellularNetwork* cellular = static_cast<CellularNetwork*>(network); 159 CellularNetwork* cellular = static_cast<CellularNetwork*>(network);
157 if (cellular->NeedsActivation() || cellular->out_of_credits()) { 160 if (cellular->NeedsActivation() || cellular->out_of_credits()) {
158 ActivateCellular(service_path); 161 ActivateCellular(service_path);
159 return CONNECT_STARTED; 162 return CONNECT_STARTED;
160 } 163 }
161 if (cellular->activation_state() == ACTIVATION_STATE_ACTIVATING) 164 if (cellular->activation_state() == ACTIVATION_STATE_ACTIVATING)
162 return CONNECT_NOT_STARTED; 165 return CONNECT_NOT_STARTED;
163 cros->ConnectToCellularNetwork(cellular); 166 cros->ConnectToCellularNetwork(cellular);
164 return CONNECT_STARTED; 167 return CONNECT_STARTED;
165 } 168 }
166 169
167 if (network->type() == TYPE_VPN) {
168 VirtualNetwork* vpn = static_cast<VirtualNetwork*>(network);
169 vpn->SetEnrollmentDelegate(
170 chromeos::CreateEnrollmentDelegate(
171 parent_window,
172 vpn->name(),
173 ProfileManager::GetLastUsedProfile()));
174 vpn->AttemptConnection(base::Bind(&DoConnect, vpn, parent_window));
175 return CONNECT_STARTED;
176 }
177
178 NOTREACHED(); 170 NOTREACHED();
179 return CONNECT_NOT_STARTED; 171 return CONNECT_NOT_STARTED;
180 } 172 }
181 173
174 void HandleUnconfiguredNetwork(const std::string& service_path,
175 gfx::NativeWindow parent_window) {
176 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary();
177 Network* network = cros->FindNetworkByPath(service_path);
178 if (!network) {
179 LOG(WARNING) << "Unknown network: " << service_path;
180 return;
181 }
182
183 if (network->type() == TYPE_WIFI || network->type() == TYPE_VPN) {
184 network->SetEnrollmentDelegate(chromeos::CreateEnrollmentDelegate(
185 parent_window, network->name(), ProfileManager::GetLastUsedProfile()));
186 // This will connect to the network only if the network just needs to have
187 // its certificate configured. Otherwise it will show an enrollment dialog
188 // if available, or call NetworkConfigView::Show().
189 network->AttemptConnection(
190 base::Bind(&NetworkConfigView::Show, network, parent_window));
191 return;
192 }
193
194 if (network->type() == TYPE_WIMAX) {
195 NetworkConfigView::Show(network, parent_window);
196 return;
197 }
198
199 if (network->type() == TYPE_CELLULAR) {
200 CellularNetwork* cellular = static_cast<CellularNetwork*>(network);
201 if (cellular->NeedsActivation()) {
202 ActivateCellular(service_path);
203 return;
204 } else if (cellular->out_of_credits()) {
205 ShowMobileSetup(service_path);
206 return;
207 }
208 }
209
210 // No special configure or setup for |service_path|, show the settings UI.
211 std::string page = chrome::kInternetOptionsSubPage;
212 std::string name = network->name();
213 if (name.empty() && network->type() == TYPE_ETHERNET)
214 name = l10n_util::GetStringUTF8(IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET);
215 page += base::StringPrintf(
216 "?servicePath=%s&networkType=%d&networkName=%s",
pneubeck (no reviews) 2013/06/07 12:05:47 networkName is not used by internet_detail.js and
stevenjb 2013/06/07 18:50:40 It's still referenced there. I think I will leave
217 net::EscapeUrlEncodedData(service_path, true).c_str(),
218 network->type(),
219 net::EscapeUrlEncodedData(name, false).c_str());
220 content::RecordAction(
221 content::UserMetricsAction("OpenInternetOptionsDialog"));
222 Browser* browser = chrome::FindOrCreateTabbedBrowser(
223 ProfileManager::GetDefaultProfileOrOffTheRecord(),
224 chrome::HOST_DESKTOP_TYPE_ASH);
225 chrome::ShowSettingsSubPage(browser, page);
226 }
227
182 } // namespace network_connect 228 } // namespace network_connect
183 } // namespace chromeos 229 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698