| 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/options/internet_page_view.h" | 5 #include "chrome/browser/chromeos/options/internet_page_view.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 // For |connecting| or |connected| networks, the name is bold. | 294 // For |connecting| or |connected| networks, the name is bold. |
| 295 // The status is "Connecting" if |connecting|, "Connected" if |connected|, | 295 // The status is "Connecting" if |connecting|, "Connected" if |connected|, |
| 296 // or "Disconnected". | 296 // or "Disconnected". |
| 297 // For connected networks, we show the disconnect and options buttons. | 297 // For connected networks, we show the disconnect and options buttons. |
| 298 // For !connected and !connecting networks, we show the connect button. | 298 // For !connected and !connecting networks, we show the connect button. |
| 299 void AddWirelessNetwork(int id, const SkBitmap& icon, | 299 void AddWirelessNetwork(int id, const SkBitmap& icon, |
| 300 const std::wstring& name, bool connecting, | 300 const std::wstring& name, bool connecting, |
| 301 bool connected, int connection_type); | 301 bool connected, int connection_type); |
| 302 | 302 |
| 303 WifiNetworkVector wifi_networks_; | 303 WifiNetworkVector wifi_networks_; |
| 304 CellularNetworkVector celluar_networks_; | 304 CellularNetworkVector cellular_networks_; |
| 305 | 305 |
| 306 DISALLOW_COPY_AND_ASSIGN(WirelessSection); | 306 DISALLOW_COPY_AND_ASSIGN(WirelessSection); |
| 307 }; | 307 }; |
| 308 | 308 |
| 309 WirelessSection::WirelessSection(InternetPageContentView* parent, | 309 WirelessSection::WirelessSection(InternetPageContentView* parent, |
| 310 Profile* profile) | 310 Profile* profile) |
| 311 : NetworkSection(parent, profile, | 311 : NetworkSection(parent, profile, |
| 312 IDS_OPTIONS_SETTINGS_SECTION_TITLE_WIRELESS_NETWORK) { | 312 IDS_OPTIONS_SETTINGS_SECTION_TITLE_WIRELESS_NETWORK) { |
| 313 } | 313 } |
| 314 | 314 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 327 icon = NetworkMenu::IconForDisplay(icon, | 327 icon = NetworkMenu::IconForDisplay(icon, |
| 328 *rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_SECURE)); | 328 *rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_SECURE)); |
| 329 } | 329 } |
| 330 | 330 |
| 331 bool connecting = wifi_networks_[i]->connecting(); | 331 bool connecting = wifi_networks_[i]->connecting(); |
| 332 bool connected = wifi_networks_[i]->connected(); | 332 bool connected = wifi_networks_[i]->connected(); |
| 333 AddWirelessNetwork(i, icon, name, connecting, connected, TYPE_WIFI); | 333 AddWirelessNetwork(i, icon, name, connecting, connected, TYPE_WIFI); |
| 334 } | 334 } |
| 335 | 335 |
| 336 // Cellular | 336 // Cellular |
| 337 celluar_networks_ = cros->cellular_networks(); | 337 cellular_networks_ = cros->cellular_networks(); |
| 338 // Cellular networks ssids. | 338 for (size_t i = 0; i < cellular_networks_.size(); ++i) { |
| 339 for (size_t i = 0; i < celluar_networks_.size(); ++i) { | 339 std::wstring name = ASCIIToWide(cellular_networks_[i]->name()); |
| 340 std::wstring name = ASCIIToWide(celluar_networks_[i]->name()); | |
| 341 | 340 |
| 342 SkBitmap icon = NetworkMenu::IconForNetworkStrength( | 341 SkBitmap icon = NetworkMenu::IconForNetworkStrength( |
| 343 celluar_networks_[i]->strength(), true); | 342 cellular_networks_[i]->strength(), true); |
| 344 // TODO(chocobo): Check cellular network 3g/edge. | 343 SkBitmap badge = |
| 345 SkBitmap badge = *rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_3G); | 344 NetworkMenu::BadgeForNetworkTechnology(cellular_networks_[i]); |
| 346 // SkBitmap badge = *rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_EDGE); | |
| 347 icon = NetworkMenu::IconForDisplay(icon, badge); | 345 icon = NetworkMenu::IconForDisplay(icon, badge); |
| 348 | 346 |
| 349 bool connecting = celluar_networks_[i]->connecting(); | 347 bool connecting = cellular_networks_[i]->connecting(); |
| 350 bool connected = celluar_networks_[i]->connected(); | 348 bool connected = cellular_networks_[i]->connected(); |
| 351 AddWirelessNetwork(i, icon, name, connecting, connected, TYPE_CELLULAR); | 349 AddWirelessNetwork(i, icon, name, connecting, connected, TYPE_CELLULAR); |
| 352 } | 350 } |
| 353 } | 351 } |
| 354 | 352 |
| 355 void WirelessSection::ButtonClicked(int button, int connection_type, int id) { | 353 void WirelessSection::ButtonClicked(int button, int connection_type, int id) { |
| 356 if (connection_type == TYPE_CELLULAR) { | 354 if (connection_type == TYPE_CELLULAR) { |
| 357 if (static_cast<int>(celluar_networks_.size()) > id) { | 355 if (static_cast<int>(cellular_networks_.size()) > id) { |
| 358 if (button == CONNECT_BUTTON) { | 356 if (button == CONNECT_BUTTON) { |
| 359 // Connect to cellular network. | 357 // Connect to cellular network. |
| 360 CrosLibrary::Get()->GetNetworkLibrary()->ConnectToCellularNetwork( | 358 CrosLibrary::Get()->GetNetworkLibrary()->ConnectToCellularNetwork( |
| 361 celluar_networks_[id]); | 359 cellular_networks_[id]); |
| 362 } else if (button == DISCONNECT_BUTTON) { | 360 } else if (button == DISCONNECT_BUTTON) { |
| 363 CrosLibrary::Get()->GetNetworkLibrary()->DisconnectFromWirelessNetwork( | 361 CrosLibrary::Get()->GetNetworkLibrary()->DisconnectFromWirelessNetwork( |
| 364 celluar_networks_[id]); | 362 cellular_networks_[id]); |
| 365 } else { | 363 } else { |
| 366 CreateModalPopup(new NetworkConfigView(celluar_networks_[id])); | 364 CreateModalPopup(new NetworkConfigView(cellular_networks_[id])); |
| 367 } | 365 } |
| 368 } | 366 } |
| 369 } else if (connection_type == TYPE_WIFI) { | 367 } else if (connection_type == TYPE_WIFI) { |
| 370 if (static_cast<int>(wifi_networks_.size()) > id) { | 368 if (static_cast<int>(wifi_networks_.size()) > id) { |
| 371 if (button == CONNECT_BUTTON) { | 369 if (button == CONNECT_BUTTON) { |
| 372 // Connect to wifi here. Open password page if appropriate. | 370 // Connect to wifi here. Open password page if appropriate. |
| 373 if (wifi_networks_[id]->encrypted()) { | 371 if (wifi_networks_[id]->encrypted()) { |
| 374 NetworkConfigView* view = | 372 NetworkConfigView* view = |
| 375 new NetworkConfigView(wifi_networks_[id], true); | 373 new NetworkConfigView(wifi_networks_[id], true); |
| 376 CreateModalPopup(view); | 374 CreateModalPopup(view); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 RememberedSection(InternetPageContentView* parent, Profile* profile); | 419 RememberedSection(InternetPageContentView* parent, Profile* profile); |
| 422 virtual ~RememberedSection() {} | 420 virtual ~RememberedSection() {} |
| 423 | 421 |
| 424 protected: | 422 protected: |
| 425 // NetworkSection overrides: | 423 // NetworkSection overrides: |
| 426 virtual void InitSection(); | 424 virtual void InitSection(); |
| 427 virtual void ButtonClicked(int button, int connection_type, int id); | 425 virtual void ButtonClicked(int button, int connection_type, int id); |
| 428 | 426 |
| 429 private: | 427 private: |
| 430 WifiNetworkVector wifi_networks_; | 428 WifiNetworkVector wifi_networks_; |
| 431 CellularNetworkVector celluar_networks_; | |
| 432 | 429 |
| 433 DISALLOW_COPY_AND_ASSIGN(RememberedSection); | 430 DISALLOW_COPY_AND_ASSIGN(RememberedSection); |
| 434 }; | 431 }; |
| 435 | 432 |
| 436 RememberedSection::RememberedSection(InternetPageContentView* parent, | 433 RememberedSection::RememberedSection(InternetPageContentView* parent, |
| 437 Profile* profile) | 434 Profile* profile) |
| 438 : NetworkSection(parent, profile, | 435 : NetworkSection(parent, profile, |
| 439 IDS_OPTIONS_SETTINGS_SECTION_TITLE_REMEMBERED_NETWORK) { | 436 IDS_OPTIONS_SETTINGS_SECTION_TITLE_REMEMBERED_NETWORK) { |
| 440 } | 437 } |
| 441 | 438 |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 | 560 |
| 564 //////////////////////////////////////////////////////////////////////////////// | 561 //////////////////////////////////////////////////////////////////////////////// |
| 565 // InternetPageView | 562 // InternetPageView |
| 566 | 563 |
| 567 InternetPageView::InternetPageView(Profile* profile) | 564 InternetPageView::InternetPageView(Profile* profile) |
| 568 : SettingsPageView(profile), | 565 : SettingsPageView(profile), |
| 569 contents_view_(new InternetPageContentView(profile)), | 566 contents_view_(new InternetPageContentView(profile)), |
| 570 scroll_view_(new views::ScrollView) { | 567 scroll_view_(new views::ScrollView) { |
| 571 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary(); | 568 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary(); |
| 572 cros->UpdateSystemInfo(); | 569 cros->UpdateSystemInfo(); |
| 573 cros->AddObserver(this); | 570 cros->AddNetworkManagerObserver(this); |
| 574 } | 571 } |
| 575 | 572 |
| 576 InternetPageView::~InternetPageView() { | 573 InternetPageView::~InternetPageView() { |
| 577 CrosLibrary::Get()->GetNetworkLibrary()->RemoveObserver(this); | 574 CrosLibrary::Get()->GetNetworkLibrary()->RemoveNetworkManagerObserver(this); |
| 578 } | 575 } |
| 579 | 576 |
| 580 void InternetPageView::NetworkChanged(NetworkLibrary* obj) { | 577 void InternetPageView::OnNetworkManagerChanged(NetworkLibrary* obj) { |
| 581 // Refresh wired, wireless, and remembered networks. | 578 // Refresh wired, wireless, and remembered networks. |
| 582 // Remember the current scroll region, and try to scroll back afterwards. | 579 // Remember the current scroll region, and try to scroll back afterwards. |
| 583 gfx::Rect rect = scroll_view_->GetVisibleRect(); | 580 gfx::Rect rect = scroll_view_->GetVisibleRect(); |
| 584 contents_view_->RefreshContents(); | 581 contents_view_->RefreshContents(); |
| 585 Layout(); | 582 Layout(); |
| 586 scroll_view_->ScrollContentsRegionToBeVisible(rect); | 583 scroll_view_->ScrollContentsRegionToBeVisible(rect); |
| 587 } | 584 } |
| 588 | 585 |
| 589 void InternetPageView::Layout() { | 586 void InternetPageView::Layout() { |
| 590 contents_view_->Layout(); | 587 contents_view_->Layout(); |
| 591 scroll_view_->SetBounds(GetLocalBounds(false)); | 588 scroll_view_->SetBounds(GetLocalBounds(false)); |
| 592 scroll_view_->Layout(); | 589 scroll_view_->Layout(); |
| 593 } | 590 } |
| 594 | 591 |
| 595 void InternetPageView::InitControlLayout() { | 592 void InternetPageView::InitControlLayout() { |
| 596 AddChildView(scroll_view_); | 593 AddChildView(scroll_view_); |
| 597 scroll_view_->SetContents(contents_view_); | 594 scroll_view_->SetContents(contents_view_); |
| 598 } | 595 } |
| 599 | 596 |
| 600 } // namespace chromeos | 597 } // namespace chromeos |
| OLD | NEW |