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

Side by Side Diff: ash/shell.h

Issue 2739553005: Moves maintaining root_window_for_new_windows_ to Shell (Closed)
Patch Set: remove ash:: Created 3 years, 9 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.cc ('k') | ash/shell.cc » ('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 #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 } 35 }
36 } 36 }
37 37
38 namespace chromeos { 38 namespace chromeos {
39 class AudioA11yController; 39 class AudioA11yController;
40 } 40 }
41 41
42 namespace display { 42 namespace display {
43 class DisplayChangeObserver; 43 class DisplayChangeObserver;
44 class DisplayConfigurator; 44 class DisplayConfigurator;
(...skipping 13 matching lines...) Expand all
58 class NonClientFrameView; 58 class NonClientFrameView;
59 class Widget; 59 class Widget;
60 namespace corewm { 60 namespace corewm {
61 class TooltipController; 61 class TooltipController;
62 } 62 }
63 } 63 }
64 64
65 namespace wm { 65 namespace wm {
66 class AcceleratorFilter; 66 class AcceleratorFilter;
67 class CompoundEventFilter; 67 class CompoundEventFilter;
68 class FocusController;
68 class ShadowController; 69 class ShadowController;
69 class VisibilityController; 70 class VisibilityController;
70 class WindowModalityController; 71 class WindowModalityController;
71 } 72 }
72 73
73 namespace ash { 74 namespace ash {
74 75
75 class AcceleratorControllerDelegateAura; 76 class AcceleratorControllerDelegateAura;
76 class AppListDelegateImpl; 77 class AppListDelegateImpl;
77 class AshNativeCursorManager; 78 class AshNativeCursorManager;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 13 matching lines...) Expand all
168 int64_t display_id); 170 int64_t display_id);
169 171
170 // Returns all root window controllers. 172 // Returns all root window controllers.
171 // TODO(oshima): move this to |RootWindowController| 173 // TODO(oshima): move this to |RootWindowController|
172 static RootWindowControllerList GetAllRootWindowControllers(); 174 static RootWindowControllerList GetAllRootWindowControllers();
173 175
174 // Returns the primary root Window. The primary root Window is the one that 176 // Returns the primary root Window. The primary root Window is the one that
175 // has a launcher. 177 // has a launcher.
176 static aura::Window* GetPrimaryRootWindow(); 178 static aura::Window* GetPrimaryRootWindow();
177 179
178 // Returns a root Window when used as a target when creating a new window. 180 // Returns the root window that newly created windows should be added to.
179 // The root window of the active window is used in most cases, but can 181 // Value can be temporarily overridden using ScopedRootWindowForNewWindows.
180 // be overridden by using ScopedRootWindowForNewWindows. 182 // NOTE: this returns the root, newly created window should be added to the
181 // If you want to get the root Window of the active window, just use 183 // appropriate container in the returned window.
182 // |wm::GetActiveWindow()->GetRootWindow()|. 184 static aura::Window* GetRootWindowForNewWindows();
183 static aura::Window* GetTargetRootWindow(); 185 static WmWindow* GetWmRootWindowForNewWindows();
184
185 // Returns the id of the display::Display corresponding to the window returned
186 // by |GetTargetRootWindow()|
187 static int64_t GetTargetDisplayId();
188 186
189 // Returns all root windows. 187 // Returns all root windows.
190 static aura::Window::Windows GetAllRootWindows(); 188 static aura::Window::Windows GetAllRootWindows();
191 189
192 static aura::Window* GetContainer(aura::Window* root_window, 190 static aura::Window* GetContainer(aura::Window* root_window,
193 int container_id); 191 int container_id);
194 static const aura::Window* GetContainer(const aura::Window* root_window, 192 static const aura::Window* GetContainer(const aura::Window* root_window,
195 int container_id); 193 int container_id);
196 194
197 // TODO(sky): move this and WindowManagerClient into ShellMash that is owned 195 // TODO(sky): move this and WindowManagerClient into ShellMash that is owned
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 } 309 }
312 310
313 MagnificationController* magnification_controller() { 311 MagnificationController* magnification_controller() {
314 return magnification_controller_.get(); 312 return magnification_controller_.get();
315 } 313 }
316 314
317 AutoclickController* autoclick_controller() { 315 AutoclickController* autoclick_controller() {
318 return autoclick_controller_.get(); 316 return autoclick_controller_.get();
319 } 317 }
320 318
321 aura::client::ActivationClient* activation_client() { 319 aura::client::ActivationClient* activation_client();
322 return activation_client_;
323 }
324 320
325 // Force the shelf to query for it's current visibility state. 321 // Force the shelf to query for it's current visibility state.
326 // TODO(jamescook): Move to Shelf. 322 // TODO(jamescook): Move to Shelf.
327 void UpdateShelfVisibility(); 323 void UpdateShelfVisibility();
328 324
329 // Returns WebNotificationTray on the primary root window. 325 // Returns WebNotificationTray on the primary root window.
330 WebNotificationTray* GetWebNotificationTray(); 326 WebNotificationTray* GetWebNotificationTray();
331 327
332 // Does the primary display have status area? 328 // Does the primary display have status area?
333 bool HasPrimaryStatusArea(); 329 bool HasPrimaryStatusArea();
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 WindowPositioner* window_positioner() { return window_positioner_.get(); } 378 WindowPositioner* window_positioner() { return window_positioner_.get(); }
383 379
384 UserMetricsRecorder* metrics() { return user_metrics_recorder_.get(); } 380 UserMetricsRecorder* metrics() { return user_metrics_recorder_.get(); }
385 381
386 void SetTouchHudProjectionEnabled(bool enabled); 382 void SetTouchHudProjectionEnabled(bool enabled);
387 383
388 bool is_touch_hud_projection_enabled() const { 384 bool is_touch_hud_projection_enabled() const {
389 return is_touch_hud_projection_enabled_; 385 return is_touch_hud_projection_enabled_;
390 } 386 }
391 387
388 // NOTE: Prefer ScopedRootWindowForNewWindows when setting temporarily.
389 void set_root_window_for_new_windows(WmWindow* root) {
390 root_window_for_new_windows_ = root;
391 }
392
392 // Creates instance of FirstRunHelper. Caller is responsible for deleting 393 // Creates instance of FirstRunHelper. Caller is responsible for deleting
393 // returned object. 394 // returned object.
394 ash::FirstRunHelper* CreateFirstRunHelper(); 395 ash::FirstRunHelper* CreateFirstRunHelper();
395 396
396 void SetLargeCursorSizeInDip(int large_cursor_size_in_dip); 397 void SetLargeCursorSizeInDip(int large_cursor_size_in_dip);
397 398
398 // Toggles cursor compositing on/off. Native cursor is disabled when cursor 399 // Toggles cursor compositing on/off. Native cursor is disabled when cursor
399 // compositing is enabled, and vice versa. 400 // compositing is enabled, and vice versa.
400 void SetCursorCompositingEnabled(bool enabled); 401 void SetCursorCompositingEnabled(bool enabled);
401 402
402 StickyKeysController* sticky_keys_controller() { 403 StickyKeysController* sticky_keys_controller() {
403 return sticky_keys_controller_.get(); 404 return sticky_keys_controller_.get();
404 } 405 }
405 406
406 ScreenPinningController* screen_pinning_controller() { 407 ScreenPinningController* screen_pinning_controller() {
407 return screen_pinning_controller_.get(); 408 return screen_pinning_controller_.get();
408 } 409 }
409 410
410 GPUSupport* gpu_support() { return gpu_support_.get(); } 411 GPUSupport* gpu_support() { return gpu_support_.get(); }
411 412
412 private: 413 private:
413 FRIEND_TEST_ALL_PREFIXES(ExtendedDesktopTest, TestCursor); 414 FRIEND_TEST_ALL_PREFIXES(ExtendedDesktopTest, TestCursor);
414 FRIEND_TEST_ALL_PREFIXES(WindowManagerTest, MouseEventCursors); 415 FRIEND_TEST_ALL_PREFIXES(WindowManagerTest, MouseEventCursors);
415 FRIEND_TEST_ALL_PREFIXES(WindowManagerTest, TransformActivate); 416 FRIEND_TEST_ALL_PREFIXES(WindowManagerTest, TransformActivate);
416 friend class RootWindowController; 417 friend class RootWindowController;
418 friend class ScopedRootWindowForNewWindows;
419 friend class SmsObserverTest;
417 friend class test::ShellTestApi; 420 friend class test::ShellTestApi;
418 friend class shell::WindowWatcher; 421 friend class shell::WindowWatcher;
419 friend class SmsObserverTest;
420 422
421 explicit Shell(std::unique_ptr<WmShell> wm_shell); 423 explicit Shell(std::unique_ptr<WmShell> wm_shell);
422 ~Shell() override; 424 ~Shell() override;
423 425
424 void Init(const ShellInitParams& init_params); 426 void Init(const ShellInitParams& init_params);
425 427
426 // Initializes virtual keyboard controller. 428 // Initializes virtual keyboard controller.
427 void InitKeyboard(); 429 void InitKeyboard();
428 430
429 // Initializes the root window so that it can host browser windows. 431 // Initializes the root window so that it can host browser windows.
430 void InitRootWindow(aura::Window* root_window); 432 void InitRootWindow(aura::Window* root_window);
431 433
432 // Destroys all child windows including widgets across all roots. 434 // Destroys all child windows including widgets across all roots.
433 void CloseAllRootWindowChildWindows(); 435 void CloseAllRootWindowChildWindows();
434 436
435 // SystemModalContainerEventFilterDelegate: 437 // SystemModalContainerEventFilterDelegate:
436 bool CanWindowReceiveEvents(aura::Window* window) override; 438 bool CanWindowReceiveEvents(aura::Window* window) override;
437 439
438 // Overridden from ui::EventTarget: 440 // Overridden from ui::EventTarget:
439 bool CanAcceptEvent(const ui::Event& event) override; 441 bool CanAcceptEvent(const ui::Event& event) override;
440 EventTarget* GetParentTarget() override; 442 EventTarget* GetParentTarget() override;
441 std::unique_ptr<ui::EventTargetIterator> GetChildIterator() const override; 443 std::unique_ptr<ui::EventTargetIterator> GetChildIterator() const override;
442 ui::EventTargeter* GetEventTargeter() override; 444 ui::EventTargeter* GetEventTargeter() override;
443 445
446 // aura::client::ActivationChangeObserver:
447 void OnWindowActivated(ActivationReason reason,
448 aura::Window* gained_active,
449 aura::Window* lost_active) override;
450
444 static Shell* instance_; 451 static Shell* instance_;
445 452
446 // Only valid in mash, for classic ash this is null. 453 // Only valid in mash, for classic ash this is null.
447 static aura::WindowTreeClient* window_tree_client_; 454 static aura::WindowTreeClient* window_tree_client_;
448 static aura::WindowManagerClient* window_manager_client_; 455 static aura::WindowManagerClient* window_manager_client_;
449 456
450 // If set before the Shell is initialized, the mouse cursor will be hidden 457 // If set before the Shell is initialized, the mouse cursor will be hidden
451 // when the screen is initially created. 458 // when the screen is initially created.
452 static bool initially_hide_cursor_; 459 static bool initially_hide_cursor_;
453 460
(...skipping 18 matching lines...) Expand all
472 std::unique_ptr<views::corewm::TooltipController> tooltip_controller_; 479 std::unique_ptr<views::corewm::TooltipController> tooltip_controller_;
473 LinkHandlerModelFactory* link_handler_model_factory_; 480 LinkHandlerModelFactory* link_handler_model_factory_;
474 std::unique_ptr<PowerButtonController> power_button_controller_; 481 std::unique_ptr<PowerButtonController> power_button_controller_;
475 std::unique_ptr<LockStateController> lock_state_controller_; 482 std::unique_ptr<LockStateController> lock_state_controller_;
476 std::unique_ptr<ui::UserActivityDetector> user_activity_detector_; 483 std::unique_ptr<ui::UserActivityDetector> user_activity_detector_;
477 std::unique_ptr<VideoDetector> video_detector_; 484 std::unique_ptr<VideoDetector> video_detector_;
478 std::unique_ptr<WindowTreeHostManager> window_tree_host_manager_; 485 std::unique_ptr<WindowTreeHostManager> window_tree_host_manager_;
479 std::unique_ptr<HighContrastController> high_contrast_controller_; 486 std::unique_ptr<HighContrastController> high_contrast_controller_;
480 std::unique_ptr<MagnificationController> magnification_controller_; 487 std::unique_ptr<MagnificationController> magnification_controller_;
481 std::unique_ptr<AutoclickController> autoclick_controller_; 488 std::unique_ptr<AutoclickController> autoclick_controller_;
482 std::unique_ptr<aura::client::FocusClient> focus_client_; 489 std::unique_ptr<::wm::FocusController> focus_controller_;
483
484 aura::client::ActivationClient* activation_client_;
485 490
486 std::unique_ptr<ScreenshotController> screenshot_controller_; 491 std::unique_ptr<ScreenshotController> screenshot_controller_;
487 492
488 std::unique_ptr<MouseCursorEventFilter> mouse_cursor_filter_; 493 std::unique_ptr<MouseCursorEventFilter> mouse_cursor_filter_;
489 std::unique_ptr<ScreenPositionController> screen_position_controller_; 494 std::unique_ptr<ScreenPositionController> screen_position_controller_;
490 std::unique_ptr<SystemModalContainerEventFilter> modality_filter_; 495 std::unique_ptr<SystemModalContainerEventFilter> modality_filter_;
491 std::unique_ptr<EventClientImpl> event_client_; 496 std::unique_ptr<EventClientImpl> event_client_;
492 std::unique_ptr<EventTransformationHandler> event_transformation_handler_; 497 std::unique_ptr<EventTransformationHandler> event_transformation_handler_;
493 498
494 // An event filter that pre-handles key events while the partial 499 // An event filter that pre-handles key events while the partial
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 562
558 // Cursor may be hidden on certain key events in Chrome OS, whereas we never 563 // Cursor may be hidden on certain key events in Chrome OS, whereas we never
559 // hide the cursor on Windows. 564 // hide the cursor on Windows.
560 std::unique_ptr<::wm::CursorManager> cursor_manager_; 565 std::unique_ptr<::wm::CursorManager> cursor_manager_;
561 566
562 // For testing only: simulate that a modal window is open 567 // For testing only: simulate that a modal window is open
563 bool simulate_modal_window_open_for_testing_; 568 bool simulate_modal_window_open_for_testing_;
564 569
565 bool is_touch_hud_projection_enabled_; 570 bool is_touch_hud_projection_enabled_;
566 571
572 // See comment for GetWmRootWindowForNewWindows().
573 WmWindow* root_window_for_new_windows_ = nullptr;
574 WmWindow* scoped_root_window_for_new_windows_ = nullptr;
575
567 // Injected content::GPUDataManager support. 576 // Injected content::GPUDataManager support.
568 std::unique_ptr<GPUSupport> gpu_support_; 577 std::unique_ptr<GPUSupport> gpu_support_;
569 578
570 std::unique_ptr<ImmersiveHandlerFactoryAsh> immersive_handler_factory_; 579 std::unique_ptr<ImmersiveHandlerFactoryAsh> immersive_handler_factory_;
571 580
572 std::unique_ptr<AppListDelegateImpl> app_list_delegate_impl_; 581 std::unique_ptr<AppListDelegateImpl> app_list_delegate_impl_;
573 582
574 DISALLOW_COPY_AND_ASSIGN(Shell); 583 DISALLOW_COPY_AND_ASSIGN(Shell);
575 }; 584 };
576 585
577 } // namespace ash 586 } // namespace ash
578 587
579 #endif // ASH_SHELL_H_ 588 #endif // ASH_SHELL_H_
OLDNEW
« no previous file with comments | « ash/root_window_controller.cc ('k') | ash/shell.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698