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

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

Issue 252513004: Reland r265807: "Moves the notification icon out of th..." (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Disable tray size test on Vista since it won't have any effect on a new icon. Created 6 years, 8 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/prefs/pref_service.h"
8 #include "base/strings/string16.h" 9 #include "base/strings/string16.h"
9 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/browser_process.h" 11 #include "chrome/browser/browser_process.h"
11 #include "chrome/browser/status_icons/status_icon.h" 12 #include "chrome/browser/status_icons/status_icon.h"
12 #include "chrome/browser/status_icons/status_icon_menu_model.h" 13 #include "chrome/browser/status_icons/status_icon_menu_model.h"
13 #include "chrome/browser/status_icons/status_tray.h" 14 #include "chrome/browser/status_icons/status_tray.h"
15 #include "chrome/common/pref_names.h"
14 #include "content/public/browser/notification_service.h" 16 #include "content/public/browser/notification_service.h"
15 #include "grit/chromium_strings.h" 17 #include "grit/chromium_strings.h"
16 #include "grit/theme_resources.h" 18 #include "grit/theme_resources.h"
17 #include "grit/ui_strings.h" 19 #include "grit/ui_strings.h"
18 #include "ui/base/l10n/l10n_util.h" 20 #include "ui/base/l10n/l10n_util.h"
19 #include "ui/base/resource/resource_bundle.h" 21 #include "ui/base/resource/resource_bundle.h"
20 #include "ui/gfx/canvas.h" 22 #include "ui/gfx/canvas.h"
21 #include "ui/gfx/image/image_skia_operations.h" 23 #include "ui/gfx/image/image_skia_operations.h"
22 #include "ui/gfx/rect.h" 24 #include "ui/gfx/rect.h"
23 #include "ui/gfx/screen.h" 25 #include "ui/gfx/screen.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 anchor_alignment = 116 anchor_alignment =
115 (Alignment)(anchor_alignment | 117 (Alignment)(anchor_alignment |
116 (center.x() > corner.x() ? ALIGNMENT_LEFT : ALIGNMENT_RIGHT)); 118 (center.x() > corner.x() ? ALIGNMENT_LEFT : ALIGNMENT_RIGHT));
117 119
118 return anchor_alignment; 120 return anchor_alignment;
119 } 121 }
120 122
121 } // namespace internal 123 } // namespace internal
122 124
123 MessageCenterTrayDelegate* CreateMessageCenterTray() { 125 MessageCenterTrayDelegate* CreateMessageCenterTray() {
124 return new WebNotificationTray(); 126 return new WebNotificationTray(g_browser_process->local_state());
125 } 127 }
126 128
127 WebNotificationTray::WebNotificationTray() 129 WebNotificationTray::WebNotificationTray(PrefService* local_state)
128 : message_center_delegate_(NULL), 130 : message_center_delegate_(NULL),
129 status_icon_(NULL), 131 status_icon_(NULL),
130 status_icon_menu_(NULL), 132 status_icon_menu_(NULL),
131 should_update_tray_content_(true) { 133 should_update_tray_content_(true) {
132 message_center_tray_.reset( 134 message_center_tray_.reset(
133 new MessageCenterTray(this, g_browser_process->message_center())); 135 new MessageCenterTray(this, g_browser_process->message_center()));
134 last_quiet_mode_state_ = message_center()->IsQuietMode(); 136 last_quiet_mode_state_ = message_center()->IsQuietMode();
135 popup_collection_.reset(new message_center::MessagePopupCollection( 137 popup_collection_.reset(new message_center::MessagePopupCollection(
136 NULL, message_center(), message_center_tray_.get(), false)); 138 NULL, message_center(), message_center_tray_.get(), false));
139
140 #if defined(OS_WIN)
141 // |local_state| can be NULL in tests.
142 if (local_state) {
143 did_force_tray_visible_.reset(new BooleanPrefMember());
144 did_force_tray_visible_->Init(prefs::kMessageCenterForcedOnTaskbar,
145 local_state);
146 }
147 #endif
137 } 148 }
138 149
139 WebNotificationTray::~WebNotificationTray() { 150 WebNotificationTray::~WebNotificationTray() {
140 // Reset this early so that delegated events during destruction don't cause 151 // Reset this early so that delegated events during destruction don't cause
141 // problems. 152 // problems.
142 popup_collection_.reset(); 153 popup_collection_.reset();
143 message_center_tray_.reset(); 154 message_center_tray_.reset();
144 DestroyStatusIcon(); 155 DestroyStatusIcon();
145 } 156 }
146 157
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 if (!status_tray) 344 if (!status_tray)
334 return; 345 return;
335 346
336 status_icon_ = status_tray->CreateStatusIcon( 347 status_icon_ = status_tray->CreateStatusIcon(
337 StatusTray::NOTIFICATION_TRAY_ICON, image, tool_tip); 348 StatusTray::NOTIFICATION_TRAY_ICON, image, tool_tip);
338 if (!status_icon_) 349 if (!status_icon_)
339 return; 350 return;
340 351
341 status_icon_->AddObserver(this); 352 status_icon_->AddObserver(this);
342 AddQuietModeMenu(status_icon_); 353 AddQuietModeMenu(status_icon_);
354 #if defined(OS_WIN)
355 if (did_force_tray_visible_.get() && !did_force_tray_visible_->GetValue()) {
356 EnforceStatusIconVisible();
357 did_force_tray_visible_->SetValue(true);
358 }
359 #endif
343 } 360 }
344 361
345 void WebNotificationTray::DestroyStatusIcon() { 362 void WebNotificationTray::DestroyStatusIcon() {
346 if (!status_icon_) 363 if (!status_icon_)
347 return; 364 return;
348 365
349 status_icon_->RemoveObserver(this); 366 status_icon_->RemoveObserver(this);
350 StatusTray* status_tray = g_browser_process->status_tray(); 367 StatusTray* status_tray = g_browser_process->status_tray();
351 if (status_tray) 368 if (status_tray)
352 status_tray->RemoveStatusIcon(status_icon_); 369 status_tray->RemoveStatusIcon(status_icon_);
(...skipping 16 matching lines...) Expand all
369 status_icon_menu_ = menu.get(); 386 status_icon_menu_ = menu.get();
370 status_icon->SetContextMenu(menu.Pass()); 387 status_icon->SetContextMenu(menu.Pass());
371 } 388 }
372 389
373 MessageCenterWidgetDelegate* 390 MessageCenterWidgetDelegate*
374 WebNotificationTray::GetMessageCenterWidgetDelegateForTest() { 391 WebNotificationTray::GetMessageCenterWidgetDelegateForTest() {
375 return message_center_delegate_; 392 return message_center_delegate_;
376 } 393 }
377 394
378 } // namespace message_center 395 } // namespace message_center
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698