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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: ash/common/system/tray/system_tray_bubble.cc
diff --git a/ash/common/system/tray/system_tray_bubble.cc b/ash/common/system/tray/system_tray_bubble.cc
index ebe94148f4bb0c0cc063faeb53604107ba141025..c131853fe7435fd44909ba6c20b9cad7291352ba 100644
--- a/ash/common/system/tray/system_tray_bubble.cc
+++ b/ash/common/system/tray/system_tray_bubble.cc
@@ -4,6 +4,9 @@
#include "ash/common/system/tray/system_tray_bubble.h"
+#include <utility>
+#include <vector>
+
#include "ash/common/system/tray/system_tray.h"
#include "ash/common/system/tray/system_tray_delegate.h"
#include "ash/common/system/tray/system_tray_item.h"
@@ -11,6 +14,7 @@
#include "ash/common/system/tray/tray_constants.h"
#include "ash/common/system/tray/tray_popup_item_container.h"
#include "ash/common/wm_shell.h"
+#include "base/metrics/histogram_macros.h"
#include "base/threading/thread_task_runner_handle.h"
#include "ui/compositor/layer.h"
#include "ui/compositor/layer_animation_observer.h"
@@ -274,8 +278,24 @@ bool SystemTrayBubble::ShouldShowShelf() const {
return false;
}
+void SystemTrayBubble::RecordVisibleRowMetrics() {
+ if (bubble_type_ != BUBBLE_TYPE_DEFAULT) {
+ 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.
+ return;
+ }
+
+ for (const std::pair<SystemTrayItem::ItemType, views::View*>& pair :
+ tray_item_view_map_) {
+ if (pair.second->visible()) {
+ UMA_HISTOGRAM_ENUMERATION("Ash.SystemMenu.DefaultView.VisibleItems",
+ pair.first, SystemTrayItem::COUNT);
+ }
+ }
+}
+
void SystemTrayBubble::CreateItemViews(LoginStatus login_status) {
- std::vector<views::View*> item_views;
+ tray_item_view_map_.clear();
+
// If a system modal dialog is present, create the same tray as
// in locked state.
if (WmShell::Get()->IsSystemModalWindowOpen() &&
@@ -284,33 +304,44 @@ void SystemTrayBubble::CreateItemViews(LoginStatus login_status) {
}
views::View* focus_view = NULL;
+ const bool is_default_bubble = bubble_type_ == BUBBLE_TYPE_DEFAULT;
for (size_t i = 0; i < items_.size(); ++i) {
- views::View* view = NULL;
+ 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.
switch (bubble_type_) {
case BUBBLE_TYPE_DEFAULT:
- view = items_[i]->CreateDefaultView(login_status);
+ item_view = items_[i]->CreateDefaultView(login_status);
if (items_[i]->restore_focus())
- focus_view = view;
+ focus_view = item_view;
break;
case BUBBLE_TYPE_DETAILED:
- view = items_[i]->CreateDetailedView(login_status);
+ item_view = items_[i]->CreateDetailedView(login_status);
break;
case BUBBLE_TYPE_NOTIFICATION:
- view = items_[i]->CreateNotificationView(login_status);
+ item_view = items_[i]->CreateNotificationView(login_status);
break;
}
- if (view)
- item_views.push_back(view);
+ if (item_view) {
+ views::View* tray_popup_item_container = new TrayPopupItemContainer(
+ item_view, is_default_bubble, is_default_bubble);
+
tdanderson 2016/07/19 21:58:39 nit: omit blank lines at 326 and 328
bruthig 2016/07/20 18:15:52 Done.
+ bubble_view_->AddChildView(tray_popup_item_container);
+
+ tray_item_view_map_[items_[i]->type()] = tray_popup_item_container;
+ }
}
- bool is_default_bubble = bubble_type_ == BUBBLE_TYPE_DEFAULT;
- for (size_t i = 0; i < item_views.size(); ++i) {
- // For default view, draw bottom border for each item, except the last
- // 2 items, which are the bottom header row and the one just above it.
- bubble_view_->AddChildView(new TrayPopupItemContainer(
- item_views[i], is_default_bubble,
- is_default_bubble && (i < item_views.size() - 2)));
+ // For default view, draw bottom border for each item, except the last
+ // 2 items, which are the bottom header row and the one just above it.
+ const int view_count = bubble_view_->child_count();
+ if (is_default_bubble && view_count > 1) {
+ bubble_view_->child_at(view_count - 1)
+ ->SetBorder(views::Border::NullBorder());
+ if (view_count > 2) {
+ bubble_view_->child_at(view_count - 2)
+ ->SetBorder(views::Border::NullBorder());
+ }
}
+
if (focus_view)
focus_view->RequestFocus();
}

Powered by Google App Engine
This is Rietveld 408576698