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 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 | 293 |
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( |
304 const gfx::Point& point) OVERRIDE; | 304 views::View* source, |
| 305 const gfx::Point& point, |
| 306 ui::ContextMenuSourceType source_type) OVERRIDE; |
305 | 307 |
306 message_center::MessageCenter* message_center_; | 308 message_center::MessageCenter* message_center_; |
307 std::string notification_id_; | 309 std::string notification_id_; |
308 string16 display_source_; | 310 string16 display_source_; |
309 std::string extension_id_; | 311 std::string extension_id_; |
310 }; | 312 }; |
311 | 313 |
312 MessageViewContextMenuController::MessageViewContextMenuController( | 314 MessageViewContextMenuController::MessageViewContextMenuController( |
313 message_center::MessageCenter* message_center, | 315 message_center::MessageCenter* message_center, |
314 const Notification& notification) | 316 const Notification& notification) |
315 : message_center_(message_center), | 317 : message_center_(message_center), |
316 notification_id_(notification.id()), | 318 notification_id_(notification.id()), |
317 display_source_(notification.display_source()), | 319 display_source_(notification.display_source()), |
318 extension_id_(notification.extension_id()) { | 320 extension_id_(notification.extension_id()) { |
319 } | 321 } |
320 | 322 |
321 MessageViewContextMenuController::~MessageViewContextMenuController() { | 323 MessageViewContextMenuController::~MessageViewContextMenuController() { |
322 } | 324 } |
323 | 325 |
324 void MessageViewContextMenuController::ShowContextMenuForView( | 326 void MessageViewContextMenuController::ShowContextMenuForView( |
325 views::View* source, | 327 views::View* source, |
326 const gfx::Point& point) { | 328 const gfx::Point& point, |
| 329 ui::ContextMenuSourceType source_type) { |
327 MenuModel menu_model(message_center_, notification_id_, | 330 MenuModel menu_model(message_center_, notification_id_, |
328 display_source_, extension_id_); | 331 display_source_, extension_id_); |
329 if (menu_model.GetItemCount() == 0) | 332 if (menu_model.GetItemCount() == 0) |
330 return; | 333 return; |
331 | 334 |
332 views::MenuRunner menu_runner(&menu_model); | 335 views::MenuRunner menu_runner(&menu_model); |
333 | 336 |
334 ignore_result(menu_runner.RunMenuAt( | 337 ignore_result(menu_runner.RunContextMenuAt( |
335 source->GetWidget()->GetTopLevelWidget(), | 338 source->GetWidget()->GetTopLevelWidget(), |
336 NULL, | 339 NULL, |
337 gfx::Rect(point, gfx::Size()), | 340 gfx::Rect(point, gfx::Size()), |
338 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 |