Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(919)

Side by Side Diff: ash/root_window_controller.cc

Issue 2336883002: mash: Port context menu code to WmShell and WmRootWindowController. (Closed)
Patch Set: Fix error. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/root_window_controller.h ('k') | ash/shell.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/root_window_controller.h" 5 #include "ash/root_window_controller.h"
6 6
7 #include <queue> 7 #include <queue>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/aura/aura_layout_manager_adapter.h" 10 #include "ash/aura/aura_layout_manager_adapter.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 #include "base/memory/ptr_util.h" 62 #include "base/memory/ptr_util.h"
63 #include "base/time/time.h" 63 #include "base/time/time.h"
64 #include "ui/aura/client/aura_constants.h" 64 #include "ui/aura/client/aura_constants.h"
65 #include "ui/aura/client/screen_position_client.h" 65 #include "ui/aura/client/screen_position_client.h"
66 #include "ui/aura/window.h" 66 #include "ui/aura/window.h"
67 #include "ui/aura/window_delegate.h" 67 #include "ui/aura/window_delegate.h"
68 #include "ui/aura/window_event_dispatcher.h" 68 #include "ui/aura/window_event_dispatcher.h"
69 #include "ui/aura/window_observer.h" 69 #include "ui/aura/window_observer.h"
70 #include "ui/aura/window_tracker.h" 70 #include "ui/aura/window_tracker.h"
71 #include "ui/base/hit_test.h" 71 #include "ui/base/hit_test.h"
72 #include "ui/base/models/menu_model.h"
73 #include "ui/display/display.h" 72 #include "ui/display/display.h"
74 #include "ui/display/screen.h" 73 #include "ui/display/screen.h"
75 #include "ui/keyboard/keyboard_controller.h" 74 #include "ui/keyboard/keyboard_controller.h"
76 #include "ui/keyboard/keyboard_util.h" 75 #include "ui/keyboard/keyboard_util.h"
77 #include "ui/views/controls/menu/menu_model_adapter.h"
78 #include "ui/views/controls/menu/menu_runner.h"
79 #include "ui/views/view_model.h" 76 #include "ui/views/view_model.h"
80 #include "ui/views/view_model_utils.h" 77 #include "ui/views/view_model_utils.h"
81 #include "ui/wm/core/capture_controller.h" 78 #include "ui/wm/core/capture_controller.h"
82 #include "ui/wm/core/visibility_controller.h" 79 #include "ui/wm/core/visibility_controller.h"
83 #include "ui/wm/core/window_util.h" 80 #include "ui/wm/core/window_util.h"
84 #include "ui/wm/public/drag_drop_client.h" 81 #include "ui/wm/public/drag_drop_client.h"
85 #include "ui/wm/public/tooltip_client.h" 82 #include "ui/wm/public/tooltip_client.h"
86 #include "ui/wm/public/window_types.h" 83 #include "ui/wm/public/window_types.h"
87 84
88 #if defined(OS_CHROMEOS) 85 #if defined(OS_CHROMEOS)
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 return shelf_widget ? shelf_widget->status_area_widget() : nullptr; 569 return shelf_widget ? shelf_widget->status_area_widget() : nullptr;
573 } 570 }
574 571
575 SystemTray* RootWindowController::GetSystemTray() { 572 SystemTray* RootWindowController::GetSystemTray() {
576 // We assume in throughout the code that this will not return NULL. If code 573 // We assume in throughout the code that this will not return NULL. If code
577 // triggers this for valid reasons, it should test status_area_widget first. 574 // triggers this for valid reasons, it should test status_area_widget first.
578 CHECK(wm_shelf_aura_->shelf_widget()->status_area_widget()); 575 CHECK(wm_shelf_aura_->shelf_widget()->status_area_widget());
579 return wm_shelf_aura_->shelf_widget()->status_area_widget()->system_tray(); 576 return wm_shelf_aura_->shelf_widget()->status_area_widget()->system_tray();
580 } 577 }
581 578
582 void RootWindowController::ShowContextMenu(const gfx::Point& location_in_screen,
583 ui::MenuSourceType source_type) {
584 ShellDelegate* delegate = WmShell::Get()->delegate();
585 DCHECK(delegate);
586 menu_model_.reset(delegate->CreateContextMenu(wm_shelf_aura_.get(), nullptr));
587 if (!menu_model_)
588 return;
589
590 menu_model_adapter_.reset(new views::MenuModelAdapter(
591 menu_model_.get(),
592 base::Bind(&RootWindowController::OnMenuClosed, base::Unretained(this))));
593
594 // Wallpaper controller may not be set yet if user clicked on status are
595 // before initial animation completion. See crbug.com/222218
596 WallpaperWidgetController* wallpaper_widget_controller =
597 wm_root_window_controller_->wallpaper_widget_controller();
598 if (!wallpaper_widget_controller)
599 return;
600
601 menu_runner_.reset(new views::MenuRunner(
602 menu_model_adapter_->CreateMenu(),
603 views::MenuRunner::CONTEXT_MENU | views::MenuRunner::ASYNC));
604 ignore_result(
605 menu_runner_->RunMenuAt(wallpaper_widget_controller->widget(), nullptr,
606 gfx::Rect(location_in_screen, gfx::Size()),
607 views::MENU_ANCHOR_TOPLEFT, source_type));
608 }
609
610 void RootWindowController::UpdateShelfVisibility() { 579 void RootWindowController::UpdateShelfVisibility() {
611 wm_shelf_aura_->UpdateVisibilityState(); 580 wm_shelf_aura_->UpdateVisibilityState();
612 } 581 }
613 582
614 aura::Window* RootWindowController::GetWindowForFullscreenMode() { 583 aura::Window* RootWindowController::GetWindowForFullscreenMode() {
615 return WmWindowAura::GetAuraWindow( 584 return WmWindowAura::GetAuraWindow(
616 wm::GetWindowForFullscreenMode(WmWindowAura::Get(GetRootWindow()))); 585 wm::GetWindowForFullscreenMode(WmWindowAura::Get(GetRootWindow())));
617 } 586 }
618 587
619 void RootWindowController::ActivateKeyboard( 588 void RootWindowController::ActivateKeyboard(
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 return; 819 return;
851 set_touch_hud_projection(new TouchHudProjection(GetRootWindow())); 820 set_touch_hud_projection(new TouchHudProjection(GetRootWindow()));
852 } 821 }
853 822
854 void RootWindowController::DisableTouchHudProjection() { 823 void RootWindowController::DisableTouchHudProjection() {
855 if (!touch_hud_projection_) 824 if (!touch_hud_projection_)
856 return; 825 return;
857 touch_hud_projection_->Remove(); 826 touch_hud_projection_->Remove();
858 } 827 }
859 828
860 void RootWindowController::OnMenuClosed() {
861 menu_runner_.reset();
862 menu_model_adapter_.reset();
863 menu_model_.reset();
864 Shell::GetInstance()->UpdateShelfVisibility();
865 }
866
867 void RootWindowController::OnLoginStateChanged(LoginStatus status) { 829 void RootWindowController::OnLoginStateChanged(LoginStatus status) {
868 wm_shelf_aura_->UpdateVisibilityState(); 830 wm_shelf_aura_->UpdateVisibilityState();
869 } 831 }
870 832
871 void RootWindowController::OnTouchHudProjectionToggled(bool enabled) { 833 void RootWindowController::OnTouchHudProjectionToggled(bool enabled) {
872 if (enabled) 834 if (enabled)
873 EnableTouchHudProjection(); 835 EnableTouchHudProjection();
874 else 836 else
875 DisableTouchHudProjection(); 837 DisableTouchHudProjection();
876 } 838 }
(...skipping 11 matching lines...) Expand all
888 aura::Window* primary_root_window = Shell::GetInstance() 850 aura::Window* primary_root_window = Shell::GetInstance()
889 ->window_tree_host_manager() 851 ->window_tree_host_manager()
890 ->GetPrimaryRootWindow(); 852 ->GetPrimaryRootWindow();
891 return GetRootWindowSettings(primary_root_window)->controller; 853 return GetRootWindowSettings(primary_root_window)->controller;
892 } 854 }
893 855
894 return GetRootWindowSettings(root_window)->controller; 856 return GetRootWindowSettings(root_window)->controller;
895 } 857 }
896 858
897 } // namespace ash 859 } // namespace ash
OLDNEW
« no previous file with comments | « ash/root_window_controller.h ('k') | ash/shell.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698