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