Chromium Code Reviews| 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 #ifndef ASH_SHELL_H_ | 5 #ifndef ASH_SHELL_H_ |
| 6 #define ASH_SHELL_H_ | 6 #define ASH_SHELL_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "ash/ash_export.h" | 12 #include "ash/ash_export.h" |
| 13 #include "ash/metrics/user_metrics_recorder.h" | 13 #include "ash/metrics/user_metrics_recorder.h" |
| 14 #include "ash/public/cpp/shelf_types.h" | 14 #include "ash/public/cpp/shelf_types.h" |
| 15 #include "ash/wm/cursor_manager_chromeos.h" | 15 #include "ash/wm/cursor_manager_chromeos.h" |
| 16 #include "ash/wm/system_modal_container_event_filter_delegate.h" | 16 #include "ash/wm/system_modal_container_event_filter_delegate.h" |
| 17 #include "base/gtest_prod_util.h" | 17 #include "base/gtest_prod_util.h" |
| 18 #include "base/macros.h" | 18 #include "base/macros.h" |
| 19 #include "base/memory/weak_ptr.h" | 19 #include "base/memory/weak_ptr.h" |
| 20 #include "base/observer_list.h" | 20 #include "base/observer_list.h" |
| 21 #include "ui/aura/window.h" | 21 #include "ui/aura/window.h" |
| 22 #include "ui/display/screen.h" | 22 #include "ui/display/screen.h" |
| 23 #include "ui/events/event_target.h" | 23 #include "ui/events/event_target.h" |
| 24 #include "ui/wm/core/cursor_manager.h" | 24 #include "ui/wm/core/cursor_manager.h" |
| 25 #include "ui/wm/public/activation_change_observer.h" | |
| 25 | 26 |
| 26 namespace aura { | 27 namespace aura { |
| 27 class RootWindow; | 28 class RootWindow; |
| 28 class UserActivityForwarder; | 29 class UserActivityForwarder; |
| 29 class Window; | 30 class Window; |
| 30 class WindowManagerClient; | 31 class WindowManagerClient; |
| 31 class WindowTreeClient; | 32 class WindowTreeClient; |
| 32 namespace client { | 33 namespace client { |
| 33 class ActivationClient; | 34 class ActivationClient; |
| 34 class FocusClient; | 35 class FocusClient; |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 134 class ShellTestApi; | 135 class ShellTestApi; |
| 135 class SmsObserverTest; | 136 class SmsObserverTest; |
| 136 } | 137 } |
| 137 | 138 |
| 138 // Shell is a singleton object that presents the Shell API and implements the | 139 // Shell is a singleton object that presents the Shell API and implements the |
| 139 // RootWindow's delegate interface. | 140 // RootWindow's delegate interface. |
| 140 // | 141 // |
| 141 // Upon creation, the Shell sets itself as the RootWindow's delegate, which | 142 // Upon creation, the Shell sets itself as the RootWindow's delegate, which |
| 142 // takes ownership of the Shell. | 143 // takes ownership of the Shell. |
| 143 class ASH_EXPORT Shell : public SystemModalContainerEventFilterDelegate, | 144 class ASH_EXPORT Shell : public SystemModalContainerEventFilterDelegate, |
| 144 public ui::EventTarget { | 145 public ui::EventTarget, |
| 146 public aura::client::ActivationChangeObserver { | |
| 145 public: | 147 public: |
| 146 typedef std::vector<RootWindowController*> RootWindowControllerList; | 148 typedef std::vector<RootWindowController*> RootWindowControllerList; |
| 147 | 149 |
| 148 // A shell must be explicitly created so that it can call |Init()| with the | 150 // A shell must be explicitly created so that it can call |Init()| with the |
| 149 // delegate set. |delegate| can be NULL (if not required for initialization). | 151 // delegate set. |delegate| can be NULL (if not required for initialization). |
| 150 // Takes ownership of |delegate|. | 152 // Takes ownership of |delegate|. |
| 151 static Shell* CreateInstance(const ShellInitParams& init_params); | 153 static Shell* CreateInstance(const ShellInitParams& init_params); |
| 152 | 154 |
| 153 // Should never be called before |CreateInstance()|. | 155 // Should never be called before |CreateInstance()|. |
| 154 static Shell* GetInstance(); | 156 static Shell* GetInstance(); |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 382 WindowPositioner* window_positioner() { return window_positioner_.get(); } | 384 WindowPositioner* window_positioner() { return window_positioner_.get(); } |
| 383 | 385 |
| 384 UserMetricsRecorder* metrics() { return user_metrics_recorder_.get(); } | 386 UserMetricsRecorder* metrics() { return user_metrics_recorder_.get(); } |
| 385 | 387 |
| 386 void SetTouchHudProjectionEnabled(bool enabled); | 388 void SetTouchHudProjectionEnabled(bool enabled); |
| 387 | 389 |
| 388 bool is_touch_hud_projection_enabled() const { | 390 bool is_touch_hud_projection_enabled() const { |
| 389 return is_touch_hud_projection_enabled_; | 391 return is_touch_hud_projection_enabled_; |
| 390 } | 392 } |
| 391 | 393 |
| 394 // NOTE: Prefer ScopedRootWindowForNewWindows when setting temporarily. | |
| 395 void set_root_window_for_new_windows(WmWindow* root) { | |
| 396 root_window_for_new_windows_ = root; | |
| 397 } | |
| 398 | |
| 399 // Returns the root window that newly created windows should be added to. | |
| 400 // Value can be temporarily overridden using ScopedRootWindowForNewWindows. | |
| 401 // NOTE: this returns the root, newly created window should be added to the | |
| 402 // appropriate container in the returned window. | |
| 403 WmWindow* GetRootWindowForNewWindows(); | |
|
James Cook
2017/03/08 03:04:16
Aside: I'm glad you choose this name for the WmWin
| |
| 404 | |
| 392 // Creates instance of FirstRunHelper. Caller is responsible for deleting | 405 // Creates instance of FirstRunHelper. Caller is responsible for deleting |
| 393 // returned object. | 406 // returned object. |
| 394 ash::FirstRunHelper* CreateFirstRunHelper(); | 407 ash::FirstRunHelper* CreateFirstRunHelper(); |
| 395 | 408 |
| 396 void SetLargeCursorSizeInDip(int large_cursor_size_in_dip); | 409 void SetLargeCursorSizeInDip(int large_cursor_size_in_dip); |
| 397 | 410 |
| 398 // Toggles cursor compositing on/off. Native cursor is disabled when cursor | 411 // Toggles cursor compositing on/off. Native cursor is disabled when cursor |
| 399 // compositing is enabled, and vice versa. | 412 // compositing is enabled, and vice versa. |
| 400 void SetCursorCompositingEnabled(bool enabled); | 413 void SetCursorCompositingEnabled(bool enabled); |
| 401 | 414 |
| 402 StickyKeysController* sticky_keys_controller() { | 415 StickyKeysController* sticky_keys_controller() { |
| 403 return sticky_keys_controller_.get(); | 416 return sticky_keys_controller_.get(); |
| 404 } | 417 } |
| 405 | 418 |
| 406 ScreenPinningController* screen_pinning_controller() { | 419 ScreenPinningController* screen_pinning_controller() { |
| 407 return screen_pinning_controller_.get(); | 420 return screen_pinning_controller_.get(); |
| 408 } | 421 } |
| 409 | 422 |
| 410 GPUSupport* gpu_support() { return gpu_support_.get(); } | 423 GPUSupport* gpu_support() { return gpu_support_.get(); } |
| 411 | 424 |
| 412 private: | 425 private: |
| 413 FRIEND_TEST_ALL_PREFIXES(ExtendedDesktopTest, TestCursor); | 426 FRIEND_TEST_ALL_PREFIXES(ExtendedDesktopTest, TestCursor); |
| 414 FRIEND_TEST_ALL_PREFIXES(WindowManagerTest, MouseEventCursors); | 427 FRIEND_TEST_ALL_PREFIXES(WindowManagerTest, MouseEventCursors); |
| 415 FRIEND_TEST_ALL_PREFIXES(WindowManagerTest, TransformActivate); | 428 FRIEND_TEST_ALL_PREFIXES(WindowManagerTest, TransformActivate); |
| 416 friend class RootWindowController; | 429 friend class RootWindowController; |
| 430 friend class ScopedRootWindowForNewWindows; | |
| 431 friend class SmsObserverTest; | |
| 417 friend class test::ShellTestApi; | 432 friend class test::ShellTestApi; |
| 418 friend class shell::WindowWatcher; | 433 friend class shell::WindowWatcher; |
| 419 friend class SmsObserverTest; | |
| 420 | 434 |
| 421 explicit Shell(std::unique_ptr<WmShell> wm_shell); | 435 explicit Shell(std::unique_ptr<WmShell> wm_shell); |
| 422 ~Shell() override; | 436 ~Shell() override; |
| 423 | 437 |
| 424 void Init(const ShellInitParams& init_params); | 438 void Init(const ShellInitParams& init_params); |
| 425 | 439 |
| 426 // Initializes virtual keyboard controller. | 440 // Initializes virtual keyboard controller. |
| 427 void InitKeyboard(); | 441 void InitKeyboard(); |
| 428 | 442 |
| 429 // Initializes the root window so that it can host browser windows. | 443 // Initializes the root window so that it can host browser windows. |
| 430 void InitRootWindow(aura::Window* root_window); | 444 void InitRootWindow(aura::Window* root_window); |
| 431 | 445 |
| 432 // Destroys all child windows including widgets across all roots. | 446 // Destroys all child windows including widgets across all roots. |
| 433 void CloseAllRootWindowChildWindows(); | 447 void CloseAllRootWindowChildWindows(); |
| 434 | 448 |
| 435 // SystemModalContainerEventFilterDelegate: | 449 // SystemModalContainerEventFilterDelegate: |
| 436 bool CanWindowReceiveEvents(aura::Window* window) override; | 450 bool CanWindowReceiveEvents(aura::Window* window) override; |
| 437 | 451 |
| 438 // Overridden from ui::EventTarget: | 452 // Overridden from ui::EventTarget: |
| 439 bool CanAcceptEvent(const ui::Event& event) override; | 453 bool CanAcceptEvent(const ui::Event& event) override; |
| 440 EventTarget* GetParentTarget() override; | 454 EventTarget* GetParentTarget() override; |
| 441 std::unique_ptr<ui::EventTargetIterator> GetChildIterator() const override; | 455 std::unique_ptr<ui::EventTargetIterator> GetChildIterator() const override; |
| 442 ui::EventTargeter* GetEventTargeter() override; | 456 ui::EventTargeter* GetEventTargeter() override; |
| 443 | 457 |
| 458 // aura::client::ActivationChangeObserver: | |
| 459 void OnWindowActivated(ActivationReason reason, | |
| 460 aura::Window* gained_active, | |
| 461 aura::Window* lost_active) override; | |
| 462 | |
| 444 static Shell* instance_; | 463 static Shell* instance_; |
| 445 | 464 |
| 446 // Only valid in mash, for classic ash this is null. | 465 // Only valid in mash, for classic ash this is null. |
| 447 static aura::WindowTreeClient* window_tree_client_; | 466 static aura::WindowTreeClient* window_tree_client_; |
| 448 static aura::WindowManagerClient* window_manager_client_; | 467 static aura::WindowManagerClient* window_manager_client_; |
| 449 | 468 |
| 450 // If set before the Shell is initialized, the mouse cursor will be hidden | 469 // If set before the Shell is initialized, the mouse cursor will be hidden |
| 451 // when the screen is initially created. | 470 // when the screen is initially created. |
| 452 static bool initially_hide_cursor_; | 471 static bool initially_hide_cursor_; |
| 453 | 472 |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 557 | 576 |
| 558 // Cursor may be hidden on certain key events in Chrome OS, whereas we never | 577 // Cursor may be hidden on certain key events in Chrome OS, whereas we never |
| 559 // hide the cursor on Windows. | 578 // hide the cursor on Windows. |
| 560 std::unique_ptr<::wm::CursorManager> cursor_manager_; | 579 std::unique_ptr<::wm::CursorManager> cursor_manager_; |
| 561 | 580 |
| 562 // For testing only: simulate that a modal window is open | 581 // For testing only: simulate that a modal window is open |
| 563 bool simulate_modal_window_open_for_testing_; | 582 bool simulate_modal_window_open_for_testing_; |
| 564 | 583 |
| 565 bool is_touch_hud_projection_enabled_; | 584 bool is_touch_hud_projection_enabled_; |
| 566 | 585 |
| 586 // See comment for GetRootWindowForNewWindows(). | |
| 587 WmWindow* root_window_for_new_windows_ = nullptr; | |
| 588 WmWindow* scoped_root_window_for_new_windows_ = nullptr; | |
| 589 | |
| 567 // Injected content::GPUDataManager support. | 590 // Injected content::GPUDataManager support. |
| 568 std::unique_ptr<GPUSupport> gpu_support_; | 591 std::unique_ptr<GPUSupport> gpu_support_; |
| 569 | 592 |
| 570 std::unique_ptr<ImmersiveHandlerFactoryAsh> immersive_handler_factory_; | 593 std::unique_ptr<ImmersiveHandlerFactoryAsh> immersive_handler_factory_; |
| 571 | 594 |
| 572 std::unique_ptr<AppListDelegateImpl> app_list_delegate_impl_; | 595 std::unique_ptr<AppListDelegateImpl> app_list_delegate_impl_; |
| 573 | 596 |
| 574 DISALLOW_COPY_AND_ASSIGN(Shell); | 597 DISALLOW_COPY_AND_ASSIGN(Shell); |
| 575 }; | 598 }; |
| 576 | 599 |
| 577 } // namespace ash | 600 } // namespace ash |
| 578 | 601 |
| 579 #endif // ASH_SHELL_H_ | 602 #endif // ASH_SHELL_H_ |
| OLD | NEW |