OLD | NEW |
1 // Copyright (c) 2009 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/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/browser/chromeos/cros/cros_library.h" | 10 #include "chrome/browser/chromeos/cros/cros_library.h" |
11 #include "chrome/browser/chromeos/options/network_config_view.h" | 11 #include "chrome/browser/chromeos/options/network_config_view.h" |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 } | 122 } |
123 return true; | 123 return true; |
124 } | 124 } |
125 | 125 |
126 bool WifiConfigView::Save() { | 126 bool WifiConfigView::Save() { |
127 // Save password and auto-connect here. | 127 // Save password and auto-connect here. |
128 if (!other_network_) { | 128 if (!other_network_) { |
129 bool changed = false; | 129 bool changed = false; |
130 | 130 |
131 bool auto_connect = autoconnect_checkbox_->checked(); | 131 bool auto_connect = autoconnect_checkbox_->checked(); |
132 if (auto_connect != wifi_.auto_connect) { | 132 if (auto_connect != wifi_.auto_connect()) { |
133 wifi_.auto_connect = auto_connect; | 133 wifi_.set_auto_connect(auto_connect); |
134 changed = true; | 134 changed = true; |
135 } | 135 } |
136 | 136 |
137 if (passphrase_textfield_) { | 137 if (passphrase_textfield_) { |
138 const std::string& passphrase = | 138 const std::string& passphrase = |
139 UTF16ToUTF8(passphrase_textfield_->text()); | 139 UTF16ToUTF8(passphrase_textfield_->text()); |
140 if (passphrase != wifi_.passphrase) { | 140 if (passphrase != wifi_.passphrase()) { |
141 wifi_.passphrase = passphrase; | 141 wifi_.set_passphrase(passphrase); |
142 changed = true; | 142 changed = true; |
143 } | 143 } |
144 } | 144 } |
145 | 145 |
146 if (changed) | 146 if (changed) |
147 CrosLibrary::Get()->GetNetworkLibrary()->SaveWifiNetwork(wifi_); | 147 CrosLibrary::Get()->GetNetworkLibrary()->SaveWifiNetwork(wifi_); |
148 } | 148 } |
149 return true; | 149 return true; |
150 } | 150 } |
151 | 151 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 views::GridLayout::USE_PREF, 0, 0); | 183 views::GridLayout::USE_PREF, 0, 0); |
184 | 184 |
185 layout->StartRow(0, column_view_set_id); | 185 layout->StartRow(0, column_view_set_id); |
186 layout->AddView(new views::Label(l10n_util::GetString( | 186 layout->AddView(new views::Label(l10n_util::GetString( |
187 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SSID))); | 187 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SSID))); |
188 if (other_network_) { | 188 if (other_network_) { |
189 ssid_textfield_ = new views::Textfield(views::Textfield::STYLE_DEFAULT); | 189 ssid_textfield_ = new views::Textfield(views::Textfield::STYLE_DEFAULT); |
190 ssid_textfield_->SetController(this); | 190 ssid_textfield_->SetController(this); |
191 layout->AddView(ssid_textfield_); | 191 layout->AddView(ssid_textfield_); |
192 } else { | 192 } else { |
193 views::Label* label = new views::Label(ASCIIToWide(wifi_.ssid)); | 193 views::Label* label = new views::Label(ASCIIToWide(wifi_.name())); |
194 label->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 194 label->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
195 layout->AddView(label); | 195 layout->AddView(label); |
196 } | 196 } |
197 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); | 197 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); |
198 | 198 |
199 // Add ID and cert password if we're using 802.1x | 199 // Add ID and cert password if we're using 802.1x |
200 // XXX we're cheating and assuming 802.1x means EAP-TLS - not true | 200 // XXX we're cheating and assuming 802.1x means EAP-TLS - not true |
201 // in general, but very common. WPA Supplicant doesn't report the | 201 // in general, but very common. WPA Supplicant doesn't report the |
202 // EAP type because it's unknown until the process begins, and we'd | 202 // EAP type because it's unknown until the process begins, and we'd |
203 // need some kind of callback. | 203 // need some kind of callback. |
204 if (wifi_.encrypted && wifi_.encryption == SECURITY_8021X) { | 204 if (wifi_.encrypted() && wifi_.encryption() == SECURITY_8021X) { |
205 layout->StartRow(0, column_view_set_id); | 205 layout->StartRow(0, column_view_set_id); |
206 layout->AddView(new views::Label(l10n_util::GetString( | 206 layout->AddView(new views::Label(l10n_util::GetString( |
207 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_IDENTITY))); | 207 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_IDENTITY))); |
208 identity_textfield_ = new views::Textfield( | 208 identity_textfield_ = new views::Textfield( |
209 views::Textfield::STYLE_DEFAULT); | 209 views::Textfield::STYLE_DEFAULT); |
210 identity_textfield_->SetController(this); | 210 identity_textfield_->SetController(this); |
211 layout->AddView(identity_textfield_); | 211 layout->AddView(identity_textfield_); |
212 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); | 212 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); |
213 layout->StartRow(0, column_view_set_id); | 213 layout->StartRow(0, column_view_set_id); |
214 layout->AddView(new views::Label(l10n_util::GetString( | 214 layout->AddView(new views::Label(l10n_util::GetString( |
215 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT))); | 215 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT))); |
216 certificate_browse_button_ = new views::NativeButton(this, | 216 certificate_browse_button_ = new views::NativeButton(this, |
217 l10n_util::GetString( | 217 l10n_util::GetString( |
218 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_BUTTON)); | 218 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_BUTTON)); |
219 layout->AddView(certificate_browse_button_); | 219 layout->AddView(certificate_browse_button_); |
220 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); | 220 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); |
221 } | 221 } |
222 | 222 |
223 // Add passphrase if other_network or wifi is encrypted. | 223 // Add passphrase if other_network or wifi is encrypted. |
224 if (other_network_ || wifi_.encrypted) { | 224 if (other_network_ || wifi_.encrypted()) { |
225 layout->StartRow(0, column_view_set_id); | 225 layout->StartRow(0, column_view_set_id); |
226 int label_text_id; | 226 int label_text_id; |
227 if (wifi_.encryption == SECURITY_8021X) | 227 if (wifi_.encryption() == SECURITY_8021X) |
228 label_text_id = IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT; | 228 label_text_id = IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT; |
229 else | 229 else |
230 label_text_id = IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PASSPHRASE; | 230 label_text_id = IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PASSPHRASE; |
231 layout->AddView(new views::Label(l10n_util::GetString(label_text_id))); | 231 layout->AddView(new views::Label(l10n_util::GetString(label_text_id))); |
232 passphrase_textfield_ = new views::Textfield( | 232 passphrase_textfield_ = new views::Textfield( |
233 views::Textfield::STYLE_PASSWORD); | 233 views::Textfield::STYLE_PASSWORD); |
234 passphrase_textfield_->SetController(this); | 234 passphrase_textfield_->SetController(this); |
235 if (!wifi_.passphrase.empty()) | 235 if (!wifi_.passphrase().empty()) |
236 passphrase_textfield_->SetText(UTF8ToUTF16(wifi_.passphrase)); | 236 passphrase_textfield_->SetText(UTF8ToUTF16(wifi_.passphrase())); |
237 layout->AddView(passphrase_textfield_); | 237 layout->AddView(passphrase_textfield_); |
238 // Password visible button. | 238 // Password visible button. |
239 passphrase_visible_button_ = new views::ImageButton(this); | 239 passphrase_visible_button_ = new views::ImageButton(this); |
240 passphrase_visible_button_->SetImage(views::ImageButton::BS_NORMAL, | 240 passphrase_visible_button_->SetImage(views::ImageButton::BS_NORMAL, |
241 ResourceBundle::GetSharedInstance(). | 241 ResourceBundle::GetSharedInstance(). |
242 GetBitmapNamed(IDR_STATUSBAR_NETWORK_SECURE)); | 242 GetBitmapNamed(IDR_STATUSBAR_NETWORK_SECURE)); |
243 passphrase_visible_button_->SetImageAlignment( | 243 passphrase_visible_button_->SetImageAlignment( |
244 views::ImageButton::ALIGN_CENTER, views::ImageButton::ALIGN_MIDDLE); | 244 views::ImageButton::ALIGN_CENTER, views::ImageButton::ALIGN_MIDDLE); |
245 layout->AddView(passphrase_visible_button_); | 245 layout->AddView(passphrase_visible_button_); |
246 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); | 246 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); |
247 } | 247 } |
248 | 248 |
249 // Autoconnect checkbox | 249 // Autoconnect checkbox |
250 autoconnect_checkbox_ = new views::Checkbox( | 250 autoconnect_checkbox_ = new views::Checkbox( |
251 l10n_util::GetString(IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_AUTO_CONNECT)); | 251 l10n_util::GetString(IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_AUTO_CONNECT)); |
252 // For other network, default to autoconnect. | 252 // For other network, default to autoconnect. |
253 bool autoconnect = other_network_ || wifi_.auto_connect; | 253 bool autoconnect = other_network_ || wifi_.auto_connect(); |
254 autoconnect_checkbox_->SetChecked(autoconnect); | 254 autoconnect_checkbox_->SetChecked(autoconnect); |
255 layout->StartRow(0, column_view_set_id); | 255 layout->StartRow(0, column_view_set_id); |
256 layout->AddView(autoconnect_checkbox_, 3, 1); | 256 layout->AddView(autoconnect_checkbox_, 3, 1); |
257 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); | 257 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); |
258 } | 258 } |
259 | 259 |
260 } // namespace chromeos | 260 } // namespace chromeos |
OLD | NEW |