Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(178)

Side by Side Diff: ash/system/network/network_state_list_detailed_view.cc

Issue 2843383004: CrOS: Right align captive portal/"controlled by extension" network icon (Closed)
Patch Set: fix layout Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | ash/system/tray/fixed_sized_image_view.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/system/network/network_state_list_detailed_view.h" 5 #include "ash/system/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/ash_constants.h" 10 #include "ash/ash_constants.h"
(...skipping 15 matching lines...) Expand all
26 #include "ash/system/tray/fixed_sized_image_view.h" 26 #include "ash/system/tray/fixed_sized_image_view.h"
27 #include "ash/system/tray/hover_highlight_view.h" 27 #include "ash/system/tray/hover_highlight_view.h"
28 #include "ash/system/tray/system_menu_button.h" 28 #include "ash/system/tray/system_menu_button.h"
29 #include "ash/system/tray/system_tray.h" 29 #include "ash/system/tray/system_tray.h"
30 #include "ash/system/tray/system_tray_controller.h" 30 #include "ash/system/tray/system_tray_controller.h"
31 #include "ash/system/tray/system_tray_delegate.h" 31 #include "ash/system/tray/system_tray_delegate.h"
32 #include "ash/system/tray/throbber_view.h" 32 #include "ash/system/tray/throbber_view.h"
33 #include "ash/system/tray/tray_constants.h" 33 #include "ash/system/tray/tray_constants.h"
34 #include "ash/system/tray/tray_details_view.h" 34 #include "ash/system/tray/tray_details_view.h"
35 #include "ash/system/tray/tray_popup_header_button.h" 35 #include "ash/system/tray/tray_popup_header_button.h"
36 #include "ash/system/tray/tray_popup_utils.h"
36 #include "ash/system/tray/tri_view.h" 37 #include "ash/system/tray/tri_view.h"
37 #include "ash/wm_window.h" 38 #include "ash/wm_window.h"
38 #include "base/command_line.h" 39 #include "base/command_line.h"
39 #include "base/strings/string_number_conversions.h" 40 #include "base/strings/string_number_conversions.h"
40 #include "base/strings/utf_string_conversions.h" 41 #include "base/strings/utf_string_conversions.h"
41 #include "base/threading/thread_task_runner_handle.h" 42 #include "base/threading/thread_task_runner_handle.h"
42 #include "base/time/time.h" 43 #include "base/time/time.h"
43 #include "chromeos/chromeos_switches.h" 44 #include "chromeos/chromeos_switches.h"
44 #include "chromeos/login/login_state.h" 45 #include "chromeos/login/login_state.h"
45 #include "chromeos/network/device_state.h" 46 #include "chromeos/network/device_state.h"
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 NetworkingConfigDelegate* networking_config_delegate = 451 NetworkingConfigDelegate* networking_config_delegate =
451 Shell::Get()->system_tray_delegate()->GetNetworkingConfigDelegate(); 452 Shell::Get()->system_tray_delegate()->GetNetworkingConfigDelegate();
452 if (!networking_config_delegate) 453 if (!networking_config_delegate)
453 return nullptr; 454 return nullptr;
454 std::unique_ptr<const NetworkingConfigDelegate::ExtensionInfo> 455 std::unique_ptr<const NetworkingConfigDelegate::ExtensionInfo>
455 extension_info = 456 extension_info =
456 networking_config_delegate->LookUpExtensionForNetwork(info.guid); 457 networking_config_delegate->LookUpExtensionForNetwork(info.guid);
457 if (!extension_info) 458 if (!extension_info)
458 return nullptr; 459 return nullptr;
459 460
460 // Get the tooltip text. 461 views::ImageView* controlled_icon = TrayPopupUtils::CreateMainImageView();
461 base::string16 tooltip_text = l10n_util::GetStringFUTF16(
462 IDS_ASH_STATUS_TRAY_EXTENSION_CONTROLLED_WIFI,
463 base::UTF8ToUTF16(extension_info->extension_name));
464
465 views::ImageView* controlled_icon =
466 new FixedSizedImageView(kTrayPopupDetailsIconWidth, 0);
tdanderson 2017/05/01 15:31:16 Can you please rebase and then re-ping? It looks l
467
468 controlled_icon->SetImage( 462 controlled_icon->SetImage(
469 gfx::CreateVectorIcon(kCaptivePortalIcon, kMenuIconColor)); 463 gfx::CreateVectorIcon(kCaptivePortalIcon, kMenuIconColor));
470 controlled_icon->SetTooltipText(tooltip_text); 464 controlled_icon->SetTooltipText(l10n_util::GetStringFUTF16(
465 IDS_ASH_STATUS_TRAY_EXTENSION_CONTROLLED_WIFI,
466 base::UTF8ToUTF16(extension_info->extension_name)));
471 return controlled_icon; 467 return controlled_icon;
472 } 468 }
473 469
474 void NetworkStateListDetailedView::CallRequestScan() { 470 void NetworkStateListDetailedView::CallRequestScan() {
475 VLOG(1) << "Requesting Network Scan."; 471 VLOG(1) << "Requesting Network Scan.";
476 NetworkHandler::Get()->network_state_handler()->RequestScan(); 472 NetworkHandler::Get()->network_state_handler()->RequestScan();
477 // Periodically request a scan while this UI is open. 473 // Periodically request a scan while this UI is open.
478 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 474 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
479 FROM_HERE, 475 FROM_HERE,
480 base::Bind(&NetworkStateListDetailedView::CallRequestScan, AsWeakPtr()), 476 base::Bind(&NetworkStateListDetailedView::CallRequestScan, AsWeakPtr()),
481 base::TimeDelta::FromSeconds(kRequestScanDelaySeconds)); 477 base::TimeDelta::FromSeconds(kRequestScanDelaySeconds));
482 } 478 }
483 479
484 views::View* NetworkStateListDetailedView::CreateViewForNetwork( 480 views::View* NetworkStateListDetailedView::CreateViewForNetwork(
485 const NetworkInfo& info) { 481 const NetworkInfo& info) {
486 HoverHighlightView* container = new HoverHighlightView(this); 482 HoverHighlightView* container = new HoverHighlightView(this);
487 if (info.connected) 483 UpdateViewForNetwork(container, info);
488 SetupConnectedItem(container, info.label, info.image);
489 else if (info.connecting)
490 SetupConnectingItem(container, info.label, info.image);
491 else
492 container->AddIconAndLabel(info.image, info.label);
493 container->SetTooltipText(info.tooltip);
494 views::View* controlled_icon = CreateControlledByExtensionView(info);
495 if (controlled_icon)
496 container->AddChildView(controlled_icon);
497 return container; 484 return container;
498 } 485 }
499 486
500 NetworkTypePattern NetworkStateListDetailedView::GetNetworkTypePattern() const { 487 NetworkTypePattern NetworkStateListDetailedView::GetNetworkTypePattern() const {
501 return list_type_ == LIST_TYPE_VPN ? NetworkTypePattern::VPN() 488 return list_type_ == LIST_TYPE_VPN ? NetworkTypePattern::VPN()
502 : NetworkTypePattern::NonVirtual(); 489 : NetworkTypePattern::NonVirtual();
503 } 490 }
504 491
505 void NetworkStateListDetailedView::UpdateViewForNetwork( 492 void NetworkStateListDetailedView::UpdateViewForNetwork(
506 views::View* view, 493 views::View* view,
507 const NetworkInfo& info) { 494 const NetworkInfo& info) {
508 HoverHighlightView* container = static_cast<HoverHighlightView*>(view); 495 HoverHighlightView* container = static_cast<HoverHighlightView*>(view);
509 DCHECK(!container->has_children()); 496 DCHECK(!container->has_children());
510 if (info.connected) 497 if (info.connected)
511 SetupConnectedItem(container, info.label, info.image); 498 SetupConnectedItem(container, info.label, info.image);
512 else if (info.connecting) 499 else if (info.connecting)
513 SetupConnectingItem(container, info.label, info.image); 500 SetupConnectingItem(container, info.label, info.image);
514 else 501 else
515 container->AddIconAndLabel(info.image, info.label); 502 container->AddIconAndLabel(info.image, info.label);
516 views::View* controlled_icon = CreateControlledByExtensionView(info); 503 views::View* controlled_icon = CreateControlledByExtensionView(info);
517 container->SetTooltipText(info.tooltip); 504 container->SetTooltipText(info.tooltip);
518 if (controlled_icon) 505 if (controlled_icon)
519 view->AddChildView(controlled_icon); 506 container->AddRightView(controlled_icon);
520 } 507 }
521 508
522 views::Label* NetworkStateListDetailedView::CreateInfoLabel() { 509 views::Label* NetworkStateListDetailedView::CreateInfoLabel() {
523 views::Label* label = new views::Label(); 510 views::Label* label = new views::Label();
524 label->SetBorder(views::CreateEmptyBorder(kTrayPopupPaddingBetweenItems, 511 label->SetBorder(views::CreateEmptyBorder(kTrayPopupPaddingBetweenItems,
525 kTrayPopupPaddingHorizontal, 512 kTrayPopupPaddingHorizontal,
526 kTrayPopupPaddingBetweenItems, 0)); 513 kTrayPopupPaddingBetweenItems, 0));
527 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); 514 label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
528 label->SetEnabledColor(SkColorSetARGB(192, 0, 0, 0)); 515 label->SetEnabledColor(SkColorSetARGB(192, 0, 0, 0));
529 return label; 516 return label;
530 } 517 }
531 518
532 void NetworkStateListDetailedView::OnNetworkEntryClicked(views::View* sender) { 519 void NetworkStateListDetailedView::OnNetworkEntryClicked(views::View* sender) {
533 HandleViewClicked(sender); 520 HandleViewClicked(sender);
534 } 521 }
535 522
536 void NetworkStateListDetailedView::OnOtherWifiClicked() { 523 void NetworkStateListDetailedView::OnOtherWifiClicked() {
537 ShellPort::Get()->RecordUserMetricsAction( 524 ShellPort::Get()->RecordUserMetricsAction(
538 UMA_STATUS_AREA_NETWORK_JOIN_OTHER_CLICKED); 525 UMA_STATUS_AREA_NETWORK_JOIN_OTHER_CLICKED);
539 Shell::Get()->system_tray_controller()->ShowNetworkCreate(shill::kTypeWifi); 526 Shell::Get()->system_tray_controller()->ShowNetworkCreate(shill::kTypeWifi);
540 } 527 }
541 528
542 void NetworkStateListDetailedView::RelayoutScrollList() { 529 void NetworkStateListDetailedView::RelayoutScrollList() {
543 scroller()->Layout(); 530 scroller()->Layout();
544 } 531 }
545 532
546 } // namespace tray 533 } // namespace tray
547 } // namespace ash 534 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/system/tray/fixed_sized_image_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698