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 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 IDS_OPTIONS_SETTINGS_SECTION_TITLE_WIRELESS_NETWORK) { | 312 IDS_OPTIONS_SETTINGS_SECTION_TITLE_WIRELESS_NETWORK) { |
313 } | 313 } |
314 | 314 |
315 void WirelessSection::InitSection() { | 315 void WirelessSection::InitSection() { |
316 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary(); | 316 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary(); |
317 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 317 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
318 | 318 |
319 // Wifi | 319 // Wifi |
320 wifi_networks_ = cros->wifi_networks(); | 320 wifi_networks_ = cros->wifi_networks(); |
321 for (size_t i = 0; i < wifi_networks_.size(); ++i) { | 321 for (size_t i = 0; i < wifi_networks_.size(); ++i) { |
322 std::wstring name = ASCIIToWide(wifi_networks_[i].name()); | 322 std::wstring name = ASCIIToWide(wifi_networks_[i]->name()); |
323 | 323 |
324 SkBitmap icon = NetworkMenu::IconForNetworkStrength( | 324 SkBitmap icon = NetworkMenu::IconForNetworkStrength( |
325 wifi_networks_[i].strength(), true); | 325 wifi_networks_[i]->strength(), true); |
326 if (wifi_networks_[i].encrypted()) { | 326 if (wifi_networks_[i]->encrypted()) { |
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 celluar_networks_ = cros->cellular_networks(); |
338 // Cellular networks ssids. | 338 // Cellular networks ssids. |
339 for (size_t i = 0; i < celluar_networks_.size(); ++i) { | 339 for (size_t i = 0; i < celluar_networks_.size(); ++i) { |
340 std::wstring name = ASCIIToWide(celluar_networks_[i].name()); | 340 std::wstring name = ASCIIToWide(celluar_networks_[i]->name()); |
341 | 341 |
342 SkBitmap icon = NetworkMenu::IconForNetworkStrength( | 342 SkBitmap icon = NetworkMenu::IconForNetworkStrength( |
343 celluar_networks_[i].strength(), true); | 343 celluar_networks_[i]->strength(), true); |
344 // TODO(chocobo): Check cellular network 3g/edge. | 344 // TODO(chocobo): Check cellular network 3g/edge. |
345 SkBitmap badge = *rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_3G); | 345 SkBitmap badge = *rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_3G); |
346 // SkBitmap badge = *rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_EDGE); | 346 // SkBitmap badge = *rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_EDGE); |
347 icon = NetworkMenu::IconForDisplay(icon, badge); | 347 icon = NetworkMenu::IconForDisplay(icon, badge); |
348 | 348 |
349 bool connecting = celluar_networks_[i].connecting(); | 349 bool connecting = celluar_networks_[i]->connecting(); |
350 bool connected = celluar_networks_[i].connected(); | 350 bool connected = celluar_networks_[i]->connected(); |
351 AddWirelessNetwork(i, icon, name, connecting, connected, TYPE_CELLULAR); | 351 AddWirelessNetwork(i, icon, name, connecting, connected, TYPE_CELLULAR); |
352 } | 352 } |
353 } | 353 } |
354 | 354 |
355 void WirelessSection::ButtonClicked(int button, int connection_type, int id) { | 355 void WirelessSection::ButtonClicked(int button, int connection_type, int id) { |
356 if (connection_type == TYPE_CELLULAR) { | 356 if (connection_type == TYPE_CELLULAR) { |
357 if (static_cast<int>(celluar_networks_.size()) > id) { | 357 if (static_cast<int>(celluar_networks_.size()) > id) { |
358 if (button == CONNECT_BUTTON) { | 358 if (button == CONNECT_BUTTON) { |
359 // Connect to cellular network. | 359 // Connect to cellular network. |
360 CrosLibrary::Get()->GetNetworkLibrary()->ConnectToCellularNetwork( | 360 CrosLibrary::Get()->GetNetworkLibrary()->ConnectToCellularNetwork( |
361 celluar_networks_[id]); | 361 celluar_networks_[id]); |
362 } else if (button == DISCONNECT_BUTTON) { | 362 } else if (button == DISCONNECT_BUTTON) { |
363 CrosLibrary::Get()->GetNetworkLibrary()->DisconnectFromWirelessNetwork( | 363 CrosLibrary::Get()->GetNetworkLibrary()->DisconnectFromWirelessNetwork( |
364 celluar_networks_[id]); | 364 celluar_networks_[id]); |
365 } else { | 365 } else { |
366 CreateModalPopup(new NetworkConfigView(celluar_networks_[id])); | 366 CreateModalPopup(new NetworkConfigView(celluar_networks_[id])); |
367 } | 367 } |
368 } | 368 } |
369 } else if (connection_type == TYPE_WIFI) { | 369 } else if (connection_type == TYPE_WIFI) { |
370 if (static_cast<int>(wifi_networks_.size()) > id) { | 370 if (static_cast<int>(wifi_networks_.size()) > id) { |
371 if (button == CONNECT_BUTTON) { | 371 if (button == CONNECT_BUTTON) { |
372 // Connect to wifi here. Open password page if appropriate. | 372 // Connect to wifi here. Open password page if appropriate. |
373 if (wifi_networks_[id].encrypted()) { | 373 if (wifi_networks_[id]->encrypted()) { |
374 NetworkConfigView* view = | 374 NetworkConfigView* view = |
375 new NetworkConfigView(wifi_networks_[id], true); | 375 new NetworkConfigView(wifi_networks_[id], true); |
376 CreateModalPopup(view); | 376 CreateModalPopup(view); |
377 view->SetLoginTextfieldFocus(); | 377 view->SetLoginTextfieldFocus(); |
378 } else { | 378 } else { |
379 CrosLibrary::Get()->GetNetworkLibrary()->ConnectToWifiNetwork( | 379 CrosLibrary::Get()->GetNetworkLibrary()->ConnectToWifiNetwork( |
380 wifi_networks_[id], std::string(), std::string(), std::string()); | 380 wifi_networks_[id], std::string(), std::string(), std::string()); |
381 } | 381 } |
382 } else if (button == DISCONNECT_BUTTON) { | 382 } else if (button == DISCONNECT_BUTTON) { |
383 CrosLibrary::Get()->GetNetworkLibrary()->DisconnectFromWirelessNetwork( | 383 CrosLibrary::Get()->GetNetworkLibrary()->DisconnectFromWirelessNetwork( |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 IDS_OPTIONS_SETTINGS_SECTION_TITLE_REMEMBERED_NETWORK) { | 439 IDS_OPTIONS_SETTINGS_SECTION_TITLE_REMEMBERED_NETWORK) { |
440 } | 440 } |
441 | 441 |
442 void RememberedSection::InitSection() { | 442 void RememberedSection::InitSection() { |
443 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary(); | 443 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary(); |
444 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 444 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
445 | 445 |
446 // Wifi | 446 // Wifi |
447 wifi_networks_ = cros->remembered_wifi_networks(); | 447 wifi_networks_ = cros->remembered_wifi_networks(); |
448 for (size_t i = 0; i < wifi_networks_.size(); ++i) { | 448 for (size_t i = 0; i < wifi_networks_.size(); ++i) { |
449 std::wstring name = ASCIIToWide(wifi_networks_[i].name()); | 449 std::wstring name = ASCIIToWide(wifi_networks_[i]->name()); |
450 | 450 |
451 SkBitmap icon = *rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_BARS0_BLACK); | 451 SkBitmap icon = *rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_BARS0_BLACK); |
452 if (wifi_networks_[i].encrypted()) { | 452 if (wifi_networks_[i]->encrypted()) { |
453 icon = NetworkMenu::IconForDisplay(icon, | 453 icon = NetworkMenu::IconForDisplay(icon, |
454 *rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_SECURE)); | 454 *rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_SECURE)); |
455 } | 455 } |
456 | 456 |
457 AddNetwork(i, icon, name, false, std::wstring(), FORGET_BUTTON, TYPE_WIFI); | 457 AddNetwork(i, icon, name, false, std::wstring(), FORGET_BUTTON, TYPE_WIFI); |
458 } | 458 } |
459 | |
460 // Cellular | |
461 celluar_networks_ = cros->remembered_cellular_networks(); | |
462 // Cellular networks ssids. | |
463 for (size_t i = 0; i < celluar_networks_.size(); ++i) { | |
464 std::wstring name = ASCIIToWide(celluar_networks_[i].name()); | |
465 | |
466 SkBitmap icon = *rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_BARS0_BLACK); | |
467 // TODO(chocobo): Check cellular network 3g/edge. | |
468 SkBitmap badge = *rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_3G); | |
469 // SkBitmap badge = *rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_EDGE); | |
470 icon = NetworkMenu::IconForDisplay(icon, badge); | |
471 | |
472 AddNetwork(i, icon, name, false, std::wstring(), FORGET_BUTTON, | |
473 TYPE_CELLULAR); | |
474 } | |
475 } | 459 } |
476 | 460 |
477 void RememberedSection::ButtonClicked(int button, int connection_type, int id) { | 461 void RememberedSection::ButtonClicked(int button, int connection_type, int id) { |
478 if (connection_type == TYPE_CELLULAR) { | 462 if (connection_type == TYPE_WIFI) { |
479 if (static_cast<int>(celluar_networks_.size()) > id) { | |
480 CrosLibrary::Get()->GetNetworkLibrary()->ForgetWirelessNetwork( | |
481 celluar_networks_[id].service_path()); | |
482 } | |
483 } else if (connection_type == TYPE_WIFI) { | |
484 if (static_cast<int>(wifi_networks_.size()) > id) { | 463 if (static_cast<int>(wifi_networks_.size()) > id) { |
485 CrosLibrary::Get()->GetNetworkLibrary()->ForgetWirelessNetwork( | 464 CrosLibrary::Get()->GetNetworkLibrary()->ForgetWifiNetwork( |
486 wifi_networks_[id].service_path()); | 465 wifi_networks_[id]->service_path()); |
487 } | 466 } |
488 } else { | 467 } else { |
489 NOTREACHED(); | 468 NOTREACHED(); |
490 } | 469 } |
491 } | 470 } |
492 | 471 |
493 //////////////////////////////////////////////////////////////////////////////// | 472 //////////////////////////////////////////////////////////////////////////////// |
494 // InternetPageContentView | 473 // InternetPageContentView |
495 | 474 |
496 class InternetPageContentView : public SettingsPageView { | 475 class InternetPageContentView : public SettingsPageView { |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 scroll_view_->SetBounds(GetLocalBounds(false)); | 591 scroll_view_->SetBounds(GetLocalBounds(false)); |
613 scroll_view_->Layout(); | 592 scroll_view_->Layout(); |
614 } | 593 } |
615 | 594 |
616 void InternetPageView::InitControlLayout() { | 595 void InternetPageView::InitControlLayout() { |
617 AddChildView(scroll_view_); | 596 AddChildView(scroll_view_); |
618 scroll_view_->SetContents(contents_view_); | 597 scroll_view_->SetContents(contents_view_); |
619 } | 598 } |
620 | 599 |
621 } // namespace chromeos | 600 } // namespace chromeos |
OLD | NEW |