diff options
author | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-03 08:17:06 +0000 |
---|---|---|
committer | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-03 08:17:06 +0000 |
commit | 756bda1029b3cccbdde7892c447c79bff0eadd95 (patch) | |
tree | e6eca2c2cbd42ed4e379cef138551da40fff6413 /ash | |
parent | 9c34aa24e1dd9d05b01711d746c99184c935eef8 (diff) | |
download | chromium_src-756bda1029b3cccbdde7892c447c79bff0eadd95.zip chromium_src-756bda1029b3cccbdde7892c447c79bff0eadd95.tar.gz chromium_src-756bda1029b3cccbdde7892c447c79bff0eadd95.tar.bz2 |
Simplify RootWindowController init process
Fixed the order of method body to match the order in header.
BUG=253991
Review URL: https://chromiumcodereview.appspot.com/18266004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@209915 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r-- | ash/root_window_controller.cc | 201 | ||||
-rw-r--r-- | ash/root_window_controller.h | 19 | ||||
-rw-r--r-- | ash/shell.cc | 34 | ||||
-rw-r--r-- | ash/shell.h | 6 |
4 files changed, 127 insertions, 133 deletions
diff --git a/ash/root_window_controller.cc b/ash/root_window_controller.cc index ab81dbe..ba20f58 100644 --- a/ash/root_window_controller.cc +++ b/ash/root_window_controller.cc @@ -203,6 +203,18 @@ RootWindowController* RootWindowController::ForActiveRootWindow() { return GetRootWindowController(Shell::GetActiveRootWindow()); } +void RootWindowController::EnableTouchHudProjection() { + if (touch_hud_projection_) + return; + set_touch_hud_projection(new TouchHudProjection(root_window_.get())); +} + +void RootWindowController::DisableTouchHudProjection() { + if (!touch_hud_projection_) + return; + touch_hud_projection_->Remove(); +} + void RootWindowController::SetWallpaperController( DesktopBackgroundWidgetController* controller) { wallpaper_controller_.reset(controller); @@ -267,81 +279,26 @@ aura::Window* RootWindowController::GetContainer(int container_id) { return root_window_->GetChildById(container_id); } -void RootWindowController::InitLayoutManagers() { - root_window_layout_ = - new RootWindowLayoutManager(root_window_.get()); - root_window_->SetLayoutManager(root_window_layout_); - - aura::Window* default_container = - GetContainer(kShellWindowId_DefaultContainer); - // Workspace manager has its own layout managers. - workspace_controller_.reset( - new WorkspaceController(default_container)); - - aura::Window* always_on_top_container = - GetContainer(kShellWindowId_AlwaysOnTopContainer); - always_on_top_container->SetLayoutManager( - new BaseLayoutManager( - always_on_top_container->GetRootWindow())); - always_on_top_controller_.reset(new internal::AlwaysOnTopController); - always_on_top_controller_->SetAlwaysOnTopContainer(always_on_top_container); -} - -void RootWindowController::InitForPrimaryDisplay() { - DCHECK(!shelf_.get()); - aura::Window* shelf_container = - GetContainer(internal::kShellWindowId_ShelfContainer); - // TODO(harrym): Remove when status area is view. - aura::Window* status_container = - GetContainer(internal::kShellWindowId_StatusContainer); - shelf_.reset(new ShelfWidget( - shelf_container, status_container, workspace_controller())); - - // Create Docked windows layout manager - aura::Window* docked_container = GetContainer( - internal::kShellWindowId_DockedContainer); - docked_layout_manager_ = - new internal::DockedWindowLayoutManager(docked_container); - docked_container_handler_.reset( - new ToplevelWindowEventHandler(docked_container)); - docked_container->SetLayoutManager(docked_layout_manager_); - - // Create Panel layout manager - aura::Window* panel_container = GetContainer( - internal::kShellWindowId_PanelContainer); - panel_layout_manager_ = - new internal::PanelLayoutManager(panel_container); - panel_container_handler_.reset( - new PanelWindowEventHandler(panel_container)); - panel_container->SetLayoutManager(panel_layout_manager_); +void RootWindowController::Init(bool first_run_after_boot) { + root_window_->SetCursor(ui::kCursorPointer); + CreateContainersInRootWindow(root_window_.get()); + CreateSystemBackground(first_run_after_boot); + InitLayoutManagers(); InitKeyboard(); -} + InitTouchHuds(); -void RootWindowController::CreateContainers() { - CreateContainersInRootWindow(root_window_.get()); + if (Shell::GetPrimaryRootWindowController()-> + GetSystemModalLayoutManager(NULL)->has_modal_background()) { + GetSystemModalLayoutManager(NULL)->CreateModalBackground(); + } } -void RootWindowController::CreateSystemBackground( - bool is_first_run_after_boot) { - SkColor color = SK_ColorBLACK; -#if defined(OS_CHROMEOS) - if (is_first_run_after_boot) - color = kChromeOsBootColor; -#endif - system_background_.reset( - new SystemBackgroundController(root_window_.get(), color)); - -#if defined(OS_CHROMEOS) - // Make a copy of the system's boot splash screen so we can composite it - // onscreen until the desktop background is ready. - if (is_first_run_after_boot && - (CommandLine::ForCurrentProcess()->HasSwitch( - switches::kAshCopyHostBackgroundAtBoot) || - CommandLine::ForCurrentProcess()->HasSwitch( - switches::kAshAnimateFromBootSplashScreen))) - boot_splash_screen_.reset(new BootSplashScreen(root_window_.get())); -#endif +void RootWindowController::ShowLauncher() { + if (!shelf_->launcher()) + return; + shelf_->launcher()->SetVisible(true); + shelf_->status_area_widget()->Show(); } void RootWindowController::OnLauncherCreated() { @@ -351,13 +308,6 @@ void RootWindowController::OnLauncherCreated() { docked_layout_manager_->SetLauncher(shelf_->launcher()); } -void RootWindowController::ShowLauncher() { - if (!shelf_->launcher()) - return; - shelf_->launcher()->SetVisible(true); - shelf_->status_area_widget()->Show(); -} - void RootWindowController::OnLoginStateChanged(user::LoginStatus status) { shelf_->shelf_layout_manager()->UpdateVisibilityState(); } @@ -438,18 +388,6 @@ void RootWindowController::MoveWindowsTo(aura::RootWindow* dst) { ReparentAllWindows(root_window_.get(), dst); } -void RootWindowController::EnableTouchHudProjection() { - if (touch_hud_projection_) - return; - set_touch_hud_projection(new TouchHudProjection(root_window_.get())); -} - -void RootWindowController::DisableTouchHudProjection() { - if (!touch_hud_projection_) - return; - touch_hud_projection_->Remove(); -} - ShelfLayoutManager* RootWindowController::GetShelfLayoutManager() { return shelf_->shelf_layout_manager(); } @@ -490,14 +428,6 @@ void RootWindowController::UpdateShelfVisibility() { shelf_->shelf_layout_manager()->UpdateVisibilityState(); } -void RootWindowController::InitTouchHuds() { - CommandLine* command_line = CommandLine::ForCurrentProcess(); - if (command_line->HasSwitch(switches::kAshTouchHud)) - set_touch_hud_debug(new TouchHudDebug(root_window_.get())); - if (Shell::GetInstance()->is_touch_hud_projection_enabled()) - EnableTouchHudProjection(); -} - aura::Window* RootWindowController::GetFullscreenWindow() const { aura::Window* container = workspace_controller_->GetActiveWorkspaceWindow(); for (size_t i = 0; i < container->children().size(); ++i) { @@ -531,6 +461,83 @@ void RootWindowController::InitKeyboard() { //////////////////////////////////////////////////////////////////////////////// // RootWindowController, private: +void RootWindowController::InitLayoutManagers() { + root_window_layout_ = + new RootWindowLayoutManager(root_window_.get()); + root_window_->SetLayoutManager(root_window_layout_); + + aura::Window* default_container = + GetContainer(kShellWindowId_DefaultContainer); + // Workspace manager has its own layout managers. + workspace_controller_.reset( + new WorkspaceController(default_container)); + + aura::Window* always_on_top_container = + GetContainer(kShellWindowId_AlwaysOnTopContainer); + always_on_top_container->SetLayoutManager( + new BaseLayoutManager( + always_on_top_container->GetRootWindow())); + always_on_top_controller_.reset(new internal::AlwaysOnTopController); + always_on_top_controller_->SetAlwaysOnTopContainer(always_on_top_container); + + DCHECK(!shelf_.get()); + aura::Window* shelf_container = + GetContainer(internal::kShellWindowId_ShelfContainer); + // TODO(harrym): Remove when status area is view. + aura::Window* status_container = + GetContainer(internal::kShellWindowId_StatusContainer); + shelf_.reset(new ShelfWidget( + shelf_container, status_container, workspace_controller())); + + // Create Docked windows layout manager + aura::Window* docked_container = GetContainer( + internal::kShellWindowId_DockedContainer); + docked_layout_manager_ = + new internal::DockedWindowLayoutManager(docked_container); + docked_container_handler_.reset( + new ToplevelWindowEventHandler(docked_container)); + docked_container->SetLayoutManager(docked_layout_manager_); + + // Create Panel layout manager + aura::Window* panel_container = GetContainer( + internal::kShellWindowId_PanelContainer); + panel_layout_manager_ = + new internal::PanelLayoutManager(panel_container); + panel_container_handler_.reset( + new PanelWindowEventHandler(panel_container)); + panel_container->SetLayoutManager(panel_layout_manager_); +} + +void RootWindowController::InitTouchHuds() { + CommandLine* command_line = CommandLine::ForCurrentProcess(); + if (command_line->HasSwitch(switches::kAshTouchHud)) + set_touch_hud_debug(new TouchHudDebug(root_window_.get())); + if (Shell::GetInstance()->is_touch_hud_projection_enabled()) + EnableTouchHudProjection(); +} + +void RootWindowController::CreateSystemBackground( + bool is_first_run_after_boot) { + SkColor color = SK_ColorBLACK; +#if defined(OS_CHROMEOS) + if (is_first_run_after_boot) + color = kChromeOsBootColor; +#endif + system_background_.reset( + new SystemBackgroundController(root_window_.get(), color)); + +#if defined(OS_CHROMEOS) + // Make a copy of the system's boot splash screen so we can composite it + // onscreen until the desktop background is ready. + if (is_first_run_after_boot && + (CommandLine::ForCurrentProcess()->HasSwitch( + switches::kAshCopyHostBackgroundAtBoot) || + CommandLine::ForCurrentProcess()->HasSwitch( + switches::kAshAnimateFromBootSplashScreen))) + boot_splash_screen_.reset(new BootSplashScreen(root_window_.get())); +#endif +} + void RootWindowController::CreateContainersInRootWindow( aura::RootWindow* root_window) { // These containers are just used by PowerButtonController to animate groups diff --git a/ash/root_window_controller.h b/ash/root_window_controller.h index 2895466..393dcb3 100644 --- a/ash/root_window_controller.h +++ b/ash/root_window_controller.h @@ -163,16 +163,9 @@ class ASH_EXPORT RootWindowController { aura::Window* GetContainer(int container_id); - void InitLayoutManagers(); - void CreateContainers(); - - // Initializs the RootWindowController for primary display. This - // creates - void InitForPrimaryDisplay(); - - // Initializes |system_background_| and possibly also |boot_splash_screen_|. - // |is_first_run_after_boot| determines the background's initial color. - void CreateSystemBackground(bool is_first_run_after_boot); + // Initializes the RootWindowController. |first_run_after_boot| is + // set to true only for primary root window after boot. + void Init(bool first_run_after_boot); // Show launcher view if it was created hidden (before session has started). void ShowLauncher(); @@ -222,6 +215,12 @@ class ASH_EXPORT RootWindowController { aura::Window* GetFullscreenWindow() const; private: + void InitLayoutManagers(); + + // Initializes |system_background_| and possibly also |boot_splash_screen_|. + // |is_first_run_after_boot| determines the background's initial color. + void CreateSystemBackground(bool is_first_run_after_boot); + // Creates each of the special window containers that holds windows of various // types in the shell UI. void CreateContainersInRootWindow(aura::RootWindow* root_window); diff --git a/ash/shell.cc b/ash/shell.cc index 5dec24f..1610ae3 100644 --- a/ash/shell.cc +++ b/ash/shell.cc @@ -534,12 +534,6 @@ void Shell::Init() { if (keyboard::IsKeyboardEnabled()) keyboard::InitializeKeyboard(); - internal::RootWindowController* root_window_controller = - new internal::RootWindowController(root_window); - root_window_controller->CreateContainers(); - root_window_controller->CreateSystemBackground( - delegate_->IsFirstRunAfterBoot()); - if (command_line->HasSwitch(ash::switches::kAshDisableNewLockAnimations)) lock_state_controller_.reset(new SessionStateControllerImpl); else @@ -577,8 +571,6 @@ void Shell::Init() { event_client_.reset(new internal::EventClientImpl); - InitRootWindowController(root_window_controller); - // This controller needs to be set before SetupManagedWindowMode. desktop_background_controller_.reset(new DesktopBackgroundController()); user_wallpaper_delegate_.reset(delegate_->CreateUserWallpaperDelegate()); @@ -604,8 +596,10 @@ void Shell::Init() { if (!system_tray_delegate_) system_tray_delegate_.reset(SystemTrayDelegate::CreateDummyDelegate()); - // Creates StatusAreaWidget. - root_window_controller->InitForPrimaryDisplay(); + internal::RootWindowController* root_window_controller = + new internal::RootWindowController(root_window); + InitRootWindowController(root_window_controller, + delegate_->IsFirstRunAfterBoot()); // Initialize system_tray_delegate_ after StatusAreaWidget is created. system_tray_delegate_->Initialize(); @@ -873,16 +867,13 @@ void Shell::SetTouchHudProjectionEnabled(bool enabled) { } void Shell::InitRootWindowForSecondaryDisplay(aura::RootWindow* root) { - aura::client::SetFocusClient(root, focus_client_.get()); internal::RootWindowController* controller = new internal::RootWindowController(root); - controller->CreateContainers(); // Pass false for the |is_first_run_after_boot| parameter so we'll show a // black background on this display instead of trying to mimic the boot splash // screen. - controller->CreateSystemBackground(false); - InitRootWindowController(controller); - controller->InitForPrimaryDisplay(); + InitRootWindowController(controller, false); + controller->root_window_layout()->OnWindowResized(); desktop_background_controller_->OnRootWindowAdded(root); high_contrast_controller_->OnRootWindowAdded(root); @@ -901,7 +892,9 @@ void Shell::DoInitialWorkspaceAnimation() { } void Shell::InitRootWindowController( - internal::RootWindowController* controller) { + internal::RootWindowController* controller, + bool first_run_after_boot) { + aura::RootWindow* root_window = controller->root_window(); DCHECK(activation_client_); DCHECK(visibility_controller_.get()); @@ -933,14 +926,7 @@ void Shell::InitRootWindowController( if (user_action_client_) aura::client::SetUserActionClient(root_window, user_action_client_.get()); - root_window->SetCursor(ui::kCursorPointer); - controller->InitLayoutManagers(); - controller->InitTouchHuds(); - - if (GetPrimaryRootWindowController()->GetSystemModalLayoutManager(NULL)-> - has_modal_background()) { - controller->GetSystemModalLayoutManager(NULL)->CreateModalBackground(); - } + controller->Init(first_run_after_boot); window_cycle_controller_->OnRootWindowAdded(root_window); } diff --git a/ash/shell.h b/ash/shell.h index 62ef0ff..a602cdf 100644 --- a/ash/shell.h +++ b/ash/shell.h @@ -485,8 +485,10 @@ class ASH_EXPORT Shell void Init(); // Initializes the root window and root window controller so that it - // can host browser windows. - void InitRootWindowController(internal::RootWindowController* root); + // can host browser windows. |first_run_after_boot| is true for the + // primary display only first time after boot. + void InitRootWindowController(internal::RootWindowController* root, + bool first_run_after_boot); // ash::internal::SystemModalContainerEventFilterDelegate overrides: virtual bool CanWindowReceiveEvents(aura::Window* window) OVERRIDE; |