| 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/views/controls/menu/menu_controller.h" | 5 #include "ui/views/controls/menu/menu_controller.h" |
| 6 | 6 |
| 7 #include "base/i18n/case_conversion.h" | 7 #include "base/i18n/case_conversion.h" |
| 8 #include "base/i18n/rtl.h" | 8 #include "base/i18n/rtl.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 // MenuController ------------------------------------------------------------ | 400 // MenuController ------------------------------------------------------------ |
| 401 | 401 |
| 402 // static | 402 // static |
| 403 MenuController* MenuController::active_instance_ = NULL; | 403 MenuController* MenuController::active_instance_ = NULL; |
| 404 | 404 |
| 405 // static | 405 // static |
| 406 MenuController* MenuController::GetActiveInstance() { | 406 MenuController* MenuController::GetActiveInstance() { |
| 407 return active_instance_; | 407 return active_instance_; |
| 408 } | 408 } |
| 409 | 409 |
| 410 MenuItemView* MenuController::Run(Widget* parent, | 410 void MenuController::Run(Widget* parent, |
| 411 MenuButton* button, | 411 MenuButton* button, |
| 412 MenuItemView* root, | 412 MenuItemView* root, |
| 413 const gfx::Rect& bounds, | 413 const gfx::Rect& bounds, |
| 414 MenuAnchorPosition position, | 414 MenuAnchorPosition position, |
| 415 bool context_menu, | 415 bool context_menu, |
| 416 bool is_nested_drag, | 416 bool is_nested_drag) { |
| 417 int* result_event_flags) { | |
| 418 exit_type_ = EXIT_NONE; | 417 exit_type_ = EXIT_NONE; |
| 419 possible_drag_ = false; | 418 possible_drag_ = false; |
| 420 drag_in_progress_ = false; | 419 drag_in_progress_ = false; |
| 421 did_initiate_drag_ = false; | 420 did_initiate_drag_ = false; |
| 422 closing_event_time_ = base::TimeTicks(); | 421 closing_event_time_ = base::TimeTicks(); |
| 423 menu_start_time_ = base::TimeTicks::Now(); | 422 menu_start_time_ = base::TimeTicks::Now(); |
| 424 menu_start_mouse_press_loc_ = gfx::Point(); | 423 menu_start_mouse_press_loc_ = gfx::Point(); |
| 425 | 424 |
| 426 if (parent) { | 425 if (parent) { |
| 427 View* root_view = parent->GetRootView(); | 426 View* root_view = parent->GetRootView(); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 | 474 |
| 476 // Set the selection, which opens the initial menu. | 475 // Set the selection, which opens the initial menu. |
| 477 SetSelection(root, SELECTION_OPEN_SUBMENU | SELECTION_UPDATE_IMMEDIATELY); | 476 SetSelection(root, SELECTION_OPEN_SUBMENU | SELECTION_UPDATE_IMMEDIATELY); |
| 478 | 477 |
| 479 if (!blocking_run_) { | 478 if (!blocking_run_) { |
| 480 if (!is_nested_drag) { | 479 if (!is_nested_drag) { |
| 481 // Start the timer to hide the menu. This is needed as we get no | 480 // Start the timer to hide the menu. This is needed as we get no |
| 482 // notification when the drag has finished. | 481 // notification when the drag has finished. |
| 483 StartCancelAllTimer(); | 482 StartCancelAllTimer(); |
| 484 } | 483 } |
| 485 return NULL; | 484 return; |
| 486 } | 485 } |
| 487 | 486 |
| 488 if (button) | 487 if (button) |
| 489 pressed_lock_.reset(new MenuButton::PressedLock(button)); | 488 pressed_lock_.reset(new MenuButton::PressedLock(button)); |
| 490 | 489 |
| 491 // Make sure Chrome doesn't attempt to shut down while the menu is showing. | 490 // Make sure Chrome doesn't attempt to shut down while the menu is showing. |
| 492 if (ViewsDelegate::GetInstance()) | 491 if (ViewsDelegate::GetInstance()) |
| 493 ViewsDelegate::GetInstance()->AddRef(); | 492 ViewsDelegate::GetInstance()->AddRef(); |
| 494 | |
| 495 return nullptr; | |
| 496 } | 493 } |
| 497 | 494 |
| 498 void MenuController::Cancel(ExitType type) { | 495 void MenuController::Cancel(ExitType type) { |
| 499 // If the menu has already been destroyed, no further cancellation is | 496 // If the menu has already been destroyed, no further cancellation is |
| 500 // needed. We especially don't want to set the |exit_type_| to a lesser | 497 // needed. We especially don't want to set the |exit_type_| to a lesser |
| 501 // value. | 498 // value. |
| 502 if (exit_type_ == EXIT_DESTROYED || exit_type_ == type) | 499 if (exit_type_ == EXIT_DESTROYED || exit_type_ == type) |
| 503 return; | 500 return; |
| 504 | 501 |
| 505 if (!showing_) { | 502 if (!showing_) { |
| (...skipping 2208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2714 if (hot_button_) | 2711 if (hot_button_) |
| 2715 hot_button_->SetHotTracked(false); | 2712 hot_button_->SetHotTracked(false); |
| 2716 hot_button_ = hot_button; | 2713 hot_button_ = hot_button; |
| 2717 if (hot_button) { | 2714 if (hot_button) { |
| 2718 hot_button->SetHotTracked(true); | 2715 hot_button->SetHotTracked(true); |
| 2719 hot_button->NotifyAccessibilityEvent(ui::AX_EVENT_SELECTION, true); | 2716 hot_button->NotifyAccessibilityEvent(ui::AX_EVENT_SELECTION, true); |
| 2720 } | 2717 } |
| 2721 } | 2718 } |
| 2722 | 2719 |
| 2723 } // namespace views | 2720 } // namespace views |
| OLD | NEW |