| 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 "ui/message_center/views/message_view.h" | 5 #include "ui/message_center/views/message_view.h" |
| 6 | 6 |
| 7 #include "grit/ui_resources.h" | 7 #include "grit/ui_resources.h" |
| 8 #include "grit/ui_strings.h" | 8 #include "grit/ui_strings.h" |
| 9 #include "ui/base/accessibility/accessible_view_state.h" | 9 #include "ui/base/accessibility/accessible_view_state.h" |
| 10 #include "ui/base/l10n/l10n_util.h" | 10 #include "ui/base/l10n/l10n_util.h" |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 class MessageViewContextMenuController : public views::ContextMenuController { | 294 class MessageViewContextMenuController : public views::ContextMenuController { |
| 295 public: | 295 public: |
| 296 MessageViewContextMenuController( | 296 MessageViewContextMenuController( |
| 297 message_center::MessageCenter* message_center, | 297 message_center::MessageCenter* message_center, |
| 298 const Notification& notification); | 298 const Notification& notification); |
| 299 virtual ~MessageViewContextMenuController(); | 299 virtual ~MessageViewContextMenuController(); |
| 300 | 300 |
| 301 protected: | 301 protected: |
| 302 // Overridden from views::ContextMenuController: | 302 // Overridden from views::ContextMenuController: |
| 303 virtual void ShowContextMenuForView(views::View* source, | 303 virtual void ShowContextMenuForView(views::View* source, |
| 304 const gfx::Point& point) OVERRIDE; | 304 const gfx::Point& point, |
| 305 ui::MenuSourceType source_type) OVERRIDE; |
| 305 | 306 |
| 306 message_center::MessageCenter* message_center_; | 307 message_center::MessageCenter* message_center_; |
| 307 std::string notification_id_; | 308 std::string notification_id_; |
| 308 string16 display_source_; | 309 string16 display_source_; |
| 309 std::string extension_id_; | 310 std::string extension_id_; |
| 310 }; | 311 }; |
| 311 | 312 |
| 312 MessageViewContextMenuController::MessageViewContextMenuController( | 313 MessageViewContextMenuController::MessageViewContextMenuController( |
| 313 message_center::MessageCenter* message_center, | 314 message_center::MessageCenter* message_center, |
| 314 const Notification& notification) | 315 const Notification& notification) |
| 315 : message_center_(message_center), | 316 : message_center_(message_center), |
| 316 notification_id_(notification.id()), | 317 notification_id_(notification.id()), |
| 317 display_source_(notification.display_source()), | 318 display_source_(notification.display_source()), |
| 318 extension_id_(notification.extension_id()) { | 319 extension_id_(notification.extension_id()) { |
| 319 } | 320 } |
| 320 | 321 |
| 321 MessageViewContextMenuController::~MessageViewContextMenuController() { | 322 MessageViewContextMenuController::~MessageViewContextMenuController() { |
| 322 } | 323 } |
| 323 | 324 |
| 324 void MessageViewContextMenuController::ShowContextMenuForView( | 325 void MessageViewContextMenuController::ShowContextMenuForView( |
| 325 views::View* source, | 326 views::View* source, |
| 326 const gfx::Point& point) { | 327 const gfx::Point& point, |
| 328 ui::MenuSourceType source_type) { |
| 327 MenuModel menu_model(message_center_, notification_id_, | 329 MenuModel menu_model(message_center_, notification_id_, |
| 328 display_source_, extension_id_); | 330 display_source_, extension_id_); |
| 329 if (menu_model.GetItemCount() == 0) | 331 if (menu_model.GetItemCount() == 0) |
| 330 return; | 332 return; |
| 331 | 333 |
| 332 views::MenuRunner menu_runner(&menu_model); | 334 views::MenuRunner menu_runner(&menu_model); |
| 333 | 335 |
| 334 ignore_result(menu_runner.RunMenuAt( | 336 ignore_result(menu_runner.RunMenuAt( |
| 335 source->GetWidget()->GetTopLevelWidget(), | 337 source->GetWidget()->GetTopLevelWidget(), |
| 336 NULL, | 338 NULL, |
| 337 gfx::Rect(point, gfx::Size()), | 339 gfx::Rect(point, gfx::Size()), |
| 338 views::MenuItemView::TOPRIGHT, | 340 views::MenuItemView::TOPRIGHT, |
| 341 source_type, |
| 339 views::MenuRunner::HAS_MNEMONICS)); | 342 views::MenuRunner::HAS_MNEMONICS)); |
| 340 } | 343 } |
| 341 | 344 |
| 342 MessageView::MessageView(const Notification& notification, | 345 MessageView::MessageView(const Notification& notification, |
| 343 MessageCenter* message_center, | 346 MessageCenter* message_center, |
| 344 bool expanded) | 347 bool expanded) |
| 345 : message_center_(message_center), | 348 : message_center_(message_center), |
| 346 notification_id_(notification.id()), | 349 notification_id_(notification.id()), |
| 347 context_menu_controller_(new MessageViewContextMenuController( | 350 context_menu_controller_(new MessageViewContextMenuController( |
| 348 message_center, notification)), | 351 message_center, notification)), |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 is_expanded_ = true; | 475 is_expanded_ = true; |
| 473 message_center_->ExpandNotification(notification_id_); | 476 message_center_->ExpandNotification(notification_id_); |
| 474 } | 477 } |
| 475 } | 478 } |
| 476 | 479 |
| 477 void MessageView::OnSlideOut() { | 480 void MessageView::OnSlideOut() { |
| 478 message_center_->RemoveNotification(notification_id_, true); // By user. | 481 message_center_->RemoveNotification(notification_id_, true); // By user. |
| 479 } | 482 } |
| 480 | 483 |
| 481 } // namespace message_center | 484 } // namespace message_center |
| OLD | NEW |