| OLD | NEW |
| 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/system/web_notification/web_notification_tray.h" | 5 #include "ash/system/web_notification/web_notification_tray.h" |
| 6 | 6 |
| 7 #include "ash/root_window_controller.h" | 7 #include "ash/root_window_controller.h" |
| 8 #include "ash/shelf/shelf_layout_manager.h" | 8 #include "ash/shelf/shelf_layout_manager.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/shell_window_ids.h" | 10 #include "ash/shell_window_ids.h" |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 } | 295 } |
| 296 | 296 |
| 297 // Private methods. | 297 // Private methods. |
| 298 | 298 |
| 299 bool WebNotificationTray::ShouldShowMessageCenter() { | 299 bool WebNotificationTray::ShouldShowMessageCenter() { |
| 300 return status_area_widget()->login_status() != user::LOGGED_IN_LOCKED && | 300 return status_area_widget()->login_status() != user::LOGGED_IN_LOCKED && |
| 301 !(status_area_widget()->system_tray() && | 301 !(status_area_widget()->system_tray() && |
| 302 status_area_widget()->system_tray()->HasNotificationBubble()); | 302 status_area_widget()->system_tray()->HasNotificationBubble()); |
| 303 } | 303 } |
| 304 | 304 |
| 305 void WebNotificationTray::ShowQuietModeMenu() { | 305 void WebNotificationTray::ShowQuietModeMenu(const ui::Event& event) { |
| 306 base::AutoReset<bool> reset(&should_block_shelf_auto_hide_, true); | 306 base::AutoReset<bool> reset(&should_block_shelf_auto_hide_, true); |
| 307 scoped_ptr<ui::MenuModel> menu_model( | 307 scoped_ptr<ui::MenuModel> menu_model( |
| 308 message_center_tray_->CreateQuietModeMenu()); | 308 message_center_tray_->CreateQuietModeMenu()); |
| 309 quiet_mode_menu_runner_.reset(new views::MenuRunner(menu_model.get())); | 309 quiet_mode_menu_runner_.reset(new views::MenuRunner(menu_model.get())); |
| 310 gfx::Point point; | 310 gfx::Point point; |
| 311 views::View::ConvertPointToScreen(this, &point); | 311 views::View::ConvertPointToScreen(this, &point); |
| 312 if (quiet_mode_menu_runner_->RunMenuAt( | 312 if (quiet_mode_menu_runner_->RunMenuAt( |
| 313 GetWidget(), | 313 GetWidget(), |
| 314 NULL, | 314 NULL, |
| 315 gfx::Rect(point, bounds().size()), | 315 gfx::Rect(point, bounds().size()), |
| 316 views::MenuItemView::BUBBLE_ABOVE, | 316 views::MenuItemView::BUBBLE_ABOVE, |
| 317 ui::GetMenuSourceTypeForEvent(event), |
| 317 views::MenuRunner::HAS_MNEMONICS) == views::MenuRunner::MENU_DELETED) | 318 views::MenuRunner::HAS_MNEMONICS) == views::MenuRunner::MENU_DELETED) |
| 318 return; | 319 return; |
| 319 | 320 |
| 320 quiet_mode_menu_runner_.reset(); | 321 quiet_mode_menu_runner_.reset(); |
| 321 GetShelfLayoutManager()->UpdateAutoHideState(); | 322 GetShelfLayoutManager()->UpdateAutoHideState(); |
| 322 } | 323 } |
| 323 | 324 |
| 324 bool WebNotificationTray::ShouldShowQuietModeMenu(const ui::Event& event) { | 325 bool WebNotificationTray::ShouldShowQuietModeMenu(const ui::Event& event) { |
| 325 // TODO(mukai): Add keyboard event handler. | 326 // TODO(mukai): Add keyboard event handler. |
| 326 if (!event.IsMouseEvent()) | 327 if (!event.IsMouseEvent()) |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 bubble_view == message_center_bubble()->bubble_view()) { | 404 bubble_view == message_center_bubble()->bubble_view()) { |
| 404 message_center_tray_->HideMessageCenterBubble(); | 405 message_center_tray_->HideMessageCenterBubble(); |
| 405 } else if ((popup_bubble() && bubble_view == popup_bubble()->bubble_view()) || | 406 } else if ((popup_bubble() && bubble_view == popup_bubble()->bubble_view()) || |
| 406 popup_collection_.get()) { | 407 popup_collection_.get()) { |
| 407 message_center_tray_->HidePopupBubble(); | 408 message_center_tray_->HidePopupBubble(); |
| 408 } | 409 } |
| 409 } | 410 } |
| 410 | 411 |
| 411 bool WebNotificationTray::PerformAction(const ui::Event& event) { | 412 bool WebNotificationTray::PerformAction(const ui::Event& event) { |
| 412 if (ShouldShowQuietModeMenu(event)) { | 413 if (ShouldShowQuietModeMenu(event)) { |
| 413 ShowQuietModeMenu(); | 414 ShowQuietModeMenu(event); |
| 414 return true; | 415 return true; |
| 415 } | 416 } |
| 416 | 417 |
| 417 if (message_center_bubble()) | 418 if (message_center_bubble()) |
| 418 message_center_tray_->HideMessageCenterBubble(); | 419 message_center_tray_->HideMessageCenterBubble(); |
| 419 else | 420 else |
| 420 message_center_tray_->ShowMessageCenterBubble(); | 421 message_center_tray_->ShowMessageCenterBubble(); |
| 421 return true; | 422 return true; |
| 422 } | 423 } |
| 423 | 424 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 | 517 |
| 517 message_center::MessagePopupBubble* | 518 message_center::MessagePopupBubble* |
| 518 WebNotificationTray::GetPopupBubbleForTest() { | 519 WebNotificationTray::GetPopupBubbleForTest() { |
| 519 if (!popup_bubble()) | 520 if (!popup_bubble()) |
| 520 return NULL; | 521 return NULL; |
| 521 return static_cast<message_center::MessagePopupBubble*>( | 522 return static_cast<message_center::MessagePopupBubble*>( |
| 522 popup_bubble()->bubble()); | 523 popup_bubble()->bubble()); |
| 523 } | 524 } |
| 524 | 525 |
| 525 } // namespace ash | 526 } // namespace ash |
| OLD | NEW |