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

Side by Side Diff: ash/common/system/tray/system_tray_bubble.cc

Issue 2162153002: Added Ash.SystemMenu.DefaultView.VisibleItems histogram. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed ash_unittests compile errors. Created 4 years, 5 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
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/common/system/tray/system_tray_bubble.h" 5 #include "ash/common/system/tray/system_tray_bubble.h"
6 6
7 #include <utility>
8 #include <vector>
9
7 #include "ash/common/system/tray/system_tray.h" 10 #include "ash/common/system/tray/system_tray.h"
8 #include "ash/common/system/tray/system_tray_delegate.h" 11 #include "ash/common/system/tray/system_tray_delegate.h"
9 #include "ash/common/system/tray/system_tray_item.h" 12 #include "ash/common/system/tray/system_tray_item.h"
10 #include "ash/common/system/tray/tray_bubble_wrapper.h" 13 #include "ash/common/system/tray/tray_bubble_wrapper.h"
11 #include "ash/common/system/tray/tray_constants.h" 14 #include "ash/common/system/tray/tray_constants.h"
12 #include "ash/common/system/tray/tray_popup_item_container.h" 15 #include "ash/common/system/tray/tray_popup_item_container.h"
13 #include "ash/common/wm_shell.h" 16 #include "ash/common/wm_shell.h"
17 #include "base/metrics/histogram_macros.h"
14 #include "base/threading/thread_task_runner_handle.h" 18 #include "base/threading/thread_task_runner_handle.h"
15 #include "ui/compositor/layer.h" 19 #include "ui/compositor/layer.h"
16 #include "ui/compositor/layer_animation_observer.h" 20 #include "ui/compositor/layer_animation_observer.h"
17 #include "ui/compositor/scoped_layer_animation_settings.h" 21 #include "ui/compositor/scoped_layer_animation_settings.h"
18 #include "ui/gfx/canvas.h" 22 #include "ui/gfx/canvas.h"
19 #include "ui/views/layout/box_layout.h" 23 #include "ui/views/layout/box_layout.h"
20 #include "ui/views/view.h" 24 #include "ui/views/view.h"
21 #include "ui/views/widget/widget.h" 25 #include "ui/views/widget/widget.h"
22 26
23 using views::TrayBubbleView; 27 using views::TrayBubbleView;
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 271
268 bool SystemTrayBubble::ShouldShowShelf() const { 272 bool SystemTrayBubble::ShouldShowShelf() const {
269 for (std::vector<ash::SystemTrayItem*>::const_iterator it = items_.begin(); 273 for (std::vector<ash::SystemTrayItem*>::const_iterator it = items_.begin();
270 it != items_.end(); ++it) { 274 it != items_.end(); ++it) {
271 if ((*it)->ShouldShowShelf()) 275 if ((*it)->ShouldShowShelf())
272 return true; 276 return true;
273 } 277 }
274 return false; 278 return false;
275 } 279 }
276 280
281 void SystemTrayBubble::RecordVisibleRowMetrics() {
282 if (bubble_type_ != BUBBLE_TYPE_DEFAULT) {
283 DCHECK(false) << "Only the BUBBLE_TYPE_DEFAULT BubbleType is supported.";
tdanderson 2016/07/19 21:58:40 Not sure if we need a DCHECK or a message here.
bruthig 2016/07/20 18:15:52 Removed.
284 return;
285 }
286
287 for (const std::pair<SystemTrayItem::ItemType, views::View*>& pair :
288 tray_item_view_map_) {
289 if (pair.second->visible()) {
290 UMA_HISTOGRAM_ENUMERATION("Ash.SystemMenu.DefaultView.VisibleItems",
291 pair.first, SystemTrayItem::COUNT);
292 }
293 }
294 }
295
277 void SystemTrayBubble::CreateItemViews(LoginStatus login_status) { 296 void SystemTrayBubble::CreateItemViews(LoginStatus login_status) {
278 std::vector<views::View*> item_views; 297 tray_item_view_map_.clear();
298
279 // If a system modal dialog is present, create the same tray as 299 // If a system modal dialog is present, create the same tray as
280 // in locked state. 300 // in locked state.
281 if (WmShell::Get()->IsSystemModalWindowOpen() && 301 if (WmShell::Get()->IsSystemModalWindowOpen() &&
282 login_status != LoginStatus::NOT_LOGGED_IN) { 302 login_status != LoginStatus::NOT_LOGGED_IN) {
283 login_status = LoginStatus::LOCKED; 303 login_status = LoginStatus::LOCKED;
284 } 304 }
285 305
286 views::View* focus_view = NULL; 306 views::View* focus_view = NULL;
307 const bool is_default_bubble = bubble_type_ == BUBBLE_TYPE_DEFAULT;
287 for (size_t i = 0; i < items_.size(); ++i) { 308 for (size_t i = 0; i < items_.size(); ++i) {
288 views::View* view = NULL; 309 views::View* item_view = NULL;
tdanderson 2016/07/19 21:58:40 nit: nullptr here and line 306
bruthig 2016/07/20 18:15:52 Done.
289 switch (bubble_type_) { 310 switch (bubble_type_) {
290 case BUBBLE_TYPE_DEFAULT: 311 case BUBBLE_TYPE_DEFAULT:
291 view = items_[i]->CreateDefaultView(login_status); 312 item_view = items_[i]->CreateDefaultView(login_status);
292 if (items_[i]->restore_focus()) 313 if (items_[i]->restore_focus())
293 focus_view = view; 314 focus_view = item_view;
294 break; 315 break;
295 case BUBBLE_TYPE_DETAILED: 316 case BUBBLE_TYPE_DETAILED:
296 view = items_[i]->CreateDetailedView(login_status); 317 item_view = items_[i]->CreateDetailedView(login_status);
297 break; 318 break;
298 case BUBBLE_TYPE_NOTIFICATION: 319 case BUBBLE_TYPE_NOTIFICATION:
299 view = items_[i]->CreateNotificationView(login_status); 320 item_view = items_[i]->CreateNotificationView(login_status);
300 break; 321 break;
301 } 322 }
302 if (view) 323 if (item_view) {
303 item_views.push_back(view); 324 views::View* tray_popup_item_container = new TrayPopupItemContainer(
325 item_view, is_default_bubble, is_default_bubble);
326
tdanderson 2016/07/19 21:58:39 nit: omit blank lines at 326 and 328
bruthig 2016/07/20 18:15:52 Done.
327 bubble_view_->AddChildView(tray_popup_item_container);
328
329 tray_item_view_map_[items_[i]->type()] = tray_popup_item_container;
330 }
304 } 331 }
305 332
306 bool is_default_bubble = bubble_type_ == BUBBLE_TYPE_DEFAULT; 333 // For default view, draw bottom border for each item, except the last
307 for (size_t i = 0; i < item_views.size(); ++i) { 334 // 2 items, which are the bottom header row and the one just above it.
308 // For default view, draw bottom border for each item, except the last 335 const int view_count = bubble_view_->child_count();
309 // 2 items, which are the bottom header row and the one just above it. 336 if (is_default_bubble && view_count > 1) {
310 bubble_view_->AddChildView(new TrayPopupItemContainer( 337 bubble_view_->child_at(view_count - 1)
311 item_views[i], is_default_bubble, 338 ->SetBorder(views::Border::NullBorder());
312 is_default_bubble && (i < item_views.size() - 2))); 339 if (view_count > 2) {
340 bubble_view_->child_at(view_count - 2)
341 ->SetBorder(views::Border::NullBorder());
342 }
313 } 343 }
344
314 if (focus_view) 345 if (focus_view)
315 focus_view->RequestFocus(); 346 focus_view->RequestFocus();
316 } 347 }
317 348
318 } // namespace ash 349 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698