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

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

Issue 6596064: UI for 802.1x connections. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 9 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/wifi_config_view.h" 5 #include "chrome/browser/chromeos/options/wifi_config_view.h"
6 6
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/chromeos/cros/cros_library.h" 9 #include "chrome/browser/chromeos/cros/cros_library.h"
10 #include "chrome/browser/chromeos/login/user_manager.h" 10 #include "chrome/browser/chromeos/login/user_manager.h"
(...skipping 10 matching lines...) Expand all
21 #include "views/layout/grid_layout.h" 21 #include "views/layout/grid_layout.h"
22 #include "views/layout/layout_constants.h" 22 #include "views/layout/layout_constants.h"
23 #include "views/window/window.h" 23 #include "views/window/window.h"
24 24
25 namespace chromeos { 25 namespace chromeos {
26 26
27 // The width of the password field. 27 // The width of the password field.
28 const int kPasswordWidth = 150; 28 const int kPasswordWidth = 150;
29 29
30 enum SecurityComboboxIndex { 30 enum SecurityComboboxIndex {
31 INDEX_NONE = 0, 31 SECURITY_INDEX_NONE = 0,
32 INDEX_WEP = 1, 32 SECURITY_INDEX_WEP = 1,
33 INDEX_WPA = 2, 33 SECURITY_INDEX_WPA = 2,
34 INDEX_RSN = 3, 34 SECURITY_INDEX_RSN = 3,
35 INDEX_COUNT = 4 35 SECURITY_INDEX_COUNT = 4
36 }; 36 };
37 37
38 int WifiConfigView::SecurityComboboxModel::GetItemCount() { 38 int WifiConfigView::SecurityComboboxModel::GetItemCount() {
39 return INDEX_COUNT; 39 return SECURITY_INDEX_COUNT;
40 } 40 }
41 41
42 string16 WifiConfigView::SecurityComboboxModel::GetItemAt(int index) { 42 string16 WifiConfigView::SecurityComboboxModel::GetItemAt(int index) {
43 if (index == INDEX_NONE) 43 if (index == SECURITY_INDEX_NONE)
44 return l10n_util::GetStringUTF16( 44 return l10n_util::GetStringUTF16(
45 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SECURITY_NONE); 45 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SECURITY_NONE);
46 else if (index == INDEX_WEP) 46 else if (index == SECURITY_INDEX_WEP)
47 return l10n_util::GetStringUTF16( 47 return l10n_util::GetStringUTF16(
48 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SECURITY_WEP); 48 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SECURITY_WEP);
49 else if (index == INDEX_WPA) 49 else if (index == SECURITY_INDEX_WPA)
50 return l10n_util::GetStringUTF16( 50 return l10n_util::GetStringUTF16(
51 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SECURITY_WPA); 51 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SECURITY_WPA);
52 else if (index == INDEX_RSN) 52 else if (index == SECURITY_INDEX_RSN)
53 return l10n_util::GetStringUTF16( 53 return l10n_util::GetStringUTF16(
54 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SECURITY_RSN); 54 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SECURITY_RSN);
55 NOTREACHED(); 55 NOTREACHED();
56 return string16(); 56 return string16();
57 } 57 }
58 58
59 enum EAPMethodComboboxIndex {
60 EAP_METHOD_INDEX_NONE = 0,
61 EAP_METHOD_INDEX_PEAP = 1,
62 EAP_METHOD_INDEX_TLS = 2,
63 EAP_METHOD_INDEX_TTLS = 3,
64 EAP_METHOD_INDEX_LEAP = 4,
65 EAP_METHOD_INDEX_COUNT = 5
66 };
67
68 int WifiConfigView::EAPMethodComboboxModel::GetItemCount() {
69 return EAP_METHOD_INDEX_COUNT;
70
71 }
72
73 string16 WifiConfigView::EAPMethodComboboxModel::GetItemAt(int index) {
74 if (index == EAP_METHOD_INDEX_NONE)
75 return l10n_util::GetStringUTF16(
76 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_EAP_METHOD_NONE);
77 else if (index == EAP_METHOD_INDEX_PEAP)
78 return l10n_util::GetStringUTF16(
79 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_EAP_METHOD_PEAP);
80 else if (index == EAP_METHOD_INDEX_TLS)
81 return l10n_util::GetStringUTF16(
82 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_EAP_METHOD_TLS);
83 else if (index == EAP_METHOD_INDEX_TTLS)
84 return l10n_util::GetStringUTF16(
85 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_EAP_METHOD_TTLS);
86 else if (index == EAP_METHOD_INDEX_LEAP)
87 return l10n_util::GetStringUTF16(
88 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_EAP_METHOD_LEAP);
89 NOTREACHED();
90 return string16();
91 }
92
93 enum Phase2AuthComboboxIndex {
94 PHASE_2_AUTH_INDEX_AUTO = 0, // LEAP, EAP-TLS have only this auth.
95 PHASE_2_AUTH_INDEX_MD5 = 1,
96 PHASE_2_AUTH_INDEX_MSCHAPV2 = 2, // PEAP has up to this auth.
97 PHASE_2_AUTH_INDEX_MSCHAP = 3,
98 PHASE_2_AUTH_INDEX_PAP = 4,
99 PHASE_2_AUTH_INDEX_CHAP = 5, // EAP-TTLS has up to this auth.
100 PHASE_2_AUTH_INDEX_COUNT = 6
101 };
102
103 int WifiConfigView::Phase2AuthComboboxModel::GetItemCount() {
104 switch (eap_method_combobox_->selected_item()) {
105 case EAP_METHOD_INDEX_NONE:
106 case EAP_METHOD_INDEX_TLS:
107 case EAP_METHOD_INDEX_LEAP:
108 return PHASE_2_AUTH_INDEX_AUTO + 1;
109 case EAP_METHOD_INDEX_PEAP:
110 return PHASE_2_AUTH_INDEX_MSCHAPV2 + 1;
111 case EAP_METHOD_INDEX_TTLS:
112 return PHASE_2_AUTH_INDEX_CHAP + 1;
113 }
114 NOTREACHED();
115 return 0;
116 }
117
118 string16 WifiConfigView::Phase2AuthComboboxModel::GetItemAt(int index) {
119 if (index == PHASE_2_AUTH_INDEX_AUTO)
120 return l10n_util::GetStringUTF16(
121 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PHASE_2_AUTH_AUTO);
122 else if (index == PHASE_2_AUTH_INDEX_MD5)
123 return l10n_util::GetStringUTF16(
124 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PHASE_2_AUTH_MD5);
125 else if (index == PHASE_2_AUTH_INDEX_MSCHAPV2)
126 return l10n_util::GetStringUTF16(
127 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PHASE_2_AUTH_MSCHAPV2);
128 else if (index == PHASE_2_AUTH_INDEX_MSCHAP)
129 return l10n_util::GetStringUTF16(
130 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PHASE_2_AUTH_MSCHAP);
131 else if (index == PHASE_2_AUTH_INDEX_PAP)
132 return l10n_util::GetStringUTF16(
133 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PHASE_2_AUTH_PAP);
134 else if (index == PHASE_2_AUTH_INDEX_CHAP)
135 return l10n_util::GetStringUTF16(
136 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PHASE_2_AUTH_CHAP);
137 NOTREACHED();
138 return string16();
139 }
140
59 WifiConfigView::WifiConfigView(NetworkConfigView* parent, 141 WifiConfigView::WifiConfigView(NetworkConfigView* parent,
60 const WifiNetwork* wifi) 142 const WifiNetwork* wifi)
61 : parent_(parent), 143 : parent_(parent),
62 can_login_(false), 144 is_8021x_(false),
63 wifi_(new WifiNetwork(*wifi)), 145 wifi_(new WifiNetwork(*wifi)),
64 ssid_textfield_(NULL), 146 ssid_textfield_(NULL),
147 eap_method_combobox_(NULL),
148 phase_2_auth_combobox_(NULL),
65 identity_textfield_(NULL), 149 identity_textfield_(NULL),
150 identity_anonymous_textfield_(NULL),
66 certificate_browse_button_(NULL), 151 certificate_browse_button_(NULL),
67 certificate_path_(), 152 certificate_path_(),
68 security_combobox_(NULL), 153 security_combobox_(NULL),
69 passphrase_textfield_(NULL), 154 passphrase_textfield_(NULL),
70 passphrase_visible_button_(NULL), 155 passphrase_visible_button_(NULL),
71 error_label_(NULL) { 156 error_label_(NULL) {
72 Init(); 157 Init();
73 } 158 }
74 159
75 WifiConfigView::WifiConfigView(NetworkConfigView* parent) 160 WifiConfigView::WifiConfigView(NetworkConfigView* parent)
76 : parent_(parent), 161 : parent_(parent),
77 can_login_(false), 162 is_8021x_(false),
78 ssid_textfield_(NULL), 163 ssid_textfield_(NULL),
164 eap_method_combobox_(NULL),
165 phase_2_auth_combobox_(NULL),
79 identity_textfield_(NULL), 166 identity_textfield_(NULL),
167 identity_anonymous_textfield_(NULL),
80 certificate_browse_button_(NULL), 168 certificate_browse_button_(NULL),
81 certificate_path_(), 169 certificate_path_(),
82 security_combobox_(NULL), 170 security_combobox_(NULL),
83 passphrase_textfield_(NULL), 171 passphrase_textfield_(NULL),
84 passphrase_visible_button_(NULL), 172 passphrase_visible_button_(NULL),
85 error_label_(NULL) { 173 error_label_(NULL) {
86 Init(); 174 Init();
87 } 175 }
88 176
89 WifiConfigView::~WifiConfigView() { 177 WifiConfigView::~WifiConfigView() {
90 } 178 }
91 179
92 void WifiConfigView::UpdateCanLogin(void) { 180 bool WifiConfigView::CanLogin() {
93 static const size_t kMinWirelessPasswordLen = 5; 181 static const size_t kMinWirelessPasswordLen = 5;
94 182
95 bool can_login = true;
96 if (!wifi_.get()) { 183 if (!wifi_.get()) {
97 // Enforce ssid is non empty. 184 // Enforce ssid is non empty.
185 if (GetSSID().empty())
186 return false;
187
98 // If security is not none, also enforce passphrase is non empty. 188 // If security is not none, also enforce passphrase is non empty.
99 can_login = !GetSSID().empty() && 189 if (security_combobox_->selected_item() != SECURITY_INDEX_NONE &&
100 (security_combobox_->selected_item() == INDEX_NONE || 190 passphrase_textfield_->text().length() < kMinWirelessPasswordLen)
101 passphrase_textfield_->text().length() >= kMinWirelessPasswordLen); 191 return false;
102 } else { 192 } else {
103 // Connecting to an encrypted network 193 if (is_8021x_) {
104 if (passphrase_textfield_ != NULL) { 194 // Make sure the EAP method is set
105 // if the network requires a passphrase, make sure it is non empty. 195 if (eap_method_combobox_->selected_item() == EAP_METHOD_INDEX_NONE)
106 can_login &= 196 return false;
107 passphrase_textfield_->text().length() >= kMinWirelessPasswordLen; 197
108 }
109 if (identity_textfield_ != NULL) {
110 // If we have an identity field, we can login if we have a non empty 198 // If we have an identity field, we can login if we have a non empty
111 // identity and a certificate path 199 // identity and a certificate path
112 can_login &= !identity_textfield_->text().empty() && 200 if (identity_textfield_ != NULL &&
113 !certificate_path_.empty(); 201 (identity_textfield_->text().empty() || certificate_path_.empty()))
202 return false;
114 } 203 }
204
205 // if the network requires a passphrase, make sure it is the right length.
206 if (passphrase_textfield_ != NULL &&
207 passphrase_textfield_->text().length() < kMinWirelessPasswordLen)
208 return false;
115 } 209 }
210 return true;
211 }
116 212
117 // Update the login button enable/disable state if can_login_ changes. 213 void WifiConfigView::UpdateCanLogin() {
118 if (can_login != can_login_) { 214 parent_->GetDialogClientView()->UpdateDialogButtons();
119 can_login_ = can_login;
120 parent_->GetDialogClientView()->UpdateDialogButtons();
121 }
122 } 215 }
123 216
124 void WifiConfigView::UpdateErrorLabel(bool failed) { 217 void WifiConfigView::UpdateErrorLabel(bool failed) {
125 static const int kNoError = -1; 218 static const int kNoError = -1;
126 int id = kNoError; 219 int id = kNoError;
127 if (wifi_.get()) { 220 if (wifi_.get()) {
128 // Right now, only displaying bad_passphrase and bad_wepkey errors. 221 // Right now, only displaying bad_passphrase and bad_wepkey errors.
129 if (wifi_->error() == ERROR_BAD_PASSPHRASE) 222 if (wifi_->error() == ERROR_BAD_PASSPHRASE)
130 id = IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_BAD_PASSPHRASE; 223 id = IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_BAD_PASSPHRASE;
131 else if (wifi_->error() == ERROR_BAD_WEPKEY) 224 else if (wifi_->error() == ERROR_BAD_WEPKEY)
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 NULL : 266 NULL :
174 parent_->GetNativeWindow(), 267 parent_->GetNativeWindow(),
175 NULL); 268 NULL);
176 } else { 269 } else {
177 NOTREACHED(); 270 NOTREACHED();
178 } 271 }
179 } 272 }
180 273
181 void WifiConfigView::ItemChanged(views::Combobox* combo_box, 274 void WifiConfigView::ItemChanged(views::Combobox* combo_box,
182 int prev_index, int new_index) { 275 int prev_index, int new_index) {
183 // If changed to no security, then disable combobox and clear it. 276 if (new_index == prev_index)
184 // Otherwise, enable it. Also, update can login. 277 return;
185 if (new_index == INDEX_NONE) { 278 if (combo_box == security_combobox_) {
186 passphrase_textfield_->SetEnabled(false); 279 // If changed to no security, then disable combobox and clear it.
187 passphrase_textfield_->SetText(string16()); 280 // Otherwise, enable it. Also, update can login.
188 } else { 281 if (new_index == SECURITY_INDEX_NONE) {
189 passphrase_textfield_->SetEnabled(true); 282 passphrase_textfield_->SetEnabled(false);
283 passphrase_textfield_->SetText(string16());
284 } else {
285 passphrase_textfield_->SetEnabled(true);
286 }
287 } else if (combo_box == eap_method_combobox_) {
288 // If EAP method changes, the phase 2 auth choices may have changed also.
289 phase_2_auth_combobox_->ModelChanged();
290 phase_2_auth_combobox_->SetSelectedItem(0);
291 phase_2_auth_combobox_->SetEnabled(
292 phase_2_auth_combobox_->model()->GetItemCount() > 1);
293
294 // No password for EAP-TLS
295 if (eap_method_combobox_->selected_item() == EAP_METHOD_INDEX_TLS) {
296 passphrase_textfield_->SetEnabled(false);
297 passphrase_textfield_->SetText(string16());
298 } else {
299 passphrase_textfield_->SetEnabled(true);
300 }
301
302 // No client certs for EAP-TTLS, PEAP, or LEAP
303
304 // No server certs for LEAP
305
306 // No anonymous identity if no phase 2 auth.
307 if (phase_2_auth_combobox_->model()->GetItemCount() > 1) {
308 identity_anonymous_textfield_->SetEnabled(true);
309 } else {
310 identity_anonymous_textfield_->SetEnabled(false);
311 identity_anonymous_textfield_->SetText(string16());
312 }
190 } 313 }
191 UpdateCanLogin(); 314 UpdateCanLogin();
192 } 315 }
193 316
194 void WifiConfigView::FileSelected(const FilePath& path, 317 void WifiConfigView::FileSelected(const FilePath& path,
195 int index, void* params) { 318 int index, void* params) {
196 certificate_path_ = path.value(); 319 certificate_path_ = path.value();
197 if (certificate_browse_button_) { 320 if (certificate_browse_button_) {
198 certificate_browse_button_->SetLabel( 321 certificate_browse_button_->SetLabel(
199 UTF16ToWide(path.BaseName().LossyDisplayName())); 322 UTF16ToWide(path.BaseName().LossyDisplayName()));
200 } 323 }
201 UpdateCanLogin(); // TODO(njw) Check if the passphrase decrypts the key. 324 UpdateCanLogin(); // TODO(njw) Check if the passphrase decrypts the key.
202 } 325 }
203 326
204 bool WifiConfigView::Login() { 327 bool WifiConfigView::Login() {
205 std::string identity_string; 328 std::string identity_string;
206 if (identity_textfield_ != NULL) { 329 if (identity_textfield_ != NULL) {
207 identity_string = UTF16ToUTF8(identity_textfield_->text()); 330 identity_string = UTF16ToUTF8(identity_textfield_->text());
208 } 331 }
209 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary(); 332 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary();
210 bool connected = false; 333 bool connected = false;
211 if (!wifi_.get()) { 334 if (!wifi_.get()) {
212 ConnectionSecurity sec = SECURITY_UNKNOWN; 335 ConnectionSecurity sec = SECURITY_UNKNOWN;
213 int index = security_combobox_->selected_item(); 336 int index = security_combobox_->selected_item();
214 if (index == INDEX_NONE) 337 if (index == SECURITY_INDEX_NONE)
215 sec = SECURITY_NONE; 338 sec = SECURITY_NONE;
216 else if (index == INDEX_WEP) 339 else if (index == SECURITY_INDEX_WEP)
217 sec = SECURITY_WEP; 340 sec = SECURITY_WEP;
218 else if (index == INDEX_WPA) 341 else if (index == SECURITY_INDEX_WPA)
219 sec = SECURITY_WPA; 342 sec = SECURITY_WPA;
220 else if (index == INDEX_RSN) 343 else if (index == SECURITY_INDEX_RSN)
221 sec = SECURITY_RSN; 344 sec = SECURITY_RSN;
222 connected = cros->ConnectToWifiNetwork( 345 connected = cros->ConnectToWifiNetwork(
223 sec, GetSSID(), GetPassphrase(), 346 sec, GetSSID(), GetPassphrase(),
224 identity_string, certificate_path_, true); 347 identity_string, certificate_path_, true);
225 } else { 348 } else {
226 Save(); 349 Save();
227 connected = cros->ConnectToWifiNetwork( 350 connected = cros->ConnectToWifiNetwork(
228 wifi_.get(), GetPassphrase(), 351 wifi_.get(), GetPassphrase(),
229 identity_string, certificate_path_); 352 identity_string, certificate_path_);
230 } 353 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 return result; 399 return result;
277 } 400 }
278 401
279 const std::string WifiConfigView::GetPassphrase() const { 402 const std::string WifiConfigView::GetPassphrase() const {
280 std::string result; 403 std::string result;
281 if (passphrase_textfield_ != NULL) 404 if (passphrase_textfield_ != NULL)
282 result = UTF16ToUTF8(passphrase_textfield_->text()); 405 result = UTF16ToUTF8(passphrase_textfield_->text());
283 return result; 406 return result;
284 } 407 }
285 408
409 // This will initialize the view depending on if we have a wifi network or not.
410 // And if we are doing simple password encyption or the more complicated
411 // 802.1x encryption.
412 // If we are creating the "Join other network..." dialog, we will allow user
413 // to enter the data. And if they select the 802.1x encryption, we will show
414 // the 802.1x fields.
286 void WifiConfigView::Init() { 415 void WifiConfigView::Init() {
287 views::GridLayout* layout = views::GridLayout::CreatePanel(this); 416 views::GridLayout* layout = views::GridLayout::CreatePanel(this);
288 SetLayoutManager(layout); 417 SetLayoutManager(layout);
289 418
290 int column_view_set_id = 0; 419 int column_view_set_id = 0;
291 views::ColumnSet* column_set = layout->AddColumnSet(column_view_set_id); 420 views::ColumnSet* column_set = layout->AddColumnSet(column_view_set_id);
292 // Label 421 // Label
293 column_set->AddColumn(views::GridLayout::LEADING, views::GridLayout::FILL, 1, 422 column_set->AddColumn(views::GridLayout::LEADING, views::GridLayout::FILL, 1,
294 views::GridLayout::USE_PREF, 0, 0); 423 views::GridLayout::USE_PREF, 0, 0);
295 // Textfield 424 // Textfield
(...skipping 11 matching lines...) Expand all
307 ssid_textfield_ = new views::Textfield(views::Textfield::STYLE_DEFAULT); 436 ssid_textfield_ = new views::Textfield(views::Textfield::STYLE_DEFAULT);
308 ssid_textfield_->SetController(this); 437 ssid_textfield_->SetController(this);
309 layout->AddView(ssid_textfield_); 438 layout->AddView(ssid_textfield_);
310 } else { 439 } else {
311 views::Label* label = new views::Label(ASCIIToWide(wifi_->name())); 440 views::Label* label = new views::Label(ASCIIToWide(wifi_->name()));
312 label->SetHorizontalAlignment(views::Label::ALIGN_LEFT); 441 label->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
313 layout->AddView(label); 442 layout->AddView(label);
314 } 443 }
315 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); 444 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
316 445
446 // Security select
447 if (!wifi_.get()) {
448 layout->StartRow(0, column_view_set_id);
449 layout->AddView(new views::Label(UTF16ToWide(l10n_util::GetStringUTF16(
450 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SECURITY))));
451 security_combobox_ = new views::Combobox(new SecurityComboboxModel());
452 security_combobox_->set_listener(this);
453 layout->AddView(security_combobox_);
454 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
455 }
456
317 // Certificate input 457 // Certificate input
318 // Loaded certificates (i.e. stored in a pkcs11 device) do not require 458 // Loaded certificates (i.e. stored in a pkcs11 device) do not require
319 // a passphrase. 459 // a passphrase.
320 bool certificate_loaded = false; 460 bool certificate_loaded = false;
321 461
322 // Add ID and cert password if we're using 802.1x 462 // Add ID and cert password if we're using 802.1x
323 // XXX we're cheating and assuming 802.1x means EAP-TLS - not true 463 // XXX we're cheating and assuming 802.1x means EAP-TLS - not true
324 // in general, but very common. WPA Supplicant doesn't report the 464 // in general, but very common. WPA Supplicant doesn't report the
325 // EAP type because it's unknown until the process begins, and we'd 465 // EAP type because it's unknown until the process begins, and we'd
326 // need some kind of callback. 466 // need some kind of callback.
327 if (wifi_.get() && wifi_->encrypted() && 467 is_8021x_ = wifi_.get() && wifi_->encrypted() &&
328 wifi_->encryption() == SECURITY_8021X) { 468 wifi_->encryption() == SECURITY_8021X;
469 if (is_8021x_) {
Charlie Lee 2011/03/04 01:27:23 This code is actually not live right now. Because
470 // EAP Method
329 layout->StartRow(0, column_view_set_id); 471 layout->StartRow(0, column_view_set_id);
330 layout->AddView(new views::Label(UTF16ToWide(l10n_util::GetStringUTF16( 472 layout->AddView(new views::Label(UTF16ToWide(l10n_util::GetStringUTF16(
331 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_IDENTITY)))); 473 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_EAP_METHOD))));
332 identity_textfield_ = new views::Textfield( 474 eap_method_combobox_ = new views::Combobox(new EAPMethodComboboxModel());
333 views::Textfield::STYLE_DEFAULT); 475 eap_method_combobox_->set_listener(this);
334 identity_textfield_->SetController(this); 476 layout->AddView(eap_method_combobox_);
335 if (!wifi_->identity().empty())
336 identity_textfield_->SetText(UTF8ToUTF16(wifi_->identity()));
337 layout->AddView(identity_textfield_);
338 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); 477 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
478
479 // Phase 2 Authentication
480 layout->StartRow(0, column_view_set_id);
481 layout->AddView(new views::Label(UTF16ToWide(l10n_util::GetStringUTF16(
482 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PHASE_2_AUTH))));
483 phase_2_auth_combobox_ = new views::Combobox(
484 new Phase2AuthComboboxModel(eap_method_combobox_));
485 phase_2_auth_combobox_->SetEnabled(false);
486 phase_2_auth_combobox_->set_listener(this);
487 layout->AddView(phase_2_auth_combobox_);
488 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
489
490 // Certificate
339 layout->StartRow(0, column_view_set_id); 491 layout->StartRow(0, column_view_set_id);
340 layout->AddView(new views::Label(UTF16ToWide(l10n_util::GetStringUTF16( 492 layout->AddView(new views::Label(UTF16ToWide(l10n_util::GetStringUTF16(
341 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT)))); 493 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT))));
342 if (!wifi_->cert_path().empty()) { 494 if (!wifi_->cert_path().empty()) {
343 certificate_path_ = wifi_->cert_path(); 495 certificate_path_ = wifi_->cert_path();
344 certificate_loaded = wifi_->IsCertificateLoaded(); 496 certificate_loaded = wifi_->IsCertificateLoaded();
345 } 497 }
346 if (certificate_loaded) { 498 if (certificate_loaded) {
347 std::wstring label = UTF16ToWide(l10n_util::GetStringUTF16( 499 std::wstring label = UTF16ToWide(l10n_util::GetStringUTF16(
348 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_INSTALLED)); 500 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_INSTALLED));
349 views::Label* cert_text = new views::Label(label); 501 views::Label* cert_text = new views::Label(label);
350 cert_text->SetHorizontalAlignment(views::Label::ALIGN_LEFT); 502 cert_text->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
351 layout->AddView(cert_text); 503 layout->AddView(cert_text);
352 } else { 504 } else {
353 std::wstring label; 505 std::wstring label;
354 if (!certificate_path_.empty()) 506 if (!certificate_path_.empty())
355 label = UTF8ToWide(certificate_path_); 507 label = UTF8ToWide(certificate_path_);
356 else 508 else
357 label = UTF16ToWide(l10n_util::GetStringUTF16( 509 label = UTF16ToWide(l10n_util::GetStringUTF16(
358 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_BUTTON)); 510 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_BUTTON));
359 certificate_browse_button_ = new views::NativeButton(this, label); 511 certificate_browse_button_ = new views::NativeButton(this, label);
360 layout->AddView(certificate_browse_button_); 512 layout->AddView(certificate_browse_button_);
361 } 513 }
362 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); 514 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
363 }
364 515
365 // Security select 516 // Identity
366 if (!wifi_.get()) {
367 layout->StartRow(0, column_view_set_id); 517 layout->StartRow(0, column_view_set_id);
368 layout->AddView(new views::Label(UTF16ToWide(l10n_util::GetStringUTF16( 518 layout->AddView(new views::Label(UTF16ToWide(l10n_util::GetStringUTF16(
369 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SECURITY)))); 519 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_IDENTITY))));
370 security_combobox_ = new views::Combobox(new SecurityComboboxModel()); 520 identity_textfield_ = new views::Textfield(
371 security_combobox_->set_listener(this); 521 views::Textfield::STYLE_DEFAULT);
372 layout->AddView(security_combobox_); 522 identity_textfield_->SetController(this);
523 if (!wifi_->identity().empty())
524 identity_textfield_->SetText(UTF8ToUTF16(wifi_->identity()));
525 layout->AddView(identity_textfield_);
526 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
527
528 // Anonymous Identity
529 layout->StartRow(0, column_view_set_id);
530 layout->AddView(new views::Label(UTF16ToWide(l10n_util::GetStringUTF16(
531 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_IDENTITY_ANONYMOUS))));
532 identity_anonymous_textfield_ = new views::Textfield(
533 views::Textfield::STYLE_DEFAULT);
534 identity_anonymous_textfield_->SetEnabled(false);
535 identity_anonymous_textfield_->SetController(this);
536 layout->AddView(identity_anonymous_textfield_);
373 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); 537 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
374 } 538 }
375 539
376 // Passphrase input 540 // Passphrase input
377 layout->StartRow(0, column_view_set_id); 541 layout->StartRow(0, column_view_set_id);
378 int label_text_id; 542 int label_text_id;
379 if (wifi_.get() && wifi_->encryption() == SECURITY_8021X) { 543 if (is_8021x_)
380 label_text_id = 544 label_text_id = IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PRIVATE_KEY_PASSWORD;
381 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PRIVATE_KEY_PASSWORD; 545 else
382 } else {
383 label_text_id = IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PASSPHRASE; 546 label_text_id = IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PASSPHRASE;
384 }
385 layout->AddView(new views::Label( 547 layout->AddView(new views::Label(
386 UTF16ToWide(l10n_util::GetStringUTF16(label_text_id)))); 548 UTF16ToWide(l10n_util::GetStringUTF16(label_text_id))));
387 passphrase_textfield_ = new views::Textfield( 549 passphrase_textfield_ = new views::Textfield(
388 views::Textfield::STYLE_PASSWORD); 550 views::Textfield::STYLE_PASSWORD);
389 passphrase_textfield_->SetController(this); 551 passphrase_textfield_->SetController(this);
390 if (wifi_.get() && !wifi_->passphrase().empty()) 552 if (wifi_.get() && !wifi_->passphrase().empty())
391 passphrase_textfield_->SetText(UTF8ToUTF16(wifi_->passphrase())); 553 passphrase_textfield_->SetText(UTF8ToUTF16(wifi_->passphrase()));
392 // Disable passphrase input initially for other network. 554 // Disable passphrase input initially for other network.
393 if (!wifi_.get()) 555 if (!wifi_.get())
394 passphrase_textfield_->SetEnabled(false); 556 passphrase_textfield_->SetEnabled(false);
395 layout->AddView(passphrase_textfield_); 557 layout->AddView(passphrase_textfield_);
396 // Password visible button. 558 // Password visible button.
397 passphrase_visible_button_ = new views::ImageButton(this); 559 passphrase_visible_button_ = new views::ImageButton(this);
398 passphrase_visible_button_->SetImage( 560 passphrase_visible_button_->SetImage(
399 views::ImageButton::BS_NORMAL, 561 views::ImageButton::BS_NORMAL,
400 ResourceBundle::GetSharedInstance(). 562 ResourceBundle::GetSharedInstance().
401 GetBitmapNamed(IDR_STATUSBAR_NETWORK_SECURE)); 563 GetBitmapNamed(IDR_STATUSBAR_NETWORK_SECURE));
402 passphrase_visible_button_->SetImageAlignment( 564 passphrase_visible_button_->SetImageAlignment(
403 views::ImageButton::ALIGN_CENTER, views::ImageButton::ALIGN_MIDDLE); 565 views::ImageButton::ALIGN_CENTER, views::ImageButton::ALIGN_MIDDLE);
404 layout->AddView(passphrase_visible_button_); 566 layout->AddView(passphrase_visible_button_);
405 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); 567 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
406 568
407 // Create an error label. 569 // Create an error label.
408 layout->StartRow(0, column_view_set_id); 570 layout->StartRow(0, column_view_set_id);
409 layout->SkipColumns(1); 571 layout->SkipColumns(1);
410 error_label_ = new views::Label(); 572 error_label_ = new views::Label();
411 error_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); 573 error_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
412 error_label_->SetColor(SK_ColorRED); 574 error_label_->SetColor(SK_ColorRED);
413 layout->AddView(error_label_); 575 layout->AddView(error_label_);
414 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); 576
415 // Set or hide the error text. 577 // Set or hide the error text.
416 UpdateErrorLabel(false); 578 UpdateErrorLabel(false);
417 } 579 }
418 580
419 } // namespace chromeos 581 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698