| OLD | NEW |
| 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/login/network_selection_view.h" | 5 #include "chrome/browser/chromeos/login/network_selection_view.h" |
| 6 | 6 |
| 7 #include <signal.h> | 7 #include <signal.h> |
| 8 #include <sys/types.h> | 8 #include <sys/types.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "app/l10n_util.h" | 12 #include "app/l10n_util.h" |
| 13 #include "app/resource_bundle.h" | 13 #include "app/resource_bundle.h" |
| 14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 15 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
| 16 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 16 #include "chrome/browser/chromeos/login/screen_observer.h" | 17 #include "chrome/browser/chromeos/login/screen_observer.h" |
| 17 #include "chrome/browser/pref_service.h" | 18 #include "chrome/browser/pref_service.h" |
| 18 #include "chrome/common/pref_names.h" | 19 #include "chrome/common/pref_names.h" |
| 19 #include "chrome/browser/chromeos/options/network_config_view.h" | 20 #include "chrome/browser/chromeos/options/network_config_view.h" |
| 20 #include "grit/chromium_strings.h" | 21 #include "grit/chromium_strings.h" |
| 21 #include "grit/generated_resources.h" | 22 #include "grit/generated_resources.h" |
| 22 #include "views/controls/button/native_button.h" | 23 #include "views/controls/button/native_button.h" |
| 23 #include "views/controls/combobox/combobox.h" | 24 #include "views/controls/combobox/combobox.h" |
| 24 #include "views/controls/label.h" | 25 #include "views/controls/label.h" |
| 25 #include "views/widget/widget.h" | 26 #include "views/widget/widget.h" |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 l10n_util::GetString(IDS_PRODUCT_OS_NAME))); | 139 l10n_util::GetString(IDS_PRODUCT_OS_NAME))); |
| 139 select_network_label_->SetText( | 140 select_network_label_->SetText( |
| 140 l10n_util::GetString(IDS_NETWORK_SELECTION_SELECT)); | 141 l10n_util::GetString(IDS_NETWORK_SELECTION_SELECT)); |
| 141 offline_button_->SetLabel( | 142 offline_button_->SetLabel( |
| 142 l10n_util::GetString(IDS_NETWORK_SELECTION_OFFLINE_BUTTON)); | 143 l10n_util::GetString(IDS_NETWORK_SELECTION_OFFLINE_BUTTON)); |
| 143 UpdateConnectingNetworkLabel(); | 144 UpdateConnectingNetworkLabel(); |
| 144 } | 145 } |
| 145 | 146 |
| 146 void NetworkSelectionView::Refresh() { | 147 void NetworkSelectionView::Refresh() { |
| 147 ChangeNetworkNotification(true); | 148 ChangeNetworkNotification(true); |
| 148 NetworkChanged(chromeos::NetworkLibrary::Get()); | 149 NetworkChanged(chromeos::CrosLibrary::Get()->GetNetworkLibrary()); |
| 149 } | 150 } |
| 150 | 151 |
| 151 //////////////////////////////////////////////////////////////////////////////// | 152 //////////////////////////////////////////////////////////////////////////////// |
| 152 // views::View: implementation: | 153 // views::View: implementation: |
| 153 | 154 |
| 154 gfx::Size NetworkSelectionView::GetPreferredSize() { | 155 gfx::Size NetworkSelectionView::GetPreferredSize() { |
| 155 return gfx::Size(width(), height()); | 156 return gfx::Size(width(), height()); |
| 156 } | 157 } |
| 157 | 158 |
| 158 void NetworkSelectionView::Layout() { | 159 void NetworkSelectionView::Layout() { |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 return; | 241 return; |
| 241 | 242 |
| 242 NetworkList::NetworkItem* network = | 243 NetworkList::NetworkItem* network = |
| 243 networks_.GetNetworkAt(new_index - 1); | 244 networks_.GetNetworkAt(new_index - 1); |
| 244 if (network) { | 245 if (network) { |
| 245 if (NetworkList::NETWORK_WIFI == network->network_type) { | 246 if (NetworkList::NETWORK_WIFI == network->network_type) { |
| 246 if (network->wifi_network.encrypted) { | 247 if (network->wifi_network.encrypted) { |
| 247 OpenPasswordDialog(network->wifi_network); | 248 OpenPasswordDialog(network->wifi_network); |
| 248 return; | 249 return; |
| 249 } else { | 250 } else { |
| 250 NetworkLibrary::Get()->ConnectToWifiNetwork( | 251 CrosLibrary::Get()->GetNetworkLibrary()->ConnectToWifiNetwork( |
| 251 network->wifi_network, string16()); | 252 network->wifi_network, string16()); |
| 252 } | 253 } |
| 253 } else if (NetworkList::NETWORK_CELLULAR == | 254 } else if (NetworkList::NETWORK_CELLULAR == |
| 254 network->network_type) { | 255 network->network_type) { |
| 255 NetworkLibrary::Get()->ConnectToCellularNetwork( | 256 CrosLibrary::Get()->GetNetworkLibrary()->ConnectToCellularNetwork( |
| 256 network->cellular_network); | 257 network->cellular_network); |
| 257 } | 258 } |
| 258 } | 259 } |
| 259 } | 260 } |
| 260 | 261 |
| 261 /////////////////////////////////////////////////////////////////////////////// | 262 /////////////////////////////////////////////////////////////////////////////// |
| 262 // views::ButtonListener implementation: | 263 // views::ButtonListener implementation: |
| 263 | 264 |
| 264 void NetworkSelectionView::ButtonPressed(views::Button* sender, | 265 void NetworkSelectionView::ButtonPressed(views::Button* sender, |
| 265 const views::Event& event) { | 266 const views::Event& event) { |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 network_id_ = network_id; | 374 network_id_ = network_id; |
| 374 UpdateConnectingNetworkLabel(); | 375 UpdateConnectingNetworkLabel(); |
| 375 select_network_label_->SetVisible(!connecting); | 376 select_network_label_->SetVisible(!connecting); |
| 376 network_combobox_->SetVisible(!connecting); | 377 network_combobox_->SetVisible(!connecting); |
| 377 connecting_network_label_->SetVisible(connecting); | 378 connecting_network_label_->SetVisible(connecting); |
| 378 } | 379 } |
| 379 | 380 |
| 380 void NetworkSelectionView::ChangeNetworkNotification(bool subscribe) { | 381 void NetworkSelectionView::ChangeNetworkNotification(bool subscribe) { |
| 381 network_notification_ = subscribe; | 382 network_notification_ = subscribe; |
| 382 if (subscribe) | 383 if (subscribe) |
| 383 chromeos::NetworkLibrary::Get()->AddObserver(this); | 384 chromeos::CrosLibrary::Get()->GetNetworkLibrary()->AddObserver(this); |
| 384 else | 385 else |
| 385 chromeos::NetworkLibrary::Get()->RemoveObserver(this); | 386 chromeos::CrosLibrary::Get()->GetNetworkLibrary()->RemoveObserver(this); |
| 386 } | 387 } |
| 387 | 388 |
| 388 void NetworkSelectionView::UpdateConnectingNetworkLabel() { | 389 void NetworkSelectionView::UpdateConnectingNetworkLabel() { |
| 389 connecting_network_label_->SetText(l10n_util::GetStringF( | 390 connecting_network_label_->SetText(l10n_util::GetStringF( |
| 390 IDS_NETWORK_SELECTION_CONNECTING, UTF16ToWide(network_id_))); | 391 IDS_NETWORK_SELECTION_CONNECTING, UTF16ToWide(network_id_))); |
| 391 } | 392 } |
| 392 | 393 |
| 393 } // namespace chromeos | 394 } // namespace chromeos |
| OLD | NEW |