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

Side by Side Diff: ash/system/tray/system_tray.cc

Issue 1849623002: Remove unused ash::SHELF_ALIGNMENT_TOP (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 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 | « ash/system/status_area_widget_delegate.cc ('k') | ash/system/tray/tray_background_view.cc » ('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/tray/system_tray.h" 5 #include "ash/system/tray/system_tray.h"
6 6
7 #include "ash/ash_switches.h" 7 #include "ash/ash_switches.h"
8 #include "ash/metrics/user_metrics_recorder.h" 8 #include "ash/metrics/user_metrics_recorder.h"
9 #include "ash/shelf/shelf_layout_manager.h" 9 #include "ash/shelf/shelf_layout_manager.h"
10 #include "ash/shell.h" 10 #include "ash/shell.h"
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 base::string16 battery = base::ASCIIToUTF16(""); 415 base::string16 battery = base::ASCIIToUTF16("");
416 #if defined(OS_CHROMEOS) 416 #if defined(OS_CHROMEOS)
417 battery = PowerStatus::Get()->GetAccessibleNameString(false); 417 battery = PowerStatus::Get()->GetAccessibleNameString(false);
418 #endif 418 #endif
419 return l10n_util::GetStringFUTF16( 419 return l10n_util::GetStringFUTF16(
420 IDS_ASH_STATUS_TRAY_ACCESSIBLE_DESCRIPTION, time, battery); 420 IDS_ASH_STATUS_TRAY_ACCESSIBLE_DESCRIPTION, time, battery);
421 } 421 }
422 422
423 int SystemTray::GetTrayXOffset(SystemTrayItem* item) const { 423 int SystemTray::GetTrayXOffset(SystemTrayItem* item) const {
424 // Don't attempt to align the arrow if the shelf is on the left or right. 424 // Don't attempt to align the arrow if the shelf is on the left or right.
425 if (shelf_alignment() != SHELF_ALIGNMENT_BOTTOM && 425 if (shelf_alignment() != SHELF_ALIGNMENT_BOTTOM)
426 shelf_alignment() != SHELF_ALIGNMENT_TOP)
427 return TrayBubbleView::InitParams::kArrowDefaultOffset; 426 return TrayBubbleView::InitParams::kArrowDefaultOffset;
428 427
429 std::map<SystemTrayItem*, views::View*>::const_iterator it = 428 std::map<SystemTrayItem*, views::View*>::const_iterator it =
430 tray_item_map_.find(item); 429 tray_item_map_.find(item);
431 if (it == tray_item_map_.end()) 430 if (it == tray_item_map_.end())
432 return TrayBubbleView::InitParams::kArrowDefaultOffset; 431 return TrayBubbleView::InitParams::kArrowDefaultOffset;
433 432
434 const views::View* item_view = it->second; 433 const views::View* item_view = it->second;
435 if (item_view->bounds().IsEmpty()) { 434 if (item_view->bounds().IsEmpty()) {
436 // The bounds of item could be still empty if it does not have a visible 435 // The bounds of item could be still empty if it does not have a visible
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 bubble_view = notification_bubble_->bubble_view(); 595 bubble_view = notification_bubble_->bubble_view();
597 else if (system_bubble_) 596 else if (system_bubble_)
598 bubble_view = system_bubble_->bubble_view(); 597 bubble_view = system_bubble_->bubble_view();
599 598
600 int height = 0; 599 int height = 0;
601 if (bubble_view) { 600 if (bubble_view) {
602 gfx::Rect work_area = 601 gfx::Rect work_area =
603 gfx::Screen::GetScreen() 602 gfx::Screen::GetScreen()
604 ->GetDisplayNearestWindow(bubble_view->GetWidget()->GetNativeView()) 603 ->GetDisplayNearestWindow(bubble_view->GetWidget()->GetNativeView())
605 .work_area(); 604 .work_area();
606 if (GetShelfLayoutManager()->GetAlignment() != SHELF_ALIGNMENT_TOP) { 605 height =
607 height = std::max( 606 std::max(0, work_area.height() - bubble_view->GetBoundsInScreen().y());
608 0, work_area.height() - bubble_view->GetBoundsInScreen().y());
609 } else {
610 height = std::max(
611 0, bubble_view->GetBoundsInScreen().bottom() - work_area.y());
612 }
613 } 607 }
614 status_area_widget()->web_notification_tray()->SetSystemTrayHeight(height); 608 status_area_widget()->web_notification_tray()->SetSystemTrayHeight(height);
615 } 609 }
616 610
617 base::string16 SystemTray::GetAccessibleTimeString( 611 base::string16 SystemTray::GetAccessibleTimeString(
618 const base::Time& now) const { 612 const base::Time& now) const {
619 base::HourClockType hour_type = 613 base::HourClockType hour_type =
620 ash::Shell::GetInstance()->system_tray_delegate()->GetHourClockType(); 614 ash::Shell::GetInstance()->system_tray_delegate()->GetHourClockType();
621 return base::TimeFormatTimeOfDayWithHourClockType( 615 return base::TimeFormatTimeOfDayWithHourClockType(
622 now, hour_type, base::kKeepAmPm); 616 now, hour_type, base::kKeepAmPm);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 bool SystemTray::PerformAction(const ui::Event& event) { 710 bool SystemTray::PerformAction(const ui::Event& event) {
717 // If we're already showing the default view, hide it; otherwise, show it 711 // If we're already showing the default view, hide it; otherwise, show it
718 // (and hide any popup that's currently shown). 712 // (and hide any popup that's currently shown).
719 if (HasSystemBubbleType(SystemTrayBubble::BUBBLE_TYPE_DEFAULT)) { 713 if (HasSystemBubbleType(SystemTrayBubble::BUBBLE_TYPE_DEFAULT)) {
720 system_bubble_->bubble()->Close(); 714 system_bubble_->bubble()->Close();
721 } else { 715 } else {
722 int arrow_offset = TrayBubbleView::InitParams::kArrowDefaultOffset; 716 int arrow_offset = TrayBubbleView::InitParams::kArrowDefaultOffset;
723 if (event.IsMouseEvent() || event.type() == ui::ET_GESTURE_TAP) { 717 if (event.IsMouseEvent() || event.type() == ui::ET_GESTURE_TAP) {
724 const ui::LocatedEvent& located_event = 718 const ui::LocatedEvent& located_event =
725 static_cast<const ui::LocatedEvent&>(event); 719 static_cast<const ui::LocatedEvent&>(event);
726 if (shelf_alignment() == SHELF_ALIGNMENT_BOTTOM || 720 if (shelf_alignment() == SHELF_ALIGNMENT_BOTTOM) {
727 shelf_alignment() == SHELF_ALIGNMENT_TOP) {
728 gfx::Point point(located_event.x(), 0); 721 gfx::Point point(located_event.x(), 0);
729 ConvertPointToWidget(this, &point); 722 ConvertPointToWidget(this, &point);
730 arrow_offset = point.x(); 723 arrow_offset = point.x();
731 } 724 }
732 } 725 }
733 ShowDefaultViewWithOffset(BUBBLE_CREATE_NEW, arrow_offset, false); 726 ShowDefaultViewWithOffset(BUBBLE_CREATE_NEW, arrow_offset, false);
734 } 727 }
735 return true; 728 return true;
736 } 729 }
737 730
738 void SystemTray::CloseSystemBubbleAndDeactivateSystemTray() { 731 void SystemTray::CloseSystemBubbleAndDeactivateSystemTray() {
739 system_bubble_.reset(); 732 system_bubble_.reset();
740 // When closing a system bubble with the alternate shelf layout, we need to 733 // When closing a system bubble with the alternate shelf layout, we need to
741 // turn off the active tinting of the shelf. 734 // turn off the active tinting of the shelf.
742 if (full_system_tray_menu_) { 735 if (full_system_tray_menu_) {
743 SetDrawBackgroundAsActive(false); 736 SetDrawBackgroundAsActive(false);
744 full_system_tray_menu_ = false; 737 full_system_tray_menu_ = false;
745 } 738 }
746 } 739 }
747 740
748 } // namespace ash 741 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/status_area_widget_delegate.cc ('k') | ash/system/tray/tray_background_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698