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

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

Issue 2060003002: ash: Add a unit test for the system update tray item (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@movetraydelegate
Patch Set: rebase Created 4 years, 6 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/tray/system_tray.h ('k') | ash/system/tray/tray_image_item.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/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/common/shelf/wm_shelf_util.h" 8 #include "ash/common/shelf/wm_shelf_util.h"
9 #include "ash/common/shell_window_ids.h" 9 #include "ash/common/shell_window_ids.h"
10 #include "ash/common/system/tray/system_tray_delegate.h" 10 #include "ash/common/system/tray/system_tray_delegate.h"
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 SystemTray::SystemTray(StatusAreaWidget* status_area_widget) 135 SystemTray::SystemTray(StatusAreaWidget* status_area_widget)
136 : TrayBackgroundView(status_area_widget), 136 : TrayBackgroundView(status_area_widget),
137 items_(), 137 items_(),
138 detailed_item_(nullptr), 138 detailed_item_(nullptr),
139 default_bubble_height_(0), 139 default_bubble_height_(0),
140 hide_notifications_(false), 140 hide_notifications_(false),
141 full_system_tray_menu_(false), 141 full_system_tray_menu_(false),
142 tray_accessibility_(nullptr), 142 tray_accessibility_(nullptr),
143 tray_cast_(nullptr), 143 tray_cast_(nullptr),
144 tray_date_(nullptr), 144 tray_date_(nullptr),
145 tray_update_(nullptr),
145 screen_capture_tray_item_(nullptr), 146 screen_capture_tray_item_(nullptr),
146 screen_share_tray_item_(nullptr) { 147 screen_share_tray_item_(nullptr) {
147 SetContentsBackground(); 148 SetContentsBackground();
148 } 149 }
149 150
150 SystemTray::~SystemTray() { 151 SystemTray::~SystemTray() {
151 // Destroy any child views that might have back pointers before ~View(). 152 // Destroy any child views that might have back pointers before ~View().
152 system_bubble_.reset(); 153 system_bubble_.reset();
153 notification_bubble_.reset(); 154 notification_bubble_.reset();
154 for (std::vector<SystemTrayItem*>::iterator it = items_.begin(); 155 for (std::vector<SystemTrayItem*>::iterator it = items_.begin();
(...skipping 19 matching lines...) Expand all
174 175
175 if (maximum_user_profiles > 1) { 176 if (maximum_user_profiles > 1) {
176 // Add a special double line separator between users and the rest of the 177 // Add a special double line separator between users and the rest of the
177 // menu if more then one user is logged in. 178 // menu if more then one user is logged in.
178 AddTrayItem(new TrayUserSeparator(this)); 179 AddTrayItem(new TrayUserSeparator(this));
179 } 180 }
180 #endif 181 #endif
181 182
182 tray_accessibility_ = new TrayAccessibility(this); 183 tray_accessibility_ = new TrayAccessibility(this);
183 tray_date_ = new TrayDate(this); 184 tray_date_ = new TrayDate(this);
185 tray_update_ = new TrayUpdate(this);
184 186
185 #if defined(OS_CHROMEOS) 187 #if defined(OS_CHROMEOS)
186 AddTrayItem(new TraySessionLengthLimit(this)); 188 AddTrayItem(new TraySessionLengthLimit(this));
187 AddTrayItem(new TrayEnterprise(this)); 189 AddTrayItem(new TrayEnterprise(this));
188 AddTrayItem(new TraySupervisedUser(this)); 190 AddTrayItem(new TraySupervisedUser(this));
189 AddTrayItem(new TrayIME(this)); 191 AddTrayItem(new TrayIME(this));
190 AddTrayItem(tray_accessibility_); 192 AddTrayItem(tray_accessibility_);
191 AddTrayItem(new TrayTracing(this)); 193 AddTrayItem(new TrayTracing(this));
192 AddTrayItem(new TrayPower(this, message_center::MessageCenter::Get())); 194 AddTrayItem(new TrayPower(this, message_center::MessageCenter::Get()));
193 AddTrayItem(new TrayNetwork(this)); 195 AddTrayItem(new TrayNetwork(this));
194 AddTrayItem(new TrayVPN(this)); 196 AddTrayItem(new TrayVPN(this));
195 AddTrayItem(new TraySms(this)); 197 AddTrayItem(new TraySms(this));
196 AddTrayItem(new TrayBluetooth(this)); 198 AddTrayItem(new TrayBluetooth(this));
197 tray_cast_ = new TrayCast(this); 199 tray_cast_ = new TrayCast(this);
198 AddTrayItem(tray_cast_); 200 AddTrayItem(tray_cast_);
199 AddTrayItem(new TrayDisplay(this)); 201 AddTrayItem(new TrayDisplay(this));
200 screen_capture_tray_item_ = new ScreenCaptureTrayItem(this); 202 screen_capture_tray_item_ = new ScreenCaptureTrayItem(this);
201 AddTrayItem(screen_capture_tray_item_); 203 AddTrayItem(screen_capture_tray_item_);
202 screen_share_tray_item_ = new ScreenShareTrayItem(this); 204 screen_share_tray_item_ = new ScreenShareTrayItem(this);
203 AddTrayItem(screen_share_tray_item_); 205 AddTrayItem(screen_share_tray_item_);
204 AddTrayItem(new MultiProfileMediaTrayItem(this)); 206 AddTrayItem(new MultiProfileMediaTrayItem(this));
205 AddTrayItem(new TrayAudioChromeOs(this)); 207 AddTrayItem(new TrayAudioChromeOs(this));
206 AddTrayItem(new TrayBrightness(this)); 208 AddTrayItem(new TrayBrightness(this));
207 AddTrayItem(new TrayCapsLock(this)); 209 AddTrayItem(new TrayCapsLock(this));
208 AddTrayItem(new TrayRotationLock(this)); 210 AddTrayItem(new TrayRotationLock(this));
209 AddTrayItem(new TraySettings(this)); 211 AddTrayItem(new TraySettings(this));
210 AddTrayItem(new TrayUpdate(this)); 212 AddTrayItem(tray_update_);
211 AddTrayItem(tray_date_); 213 AddTrayItem(tray_date_);
212 #elif defined(OS_WIN) 214 #elif defined(OS_WIN)
213 AddTrayItem(tray_accessibility_); 215 AddTrayItem(tray_accessibility_);
214 if (media::CoreAudioUtil::IsSupported()) 216 if (media::CoreAudioUtil::IsSupported())
215 AddTrayItem(new TrayAudioWin(this)); 217 AddTrayItem(new TrayAudioWin(this));
216 AddTrayItem(new TrayUpdate(this)); 218 AddTrayItem(tray_update_);
217 AddTrayItem(tray_date_); 219 AddTrayItem(tray_date_);
218 #endif 220 #endif
219 221
220 SetVisible(ash::WmShell::Get() 222 SetVisible(ash::WmShell::Get()
221 ->system_tray_delegate() 223 ->system_tray_delegate()
222 ->GetTrayVisibilityOnStartup()); 224 ->GetTrayVisibilityOnStartup());
223 } 225 }
224 226
225 void SystemTray::AddTrayItem(SystemTrayItem* item) { 227 void SystemTray::AddTrayItem(SystemTrayItem* item) {
226 items_.push_back(item); 228 items_.push_back(item);
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 views::View* SystemTray::GetTrayItemViewForTest(SystemTrayItem* item) { 704 views::View* SystemTray::GetTrayItemViewForTest(SystemTrayItem* item) {
703 std::map<SystemTrayItem*, views::View*>::iterator it = 705 std::map<SystemTrayItem*, views::View*>::iterator it =
704 tray_item_map_.find(item); 706 tray_item_map_.find(item);
705 return it == tray_item_map_.end() ? NULL : it->second; 707 return it == tray_item_map_.end() ? NULL : it->second;
706 } 708 }
707 709
708 TrayCast* SystemTray::GetTrayCastForTesting() const { return tray_cast_; } 710 TrayCast* SystemTray::GetTrayCastForTesting() const { return tray_cast_; }
709 711
710 TrayDate* SystemTray::GetTrayDateForTesting() const { return tray_date_; } 712 TrayDate* SystemTray::GetTrayDateForTesting() const { return tray_date_; }
711 713
714 TrayUpdate* SystemTray::GetTrayUpdateForTesting() const {
715 return tray_update_;
716 }
717
712 bool SystemTray::PerformAction(const ui::Event& event) { 718 bool SystemTray::PerformAction(const ui::Event& event) {
713 // If we're already showing the default view, hide it; otherwise, show it 719 // If we're already showing the default view, hide it; otherwise, show it
714 // (and hide any popup that's currently shown). 720 // (and hide any popup that's currently shown).
715 if (HasSystemBubbleType(SystemTrayBubble::BUBBLE_TYPE_DEFAULT)) { 721 if (HasSystemBubbleType(SystemTrayBubble::BUBBLE_TYPE_DEFAULT)) {
716 system_bubble_->bubble()->Close(); 722 system_bubble_->bubble()->Close();
717 } else { 723 } else {
718 int arrow_offset = TrayBubbleView::InitParams::kArrowDefaultOffset; 724 int arrow_offset = TrayBubbleView::InitParams::kArrowDefaultOffset;
719 if (event.IsMouseEvent() || event.type() == ui::ET_GESTURE_TAP) { 725 if (event.IsMouseEvent() || event.type() == ui::ET_GESTURE_TAP) {
720 const ui::LocatedEvent& located_event = 726 const ui::LocatedEvent& located_event =
721 static_cast<const ui::LocatedEvent&>(event); 727 static_cast<const ui::LocatedEvent&>(event);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 .work_area() 765 .work_area()
760 .height(); 766 .height();
761 if (work_area_height > 0) { 767 if (work_area_height > 0) {
762 UMA_HISTOGRAM_CUSTOM_COUNTS( 768 UMA_HISTOGRAM_CUSTOM_COUNTS(
763 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu", 769 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu",
764 100 * bubble_view->height() / work_area_height, 1, 300, 100); 770 100 * bubble_view->height() / work_area_height, 1, 300, 100);
765 } 771 }
766 } 772 }
767 773
768 } // namespace ash 774 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/tray/system_tray.h ('k') | ash/system/tray/tray_image_item.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698