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

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

Issue 3678006: Implement action interface in network_menu.js for 'connect'. (Closed)
Patch Set: Set status for non connected networks. Created 10 years, 2 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "app/resource_bundle.h" 8 #include "app/resource_bundle.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 188
189 void WifiConfigView::FocusFirstField() { 189 void WifiConfigView::FocusFirstField() {
190 if (ssid_textfield_) 190 if (ssid_textfield_)
191 ssid_textfield_->RequestFocus(); 191 ssid_textfield_->RequestFocus();
192 else if (identity_textfield_) 192 else if (identity_textfield_)
193 identity_textfield_->RequestFocus(); 193 identity_textfield_->RequestFocus();
194 else if (passphrase_textfield_) 194 else if (passphrase_textfield_)
195 passphrase_textfield_->RequestFocus(); 195 passphrase_textfield_->RequestFocus();
196 } 196 }
197 197
198 // Parse 'path' to determine if the certificate is stored in a pkcs#11 device.
199 // flimflam recognizes the string "SETTINGS:" to specify authentication
200 // parameters. 'key_id=' indicates that the certificate is stored in a pkcs#11
201 // device. See src/third_party/flimflam/files/doc/service-api.txt.
202 static bool is_certificate_in_pkcs11(const std::string& path) {
203 static const std::string settings_string("SETTINGS:");
204 static const std::string pkcs11_key("key_id");
205 if (path.find(settings_string) == 0) {
206 std::string::size_type idx = path.find(pkcs11_key);
207 if (idx != std::string::npos)
208 idx = path.find_first_not_of(kWhitespaceASCII, idx + pkcs11_key.length());
209 if (idx != std::string::npos && path[idx] == '=')
210 return true;
211 }
212 return false;
213 }
214
215 void WifiConfigView::Init() { 198 void WifiConfigView::Init() {
216 views::GridLayout* layout = CreatePanelGridLayout(this); 199 views::GridLayout* layout = CreatePanelGridLayout(this);
217 SetLayoutManager(layout); 200 SetLayoutManager(layout);
218 201
219 int column_view_set_id = 0; 202 int column_view_set_id = 0;
220 views::ColumnSet* column_set = layout->AddColumnSet(column_view_set_id); 203 views::ColumnSet* column_set = layout->AddColumnSet(column_view_set_id);
221 // Label 204 // Label
222 column_set->AddColumn(views::GridLayout::LEADING, views::GridLayout::FILL, 1, 205 column_set->AddColumn(views::GridLayout::LEADING, views::GridLayout::FILL, 1,
223 views::GridLayout::USE_PREF, 0, 0); 206 views::GridLayout::USE_PREF, 0, 0);
224 // Textfield 207 // Textfield
(...skipping 10 matching lines...) Expand all
235 ssid_textfield_ = new views::Textfield(views::Textfield::STYLE_DEFAULT); 218 ssid_textfield_ = new views::Textfield(views::Textfield::STYLE_DEFAULT);
236 ssid_textfield_->SetController(this); 219 ssid_textfield_->SetController(this);
237 layout->AddView(ssid_textfield_); 220 layout->AddView(ssid_textfield_);
238 } else { 221 } else {
239 views::Label* label = new views::Label(ASCIIToWide(wifi_.name())); 222 views::Label* label = new views::Label(ASCIIToWide(wifi_.name()));
240 label->SetHorizontalAlignment(views::Label::ALIGN_LEFT); 223 label->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
241 layout->AddView(label); 224 layout->AddView(label);
242 } 225 }
243 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); 226 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
244 227
245 // Certificates stored in a pkcs11 device can not be browsed 228 // Loaded certificates (i.e. stored in a pkcs11 device) do not require
246 // and do not require a passphrase. 229 // a passphrase.
247 bool certificate_in_pkcs11 = false; 230 bool certificate_loaded = false;
248 231
249 // Add ID and cert password if we're using 802.1x 232 // Add ID and cert password if we're using 802.1x
250 // XXX we're cheating and assuming 802.1x means EAP-TLS - not true 233 // XXX we're cheating and assuming 802.1x means EAP-TLS - not true
251 // in general, but very common. WPA Supplicant doesn't report the 234 // in general, but very common. WPA Supplicant doesn't report the
252 // EAP type because it's unknown until the process begins, and we'd 235 // EAP type because it's unknown until the process begins, and we'd
253 // need some kind of callback. 236 // need some kind of callback.
254 if (wifi_.encrypted() && wifi_.encryption() == SECURITY_8021X) { 237 if (wifi_.encrypted() && wifi_.encryption() == SECURITY_8021X) {
255 layout->StartRow(0, column_view_set_id); 238 layout->StartRow(0, column_view_set_id);
256 layout->AddView(new views::Label(l10n_util::GetString( 239 layout->AddView(new views::Label(l10n_util::GetString(
257 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_IDENTITY))); 240 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_IDENTITY)));
258 identity_textfield_ = new views::Textfield( 241 identity_textfield_ = new views::Textfield(
259 views::Textfield::STYLE_DEFAULT); 242 views::Textfield::STYLE_DEFAULT);
260 identity_textfield_->SetController(this); 243 identity_textfield_->SetController(this);
261 if (!wifi_.identity().empty()) 244 if (!wifi_.identity().empty())
262 identity_textfield_->SetText(UTF8ToUTF16(wifi_.identity())); 245 identity_textfield_->SetText(UTF8ToUTF16(wifi_.identity()));
263 layout->AddView(identity_textfield_); 246 layout->AddView(identity_textfield_);
264 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); 247 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
265 layout->StartRow(0, column_view_set_id); 248 layout->StartRow(0, column_view_set_id);
266 layout->AddView(new views::Label(l10n_util::GetString( 249 layout->AddView(new views::Label(l10n_util::GetString(
267 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT))); 250 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT)));
268 if (!wifi_.cert_path().empty()) { 251 if (!wifi_.cert_path().empty()) {
269 certificate_path_ = wifi_.cert_path(); 252 certificate_path_ = wifi_.cert_path();
270 certificate_in_pkcs11 = is_certificate_in_pkcs11(certificate_path_); 253 certificate_loaded = wifi_.IsCertificateLoaded();
271 } 254 }
272 if (certificate_in_pkcs11) { 255 if (certificate_loaded) {
273 std::wstring label = l10n_util::GetString( 256 std::wstring label = l10n_util::GetString(
274 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_INSTALLED); 257 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_INSTALLED);
275 views::Label* cert_text = new views::Label(label); 258 views::Label* cert_text = new views::Label(label);
276 cert_text->SetHorizontalAlignment(views::Label::ALIGN_LEFT); 259 cert_text->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
277 layout->AddView(cert_text); 260 layout->AddView(cert_text);
278 } else { 261 } else {
279 std::wstring label; 262 std::wstring label;
280 if (!certificate_path_.empty()) 263 if (!certificate_path_.empty())
281 label = UTF8ToWide(certificate_path_); 264 label = UTF8ToWide(certificate_path_);
282 else 265 else
283 label = l10n_util::GetString( 266 label = l10n_util::GetString(
284 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_BUTTON); 267 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_BUTTON);
285 certificate_browse_button_ = new views::NativeButton(this, label); 268 certificate_browse_button_ = new views::NativeButton(this, label);
286 layout->AddView(certificate_browse_button_); 269 layout->AddView(certificate_browse_button_);
287 } 270 }
288 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); 271 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
289 } 272 }
290 273
291 // Add passphrase if other_network or wifi is encrypted. 274 // Add passphrase if other_network or wifi is encrypted.
292 if (other_network_ || (wifi_.encrypted() && !certificate_in_pkcs11)) { 275 if (other_network_ || (wifi_.encrypted() && !certificate_loaded)) {
293 layout->StartRow(0, column_view_set_id); 276 layout->StartRow(0, column_view_set_id);
294 int label_text_id; 277 int label_text_id;
295 if (wifi_.encryption() == SECURITY_8021X) 278 if (wifi_.encryption() == SECURITY_8021X)
296 label_text_id = 279 label_text_id =
297 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PRIVATE_KEY_PASSWORD; 280 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PRIVATE_KEY_PASSWORD;
298 else 281 else
299 label_text_id = IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PASSPHRASE; 282 label_text_id = IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PASSPHRASE;
300 layout->AddView(new views::Label(l10n_util::GetString(label_text_id))); 283 layout->AddView(new views::Label(l10n_util::GetString(label_text_id)));
301 passphrase_textfield_ = new views::Textfield( 284 passphrase_textfield_ = new views::Textfield(
302 views::Textfield::STYLE_PASSWORD); 285 views::Textfield::STYLE_PASSWORD);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 // For other network, default to autoconnect. 322 // For other network, default to autoconnect.
340 bool autoconnect = other_network_ || wifi_.auto_connect(); 323 bool autoconnect = other_network_ || wifi_.auto_connect();
341 autoconnect_checkbox_->SetChecked(autoconnect); 324 autoconnect_checkbox_->SetChecked(autoconnect);
342 layout->StartRow(0, column_view_set_id); 325 layout->StartRow(0, column_view_set_id);
343 layout->AddView(autoconnect_checkbox_, 3, 1); 326 layout->AddView(autoconnect_checkbox_, 3, 1);
344 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); 327 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
345 } 328 }
346 } 329 }
347 330
348 } // namespace chromeos 331 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698