OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ash/common/system/chromeos/network/network_state_list_detailed_view.h" | 5 #include "ash/common/system/chromeos/network/network_state_list_detailed_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "ash/common/ash_constants.h" | 10 #include "ash/common/ash_constants.h" |
11 #include "ash/common/system/chromeos/network/network_icon.h" | 11 #include "ash/common/system/chromeos/network/network_icon.h" |
12 #include "ash/common/system/chromeos/network/network_icon_animation.h" | 12 #include "ash/common/system/chromeos/network/network_icon_animation.h" |
13 #include "ash/common/system/chromeos/network/network_info.h" | 13 #include "ash/common/system/chromeos/network/network_info.h" |
14 #include "ash/common/system/chromeos/network/network_list_md.h" | 14 #include "ash/common/system/chromeos/network/network_list.h" |
15 #include "ash/common/system/chromeos/network/network_list_view_base.h" | 15 #include "ash/common/system/chromeos/network/network_list_view_base.h" |
16 #include "ash/common/system/chromeos/network/tray_network_state_observer.h" | 16 #include "ash/common/system/chromeos/network/tray_network_state_observer.h" |
17 #include "ash/common/system/chromeos/network/vpn_list_view.h" | 17 #include "ash/common/system/chromeos/network/vpn_list_view.h" |
18 #include "ash/common/system/networking_config_delegate.h" | 18 #include "ash/common/system/networking_config_delegate.h" |
19 #include "ash/common/system/tray/fixed_sized_image_view.h" | 19 #include "ash/common/system/tray/fixed_sized_image_view.h" |
20 #include "ash/common/system/tray/hover_highlight_view.h" | 20 #include "ash/common/system/tray/hover_highlight_view.h" |
21 #include "ash/common/system/tray/system_menu_button.h" | 21 #include "ash/common/system/tray/system_menu_button.h" |
22 #include "ash/common/system/tray/system_tray.h" | 22 #include "ash/common/system/tray/system_tray.h" |
23 #include "ash/common/system/tray/system_tray_controller.h" | 23 #include "ash/common/system/tray/system_tray_controller.h" |
24 #include "ash/common/system/tray/system_tray_delegate.h" | 24 #include "ash/common/system/tray/system_tray_delegate.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 using chromeos::NetworkTypePattern; | 72 using chromeos::NetworkTypePattern; |
73 | 73 |
74 namespace ash { | 74 namespace ash { |
75 namespace tray { | 75 namespace tray { |
76 namespace { | 76 namespace { |
77 | 77 |
78 // Delay between scan requests. | 78 // Delay between scan requests. |
79 const int kRequestScanDelaySeconds = 10; | 79 const int kRequestScanDelaySeconds = 10; |
80 | 80 |
81 // TODO(varkha): Consolidate with a similar method in tray_bluetooth.cc. | 81 // TODO(varkha): Consolidate with a similar method in tray_bluetooth.cc. |
82 void SetupConnectedItemMd(HoverHighlightView* container, | 82 void SetupConnectedItem(HoverHighlightView* container, |
83 const base::string16& text, | 83 const base::string16& text, |
84 const gfx::ImageSkia& image) { | 84 const gfx::ImageSkia& image) { |
85 container->AddIconAndLabels( | 85 container->AddIconAndLabels( |
86 image, text, | 86 image, text, |
87 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_NETWORK_STATUS_CONNECTED)); | 87 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_NETWORK_STATUS_CONNECTED)); |
88 TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::CAPTION); | 88 TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::CAPTION); |
89 style.set_color_style(TrayPopupItemStyle::ColorStyle::CONNECTED); | 89 style.set_color_style(TrayPopupItemStyle::ColorStyle::CONNECTED); |
90 style.SetupLabel(container->sub_text_label()); | 90 style.SetupLabel(container->sub_text_label()); |
91 } | 91 } |
92 | 92 |
93 // TODO(varkha): Consolidate with a similar method in tray_bluetooth.cc. | 93 // TODO(varkha): Consolidate with a similar method in tray_bluetooth.cc. |
94 void SetupConnectingItemMd(HoverHighlightView* container, | 94 void SetupConnectingItem(HoverHighlightView* container, |
95 const base::string16& text, | 95 const base::string16& text, |
96 const gfx::ImageSkia& image) { | 96 const gfx::ImageSkia& image) { |
97 container->AddIconAndLabels( | 97 container->AddIconAndLabels( |
98 image, text, | 98 image, text, |
99 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_NETWORK_STATUS_CONNECTING)); | 99 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_NETWORK_STATUS_CONNECTING)); |
100 ThrobberView* throbber = new ThrobberView; | 100 ThrobberView* throbber = new ThrobberView; |
101 throbber->Start(); | 101 throbber->Start(); |
102 container->AddRightView(throbber); | 102 container->AddRightView(throbber); |
103 } | 103 } |
104 | 104 |
105 } // namespace | 105 } // namespace |
106 | 106 |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
488 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 488 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
489 FROM_HERE, | 489 FROM_HERE, |
490 base::Bind(&NetworkStateListDetailedView::CallRequestScan, AsWeakPtr()), | 490 base::Bind(&NetworkStateListDetailedView::CallRequestScan, AsWeakPtr()), |
491 base::TimeDelta::FromSeconds(kRequestScanDelaySeconds)); | 491 base::TimeDelta::FromSeconds(kRequestScanDelaySeconds)); |
492 } | 492 } |
493 | 493 |
494 views::View* NetworkStateListDetailedView::CreateViewForNetwork( | 494 views::View* NetworkStateListDetailedView::CreateViewForNetwork( |
495 const NetworkInfo& info) { | 495 const NetworkInfo& info) { |
496 HoverHighlightView* container = new HoverHighlightView(this); | 496 HoverHighlightView* container = new HoverHighlightView(this); |
497 if (info.connected) | 497 if (info.connected) |
498 SetupConnectedItemMd(container, info.label, info.image); | 498 SetupConnectedItem(container, info.label, info.image); |
499 else if (info.connecting) | 499 else if (info.connecting) |
500 SetupConnectingItemMd(container, info.label, info.image); | 500 SetupConnectingItem(container, info.label, info.image); |
501 else | 501 else |
502 container->AddIconAndLabel(info.image, info.label, info.highlight); | 502 container->AddIconAndLabel(info.image, info.label, info.highlight); |
503 container->set_tooltip(info.tooltip); | 503 container->set_tooltip(info.tooltip); |
504 views::View* controlled_icon = CreateControlledByExtensionView(info); | 504 views::View* controlled_icon = CreateControlledByExtensionView(info); |
505 if (controlled_icon) | 505 if (controlled_icon) |
506 container->AddChildView(controlled_icon); | 506 container->AddChildView(controlled_icon); |
507 return container; | 507 return container; |
508 } | 508 } |
509 | 509 |
510 NetworkTypePattern NetworkStateListDetailedView::GetNetworkTypePattern() const { | 510 NetworkTypePattern NetworkStateListDetailedView::GetNetworkTypePattern() const { |
511 return list_type_ == LIST_TYPE_VPN ? NetworkTypePattern::VPN() | 511 return list_type_ == LIST_TYPE_VPN ? NetworkTypePattern::VPN() |
512 : NetworkTypePattern::NonVirtual(); | 512 : NetworkTypePattern::NonVirtual(); |
513 } | 513 } |
514 | 514 |
515 void NetworkStateListDetailedView::UpdateViewForNetwork( | 515 void NetworkStateListDetailedView::UpdateViewForNetwork( |
516 views::View* view, | 516 views::View* view, |
517 const NetworkInfo& info) { | 517 const NetworkInfo& info) { |
518 HoverHighlightView* container = static_cast<HoverHighlightView*>(view); | 518 HoverHighlightView* container = static_cast<HoverHighlightView*>(view); |
519 DCHECK(!container->has_children()); | 519 DCHECK(!container->has_children()); |
520 if (info.connected) | 520 if (info.connected) |
521 SetupConnectedItemMd(container, info.label, info.image); | 521 SetupConnectedItem(container, info.label, info.image); |
522 else if (info.connecting) | 522 else if (info.connecting) |
523 SetupConnectingItemMd(container, info.label, info.image); | 523 SetupConnectingItem(container, info.label, info.image); |
524 else | 524 else |
525 container->AddIconAndLabel(info.image, info.label, info.highlight); | 525 container->AddIconAndLabel(info.image, info.label, info.highlight); |
526 views::View* controlled_icon = CreateControlledByExtensionView(info); | 526 views::View* controlled_icon = CreateControlledByExtensionView(info); |
527 container->set_tooltip(info.tooltip); | 527 container->set_tooltip(info.tooltip); |
528 if (controlled_icon) | 528 if (controlled_icon) |
529 view->AddChildView(controlled_icon); | 529 view->AddChildView(controlled_icon); |
530 } | 530 } |
531 | 531 |
532 views::Label* NetworkStateListDetailedView::CreateInfoLabel() { | 532 views::Label* NetworkStateListDetailedView::CreateInfoLabel() { |
533 views::Label* label = new views::Label(); | 533 views::Label* label = new views::Label(); |
(...skipping 14 matching lines...) Expand all Loading... |
548 UMA_STATUS_AREA_NETWORK_JOIN_OTHER_CLICKED); | 548 UMA_STATUS_AREA_NETWORK_JOIN_OTHER_CLICKED); |
549 Shell::Get()->system_tray_controller()->ShowNetworkCreate(shill::kTypeWifi); | 549 Shell::Get()->system_tray_controller()->ShowNetworkCreate(shill::kTypeWifi); |
550 } | 550 } |
551 | 551 |
552 void NetworkStateListDetailedView::RelayoutScrollList() { | 552 void NetworkStateListDetailedView::RelayoutScrollList() { |
553 scroller()->Layout(); | 553 scroller()->Layout(); |
554 } | 554 } |
555 | 555 |
556 } // namespace tray | 556 } // namespace tray |
557 } // namespace ash | 557 } // namespace ash |
OLD | NEW |