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

Side by Side Diff: chrome/browser/ui/views/message_center/web_notification_tray.cc

Issue 23636010: Notifications: Add cross-platform UMA: ShowMessageCenter, ShowSettings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added the hash to chromeactions.txt Created 7 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/ui/views/message_center/web_notification_tray.h" 5 #include "chrome/browser/ui/views/message_center/web_notification_tray.h"
6 6
7 #include "base/i18n/number_formatting.h" 7 #include "base/i18n/number_formatting.h"
8 #include "base/strings/string16.h" 8 #include "base/strings/string16.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
11 #include "chrome/browser/status_icons/status_icon.h" 11 #include "chrome/browser/status_icons/status_icon.h"
12 #include "chrome/browser/status_icons/status_icon_menu_model.h" 12 #include "chrome/browser/status_icons/status_icon_menu_model.h"
13 #include "chrome/browser/status_icons/status_tray.h" 13 #include "chrome/browser/status_icons/status_tray.h"
14 #include "content/public/browser/notification_service.h" 14 #include "content/public/browser/notification_service.h"
15 #include "content/public/browser/user_metrics.h"
16 #include "grit/chromium_strings.h" 15 #include "grit/chromium_strings.h"
17 #include "grit/theme_resources.h" 16 #include "grit/theme_resources.h"
18 #include "grit/ui_strings.h" 17 #include "grit/ui_strings.h"
19 #include "ui/base/l10n/l10n_util.h" 18 #include "ui/base/l10n/l10n_util.h"
20 #include "ui/base/resource/resource_bundle.h" 19 #include "ui/base/resource/resource_bundle.h"
21 #include "ui/gfx/canvas.h" 20 #include "ui/gfx/canvas.h"
22 #include "ui/gfx/image/image_skia_operations.h" 21 #include "ui/gfx/image/image_skia_operations.h"
23 #include "ui/gfx/rect.h" 22 #include "ui/gfx/rect.h"
24 #include "ui/gfx/screen.h" 23 #include "ui/gfx/screen.h"
25 #include "ui/gfx/size.h" 24 #include "ui/gfx/size.h"
(...skipping 30 matching lines...) Expand all
56 resource_id = IDR_NOTIFICATION_TRAY_ATTENTION; 55 resource_id = IDR_NOTIFICATION_TRAY_ATTENTION;
57 } else if (is_quiet_mode) { 56 } else if (is_quiet_mode) {
58 resource_id = IDR_NOTIFICATION_TRAY_DO_NOT_DISTURB_EMPTY; 57 resource_id = IDR_NOTIFICATION_TRAY_DO_NOT_DISTURB_EMPTY;
59 } 58 }
60 59
61 return rb.GetImageSkiaNamed(resource_id); 60 return rb.GetImageSkiaNamed(resource_id);
62 } 61 }
63 62
64 } // namespace 63 } // namespace
65 64
66 using content::UserMetricsAction;
67
68 namespace message_center { 65 namespace message_center {
69 66
70 namespace internal { 67 namespace internal {
71 68
72 // Gets the position of the taskbar from the work area bounds. Returns 69 // Gets the position of the taskbar from the work area bounds. Returns
73 // ALIGNMENT_NONE if position cannot be found. 70 // ALIGNMENT_NONE if position cannot be found.
74 Alignment GetTaskbarAlignment() { 71 Alignment GetTaskbarAlignment() {
75 gfx::Screen* screen = gfx::Screen::GetNativeScreen(); 72 gfx::Screen* screen = gfx::Screen::GetNativeScreen();
76 // TODO(dewittj): It's possible GetPrimaryDisplay is wrong. 73 // TODO(dewittj): It's possible GetPrimaryDisplay is wrong.
77 gfx::Rect screen_bounds = screen->GetPrimaryDisplay().bounds(); 74 gfx::Rect screen_bounds = screen->GetPrimaryDisplay().bounds();
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 } 151 }
155 152
156 bool WebNotificationTray::ShowPopups() { 153 bool WebNotificationTray::ShowPopups() {
157 popup_collection_.reset(new message_center::MessagePopupCollection( 154 popup_collection_.reset(new message_center::MessagePopupCollection(
158 NULL, message_center(), message_center_tray_.get(), false)); 155 NULL, message_center(), message_center_tray_.get(), false));
159 return true; 156 return true;
160 } 157 }
161 158
162 void WebNotificationTray::HidePopups() { popup_collection_.reset(); } 159 void WebNotificationTray::HidePopups() { popup_collection_.reset(); }
163 160
164 bool WebNotificationTray::ShowMessageCenterInternal(bool show_settings) { 161 bool WebNotificationTray::ShowMessageCenter() {
165 content::RecordAction(UserMetricsAction("Notifications.ShowMessageCenter")); 162 message_center_delegate_ =
166 163 new MessageCenterWidgetDelegate(this,
167 // Message center delegate will be set to NULL when the message center 164 message_center_tray_.get(),
168 // widget's Close method is called so we don't need to worry about 165 false, // settings initally invisible
169 // use-after-free issues. 166 GetPositionInfo());
170 message_center_delegate_ = new MessageCenterWidgetDelegate(
171 this,
172 message_center_tray_.get(),
173 show_settings, // settings initally invisible
174 GetPositionInfo());
175 167
176 return true; 168 return true;
177 } 169 }
178 170
179 bool WebNotificationTray::ShowMessageCenter() {
180 return ShowMessageCenterInternal(/*show_settings =*/false);
181 }
182
183 void WebNotificationTray::HideMessageCenter() { 171 void WebNotificationTray::HideMessageCenter() {
184 if (message_center_delegate_) { 172 if (message_center_delegate_) {
185 views::Widget* widget = message_center_delegate_->GetWidget(); 173 views::Widget* widget = message_center_delegate_->GetWidget();
186 if (widget) 174 if (widget)
187 widget->Close(); 175 widget->Close();
188 } 176 }
189 } 177 }
190 178
191 bool WebNotificationTray::ShowNotifierSettings() { 179 bool WebNotificationTray::ShowNotifierSettings() {
192 if (message_center_delegate_) { 180 if (message_center_delegate_) {
193 message_center_delegate_->SetSettingsVisible(true); 181 message_center_delegate_->SetSettingsVisible(true);
194 return true; 182 return true;
195 } 183 }
196 return ShowMessageCenterInternal(/*show_settings =*/true); 184 message_center_delegate_ =
185 new MessageCenterWidgetDelegate(this,
186 message_center_tray_.get(),
187 true, // settings initally visible
188 GetPositionInfo());
189
190 return true;
197 } 191 }
198 192
199 void WebNotificationTray::OnMessageCenterTrayChanged() { 193 void WebNotificationTray::OnMessageCenterTrayChanged() {
200 if (status_icon_) { 194 if (status_icon_) {
201 bool quiet_mode_state = message_center()->IsQuietMode(); 195 bool quiet_mode_state = message_center()->IsQuietMode();
202 if (last_quiet_mode_state_ != quiet_mode_state) { 196 if (last_quiet_mode_state_ != quiet_mode_state) {
203 last_quiet_mode_state_ = quiet_mode_state; 197 last_quiet_mode_state_ = quiet_mode_state;
204 198
205 // Quiet mode has changed, update the quiet mode menu. 199 // Quiet mode has changed, update the quiet mode menu.
206 status_icon_menu_->SetCommandIdChecked(kToggleQuietMode, 200 status_icon_menu_->SetCommandIdChecked(kToggleQuietMode,
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 status_icon_menu_ = menu.get(); 363 status_icon_menu_ = menu.get();
370 status_icon->SetContextMenu(menu.Pass()); 364 status_icon->SetContextMenu(menu.Pass());
371 } 365 }
372 366
373 MessageCenterWidgetDelegate* 367 MessageCenterWidgetDelegate*
374 WebNotificationTray::GetMessageCenterWidgetDelegateForTest() { 368 WebNotificationTray::GetMessageCenterWidgetDelegateForTest() {
375 return message_center_delegate_; 369 return message_center_delegate_;
376 } 370 }
377 371
378 } // namespace message_center 372 } // namespace message_center
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/message_center/web_notification_tray.h ('k') | tools/metrics/actions/chromeactions.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698