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

Side by Side Diff: ash/common/system/chromeos/network/tray_sms.cc

Issue 2129913003: Added UMA Metrics for SMS UI in the status area. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated owner & description in actions.xml and other polish. 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/chromeos/network/tray_sms.h" 5 #include "ash/common/system/chromeos/network/tray_sms.h"
6 6
7 #include "ash/common/material_design/material_design_controller.h" 7 #include "ash/common/material_design/material_design_controller.h"
8 #include "ash/common/metrics/user_metrics_action.h"
8 #include "ash/common/system/tray/fixed_sized_scroll_view.h" 9 #include "ash/common/system/tray/fixed_sized_scroll_view.h"
9 #include "ash/common/system/tray/system_tray_bubble.h" 10 #include "ash/common/system/tray/system_tray_bubble.h"
10 #include "ash/common/system/tray/tray_constants.h" 11 #include "ash/common/system/tray/tray_constants.h"
11 #include "ash/common/system/tray/tray_details_view.h" 12 #include "ash/common/system/tray/tray_details_view.h"
12 #include "ash/common/system/tray/tray_item_more.h" 13 #include "ash/common/system/tray/tray_item_more.h"
13 #include "ash/common/system/tray/tray_item_view.h" 14 #include "ash/common/system/tray/tray_item_view.h"
14 #include "ash/common/system/tray/tray_notification_view.h" 15 #include "ash/common/system/tray/tray_notification_view.h"
15 #include "ash/common/system/tray/view_click_listener.h" 16 #include "ash/common/system/tray/view_click_listener.h"
17 #include "ash/common/wm_shell.h"
16 #include "ash/system/tray/system_tray.h" 18 #include "ash/system/tray/system_tray.h"
17 #include "base/strings/string_number_conversions.h" 19 #include "base/strings/string_number_conversions.h"
18 #include "base/strings/utf_string_conversions.h" 20 #include "base/strings/utf_string_conversions.h"
19 #include "chromeos/network/network_event_log.h" 21 #include "chromeos/network/network_event_log.h"
20 #include "chromeos/network/network_handler.h" 22 #include "chromeos/network/network_handler.h"
21 #include "grit/ash_resources.h" 23 #include "grit/ash_resources.h"
22 #include "grit/ash_strings.h" 24 #include "grit/ash_strings.h"
23 #include "ui/base/l10n/l10n_util.h" 25 #include "ui/base/l10n/l10n_util.h"
24 #include "ui/base/resource/resource_bundle.h" 26 #include "ui/base/resource/resource_bundle.h"
25 #include "ui/gfx/paint_vector_icon.h" 27 #include "ui/gfx/paint_vector_icon.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 if (view_type == VIEW_DETAILED) 118 if (view_type == VIEW_DETAILED)
117 LayoutDetailedView(); 119 LayoutDetailedView();
118 else 120 else
119 LayoutNotificationView(); 121 LayoutNotificationView();
120 } 122 }
121 123
122 ~SmsMessageView() override {} 124 ~SmsMessageView() override {}
123 125
124 // Overridden from ButtonListener. 126 // Overridden from ButtonListener.
125 void ButtonPressed(views::Button* sender, const ui::Event& event) override { 127 void ButtonPressed(views::Button* sender, const ui::Event& event) override {
126 owner_->RemoveMessage(index_); 128 if (owner_->RemoveMessage(index_)) {
129 WmShell::Get()->RecordUserMetricsAction(
130 UMA_STATUS_AREA_SMS_DISMISS_MSG_DETAILED_VIEW);
131 }
127 owner_->Update(false); 132 owner_->Update(false);
128 } 133 }
129 134
130 private: 135 private:
131 void LayoutDetailedView() { 136 void LayoutDetailedView() {
132 views::ImageButton* close_button = new views::ImageButton(this); 137 views::ImageButton* close_button = new views::ImageButton(this);
133 close_button->SetImage( 138 close_button->SetImage(
134 views::CustomButton::STATE_NORMAL, 139 views::CustomButton::STATE_NORMAL,
135 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( 140 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
136 IDR_AURA_UBER_TRAY_SMS_DISMISS)); 141 IDR_AURA_UBER_TRAY_SMS_DISMISS));
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 void Update(size_t message_index, 269 void Update(size_t message_index,
265 const std::string& number, 270 const std::string& number,
266 const std::string& text) { 271 const std::string& text) {
267 SmsMessageView* message_view = 272 SmsMessageView* message_view =
268 new SmsMessageView(tray_sms(), SmsMessageView::VIEW_NOTIFICATION, 273 new SmsMessageView(tray_sms(), SmsMessageView::VIEW_NOTIFICATION,
269 message_index_, number, text); 274 message_index_, number, text);
270 UpdateView(message_view); 275 UpdateView(message_view);
271 } 276 }
272 277
273 // Overridden from TrayNotificationView: 278 // Overridden from TrayNotificationView:
274 void OnClose() override { tray_sms()->RemoveMessage(message_index_); } 279 void OnClose() override {
280 if (tray_sms()->RemoveMessage(message_index_)) {
281 WmShell::Get()->RecordUserMetricsAction(
282 UMA_STATUS_AREA_SMS_DISMISS_MSG_NOTIFICATION_VIEW);
283 }
284 }
275 285
276 void OnClickAction() override { owner()->PopupDetailedView(0, true); } 286 void OnClickAction() override { owner()->PopupDetailedView(0, true); }
277 287
278 private: 288 private:
279 TraySms* tray_sms() { return static_cast<TraySms*>(owner()); } 289 TraySms* tray_sms() { return static_cast<TraySms*>(owner()); }
280 290
281 size_t message_index_; 291 size_t message_index_;
282 292
283 DISALLOW_COPY_AND_ASSIGN(SmsNotificationView); 293 DISALLOW_COPY_AND_ASSIGN(SmsNotificationView);
284 }; 294 };
(...skipping 23 matching lines...) Expand all
308 default_->SetVisible(!messages_.empty()); 318 default_->SetVisible(!messages_.empty());
309 return default_; 319 return default_;
310 } 320 }
311 321
312 views::View* TraySms::CreateDetailedView(LoginStatus status) { 322 views::View* TraySms::CreateDetailedView(LoginStatus status) {
313 CHECK(detailed_ == NULL); 323 CHECK(detailed_ == NULL);
314 HideNotificationView(); 324 HideNotificationView();
315 if (messages_.empty()) 325 if (messages_.empty())
316 return NULL; 326 return NULL;
317 detailed_ = new SmsDetailedView(this); 327 detailed_ = new SmsDetailedView(this);
328 WmShell::Get()->RecordUserMetricsAction(UMA_STATUS_AREA_DETAILED_SMS_VIEW);
318 return detailed_; 329 return detailed_;
319 } 330 }
320 331
321 views::View* TraySms::CreateNotificationView(LoginStatus status) { 332 views::View* TraySms::CreateNotificationView(LoginStatus status) {
322 CHECK(notification_ == NULL); 333 CHECK(notification_ == NULL);
323 if (detailed_) 334 if (detailed_)
324 return NULL; 335 return NULL;
325 size_t index; 336 size_t index;
326 std::string number, text; 337 std::string number, text;
327 if (GetLatestMessage(&index, &number, &text)) 338 if (GetLatestMessage(&index, &number, &text))
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 base::DictionaryValue* message; 392 base::DictionaryValue* message;
382 size_t message_index = messages_.GetSize() - 1; 393 size_t message_index = messages_.GetSize() - 1;
383 if (!messages_.GetDictionary(message_index, &message)) 394 if (!messages_.GetDictionary(message_index, &message))
384 return false; 395 return false;
385 if (!GetMessageFromDictionary(message, number, text)) 396 if (!GetMessageFromDictionary(message, number, text))
386 return false; 397 return false;
387 *index = message_index; 398 *index = message_index;
388 return true; 399 return true;
389 } 400 }
390 401
391 void TraySms::RemoveMessage(size_t index) { 402 bool TraySms::RemoveMessage(size_t index) {
392 if (index < messages_.GetSize()) 403 if (index >= messages_.GetSize())
393 messages_.Remove(index, NULL); 404 return false;
405 messages_.Remove(index, NULL);
stevenjb 2016/07/07 17:54:36 NULL -> nullptr throughout the file
bruthig 2016/07/07 18:01:38 Done.
406 return true;
394 } 407 }
395 408
396 void TraySms::Update(bool notify) { 409 void TraySms::Update(bool notify) {
397 if (messages_.empty()) { 410 if (messages_.empty()) {
398 if (default_) 411 if (default_)
399 default_->SetVisible(false); 412 default_->SetVisible(false);
400 if (detailed_) 413 if (detailed_)
401 HideDetailedView(); 414 HideDetailedView();
402 HideNotificationView(); 415 HideNotificationView();
403 } else { 416 } else {
404 if (default_) { 417 if (default_) {
405 default_->SetVisible(true); 418 default_->SetVisible(true);
406 default_->Update(); 419 default_->Update();
407 } 420 }
408 if (detailed_) 421 if (detailed_)
409 detailed_->Update(); 422 detailed_->Update();
410 if (notification_) { 423 if (notification_) {
411 size_t index; 424 size_t index;
412 std::string number, text; 425 std::string number, text;
413 if (GetLatestMessage(&index, &number, &text)) 426 if (GetLatestMessage(&index, &number, &text))
414 notification_->Update(index, number, text); 427 notification_->Update(index, number, text);
415 } else if (notify) { 428 } else if (notify) {
416 ShowNotificationView(); 429 ShowNotificationView();
417 } 430 }
418 } 431 }
419 } 432 }
420 433
421 } // namespace ash 434 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698