OLD | NEW |
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/location.h" |
8 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "base/single_thread_task_runner.h" |
9 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
10 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "base/thread_task_runner_handle.h" |
11 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
12 #include "chrome/browser/status_icons/status_icon.h" | 15 #include "chrome/browser/status_icons/status_icon.h" |
13 #include "chrome/browser/status_icons/status_icon_menu_model.h" | 16 #include "chrome/browser/status_icons/status_icon_menu_model.h" |
14 #include "chrome/browser/status_icons/status_tray.h" | 17 #include "chrome/browser/status_icons/status_tray.h" |
15 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
16 #include "chrome/grit/chromium_strings.h" | 19 #include "chrome/grit/chromium_strings.h" |
17 #include "chrome/grit/generated_resources.h" | 20 #include "chrome/grit/generated_resources.h" |
18 #include "content/public/browser/notification_service.h" | 21 #include "content/public/browser/notification_service.h" |
19 #include "grit/theme_resources.h" | 22 #include "grit/theme_resources.h" |
20 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 } | 251 } |
249 } else if (message_center()->NotificationCount() == 0) { | 252 } else if (message_center()->NotificationCount() == 0) { |
250 // If there's no existing status icon and we still don't have any | 253 // If there's no existing status icon and we still don't have any |
251 // notifications to display, nothing needs to be done. | 254 // notifications to display, nothing needs to be done. |
252 return; | 255 return; |
253 } | 256 } |
254 | 257 |
255 // See the comments in ash/system/web_notification/web_notification_tray.cc | 258 // See the comments in ash/system/web_notification/web_notification_tray.cc |
256 // for why PostTask. | 259 // for why PostTask. |
257 should_update_tray_content_ = true; | 260 should_update_tray_content_ = true; |
258 base::MessageLoop::current()->PostTask( | 261 base::ThreadTaskRunnerHandle::Get()->PostTask( |
259 FROM_HERE, | 262 FROM_HERE, |
260 base::Bind(&WebNotificationTray::UpdateStatusIcon, AsWeakPtr())); | 263 base::Bind(&WebNotificationTray::UpdateStatusIcon, AsWeakPtr())); |
261 } | 264 } |
262 | 265 |
263 void WebNotificationTray::OnStatusIconClicked() { | 266 void WebNotificationTray::OnStatusIconClicked() { |
264 // TODO(dewittj): It's possible GetNativeScreen is wrong for win-aura. | 267 // TODO(dewittj): It's possible GetNativeScreen is wrong for win-aura. |
265 gfx::Screen* screen = gfx::Screen::GetNativeScreen(); | 268 gfx::Screen* screen = gfx::Screen::GetNativeScreen(); |
266 mouse_click_point_ = screen->GetCursorScreenPoint(); | 269 mouse_click_point_ = screen->GetCursorScreenPoint(); |
267 message_center_tray_->ToggleMessageCenterBubble(); | 270 message_center_tray_->ToggleMessageCenterBubble(); |
268 } | 271 } |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 status_icon_menu_ = menu.get(); | 422 status_icon_menu_ = menu.get(); |
420 status_icon->SetContextMenu(menu.Pass()); | 423 status_icon->SetContextMenu(menu.Pass()); |
421 } | 424 } |
422 | 425 |
423 MessageCenterWidgetDelegate* | 426 MessageCenterWidgetDelegate* |
424 WebNotificationTray::GetMessageCenterWidgetDelegateForTest() { | 427 WebNotificationTray::GetMessageCenterWidgetDelegateForTest() { |
425 return message_center_delegate_; | 428 return message_center_delegate_; |
426 } | 429 } |
427 | 430 |
428 } // namespace message_center | 431 } // namespace message_center |
OLD | NEW |