Skip to content

Commit

Permalink
Remove Shell::shelf|status_area_widget|launcher and
Browse files Browse the repository at this point in the history
updated all clients to use one on RootWindowController and/or
Launcher::ForPrimaryDisplay/ForWindow.

BUG=145978

Review URL: https://chromiumcodereview.appspot.com/11017079

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@162664 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
oshima@chromium.org committed Oct 18, 2012
1 parent fe21794 commit 88d7112
Show file tree
Hide file tree
Showing 44 changed files with 318 additions and 233 deletions.
15 changes: 7 additions & 8 deletions ash/accelerators/accelerator_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ bool HandleCycleWindowMRU(WindowCycleController::Direction direction,
}

void HandleCycleWindowLinear(CycleDirection direction) {
Shell::GetInstance()->launcher()->CycleWindowLinear(direction);
Launcher::ForPrimaryDisplay()->CycleWindowLinear(direction);
}

#if defined(OS_CHROMEOS)
Expand Down Expand Up @@ -602,8 +602,8 @@ bool AcceleratorController::PerformAction(int action,
HandleVolumeUp(accelerator);
break;
case FOCUS_LAUNCHER:
if (shell->launcher())
return shell->focus_cycler()->FocusWidget(shell->launcher()->widget());
return shell->focus_cycler()->FocusWidget(
Launcher::ForPrimaryDisplay()->widget());
break;
case FOCUS_NEXT_PANE:
return HandleRotatePaneFocus(Shell::FORWARD);
Expand Down Expand Up @@ -851,10 +851,9 @@ bool AcceleratorController::AcceleratorPressed(
}

void AcceleratorController::SwitchToWindow(int window) {
const LauncherItems& items =
Shell::GetInstance()->launcher()->model()->items();
int item_count =
Shell::GetInstance()->launcher()->model()->item_count();
Launcher* launcher = Launcher::ForPrimaryDisplay();
const LauncherItems& items = launcher->model()->items();
int item_count = launcher->model()->item_count();
int indexes_left = window >= 0 ? window : item_count;
int found_index = -1;

Expand All @@ -875,7 +874,7 @@ void AcceleratorController::SwitchToWindow(int window) {
(items[found_index].status == ash::STATUS_RUNNING ||
items[found_index].status == ash::STATUS_CLOSED)) {
// Then set this one as active.
Shell::GetInstance()->launcher()->ActivateLauncherItem(found_index);
launcher->ActivateLauncherItem(found_index);
}
}

Expand Down
2 changes: 1 addition & 1 deletion ash/dip_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ TEST_F(DIPTest, MAYBE_WorkArea) {

// Sanity check if the workarea's inset hight is same as
// the launcher's height.
Launcher* launcher = Shell::GetInstance()->launcher();
Launcher* launcher = Launcher::ForPrimaryDisplay();
EXPECT_EQ(
display_2x.bounds().InsetsFrom(work_area).height(),
launcher->widget()->GetNativeView()->layer()->bounds().height());
Expand Down
4 changes: 2 additions & 2 deletions ash/display/display_controller_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ TEST_F(DisplayControllerTest, SwapPrimary) {
display_controller->GetRootWindowForDisplayId(secondary_display.id());
EXPECT_NE(primary_root, secondary_root);
aura::Window* launcher_window =
Shell::GetInstance()->launcher()->widget()->GetNativeView();
Launcher::ForPrimaryDisplay()->widget()->GetNativeView();
EXPECT_TRUE(primary_root->Contains(launcher_window));
EXPECT_FALSE(secondary_root->Contains(launcher_window));
EXPECT_EQ(primary_display.id(),
Expand Down Expand Up @@ -277,7 +277,7 @@ TEST_F(DisplayControllerTest, SwapPrimaryById) {
aura::RootWindow* secondary_root =
display_controller->GetRootWindowForDisplayId(secondary_display.id());
aura::Window* launcher_window =
Shell::GetInstance()->launcher()->widget()->GetNativeView();
Launcher::ForPrimaryDisplay()->widget()->GetNativeView();
EXPECT_TRUE(primary_root->Contains(launcher_window));
EXPECT_FALSE(secondary_root->Contains(launcher_window));
EXPECT_NE(primary_root, secondary_root);
Expand Down
16 changes: 8 additions & 8 deletions ash/focus_cycler_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ TEST_F(FocusCyclerTest, CycleFocusForward) {
focus_cycler.get());

// Add the launcher
Launcher* launcher = Shell::GetInstance()->launcher();
Launcher* launcher = Launcher::ForPrimaryDisplay();
ASSERT_TRUE(launcher);
views::Widget* launcher_widget = launcher->widget();
ASSERT_TRUE(launcher_widget);
Expand Down Expand Up @@ -103,7 +103,7 @@ TEST_F(FocusCyclerTest, CycleFocusBackward) {
focus_cycler.get());

// Add the launcher
Launcher* launcher = Shell::GetInstance()->launcher();
Launcher* launcher = Launcher::ForPrimaryDisplay();
ASSERT_TRUE(launcher);
views::Widget* launcher_widget = launcher->widget();
ASSERT_TRUE(launcher_widget);
Expand Down Expand Up @@ -138,7 +138,7 @@ TEST_F(FocusCyclerTest, CycleFocusForwardBackward) {
focus_cycler.get());

// Add the launcher
Launcher* launcher = Shell::GetInstance()->launcher();
Launcher* launcher = Launcher::ForPrimaryDisplay();
ASSERT_TRUE(launcher);
views::Widget* launcher_widget = launcher->widget();
ASSERT_TRUE(launcher_widget);
Expand Down Expand Up @@ -185,7 +185,7 @@ TEST_F(FocusCyclerTest, CycleFocusNoBrowser) {
focus_cycler.get());

// Add the launcher and focus it
Launcher* launcher = Shell::GetInstance()->launcher();
Launcher* launcher = Launcher::ForPrimaryDisplay();
ASSERT_TRUE(launcher);
views::Widget* launcher_widget = launcher->widget();
ASSERT_TRUE(launcher_widget);
Expand Down Expand Up @@ -222,7 +222,7 @@ class FocusCyclerLauncherTest : public AshTestBase {
AshTestBase::SetUp();

// Hide the launcher
Launcher* launcher = Shell::GetInstance()->launcher();
Launcher* launcher = Launcher::ForPrimaryDisplay();
ASSERT_TRUE(launcher);
views::Widget* launcher_widget = launcher->widget();
ASSERT_TRUE(launcher_widget);
Expand All @@ -231,7 +231,7 @@ class FocusCyclerLauncherTest : public AshTestBase {

virtual void TearDown() OVERRIDE {
// Show the launcher
Launcher* launcher = Shell::GetInstance()->launcher();
Launcher* launcher = Launcher::ForPrimaryDisplay();
ASSERT_TRUE(launcher);
views::Widget* launcher_widget = launcher->widget();
ASSERT_TRUE(launcher_widget);
Expand All @@ -255,7 +255,7 @@ TEST_F(FocusCyclerLauncherTest, CycleFocusForwardInvisible) {
focus_cycler.get());

// Add the launcher
Launcher* launcher = Shell::GetInstance()->launcher();
Launcher* launcher = Launcher::ForPrimaryDisplay();
ASSERT_TRUE(launcher);
views::Widget* launcher_widget = launcher->widget();
ASSERT_TRUE(launcher_widget);
Expand Down Expand Up @@ -286,7 +286,7 @@ TEST_F(FocusCyclerLauncherTest, CycleFocusBackwardInvisible) {
focus_cycler.get());

// Add the launcher
Launcher* launcher = Shell::GetInstance()->launcher();
Launcher* launcher = Launcher::ForPrimaryDisplay();
ASSERT_TRUE(launcher);
views::Widget* launcher_widget = launcher->widget();
ASSERT_TRUE(launcher_widget);
Expand Down
13 changes: 13 additions & 0 deletions ash/launcher/launcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@
#include "ash/launcher/launcher_model.h"
#include "ash/launcher/launcher_navigator.h"
#include "ash/launcher/launcher_view.h"
#include "ash/root_window_controller.h"
#include "ash/shell.h"
#include "ash/shell_delegate.h"
#include "ash/shell_window_ids.h"
#include "ash/wm/shelf_layout_manager.h"
#include "ash/wm/window_properties.h"
#include "grit/ash_resources.h"
#include "ui/aura/root_window.h"
#include "ui/aura/window.h"
#include "ui/aura/window_observer.h"
#include "ui/base/resource/resource_bundle.h"
Expand Down Expand Up @@ -238,6 +240,17 @@ Launcher::Launcher(aura::Window* window_container,
Launcher::~Launcher() {
}

// static
Launcher* Launcher::ForPrimaryDisplay() {
return internal::RootWindowController::ForLauncher(
Shell::GetPrimaryRootWindow())->launcher();
}

// static
Launcher* Launcher::ForWindow(aura::Window* window) {
return internal::RootWindowController::ForLauncher(window)->launcher();
}

void Launcher::SetFocusCycler(internal::FocusCycler* focus_cycler) {
delegate_view_->set_focus_cycler(focus_cycler);
focus_cycler->AddWidget(widget_.get());
Expand Down
9 changes: 9 additions & 0 deletions ash/launcher/launcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ class ASH_EXPORT Launcher {
internal::ShelfLayoutManager* shelf_layout_manager);
virtual ~Launcher();

// Return the launcher for the primary display. NULL if no user is
// logged in yet.
static Launcher* ForPrimaryDisplay();

// Return the launcher for the display that |window| is currently on,
// or a launcher on primary display if the launcher per display feature
// is disabled. NULL if no user is logged in yet.
static Launcher* ForWindow(aura::Window* window);

// Sets the focus cycler. Also adds the launcher to the cycle.
void SetFocusCycler(internal::FocusCycler* focus_cycler);
internal::FocusCycler* GetFocusCycler();
Expand Down
17 changes: 11 additions & 6 deletions ash/launcher/launcher_tooltip_manager_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include "ash/launcher/launcher_tooltip_manager.h"

#include "ash/root_window_controller.h"
#include "ash/shell.h"
#include "ash/test/ash_test_base.h"
#include "ash/wm/shelf_layout_manager.h"
#include "ash/wm/window_util.h"
Expand All @@ -26,11 +28,12 @@ class LauncherTooltipManagerTest : public AshTestBase {

virtual void SetUp() OVERRIDE {
AshTestBase::SetUp();

internal::RootWindowController* controller =
Shell::GetPrimaryRootWindowController();
tooltip_manager_.reset(new internal::LauncherTooltipManager(
SHELF_ALIGNMENT_BOTTOM,
Shell::GetInstance()->shelf(),
Shell::GetInstance()->launcher()->GetLauncherViewForTest()));
controller->shelf(),
controller->launcher()->GetLauncherViewForTest()));
}

virtual void TearDown() OVERRIDE {
Expand Down Expand Up @@ -96,8 +99,9 @@ TEST_F(LauncherTooltipManagerTest, HideWhenShelfIsHidden) {
widget->Show();

// Once the shelf is hidden, the tooltip should be invisible.
ASSERT_EQ(internal::ShelfLayoutManager::HIDDEN,
Shell::GetInstance()->shelf()->visibility_state());
ASSERT_EQ(
internal::ShelfLayoutManager::HIDDEN,
Shell::GetPrimaryRootWindowController()->shelf()->visibility_state());
EXPECT_FALSE(TooltipIsVisible());

// Do not show the view if the shelf is hidden.
Expand All @@ -113,7 +117,8 @@ TEST_F(LauncherTooltipManagerTest, HideWhenShelfIsAutoHide) {
ShowImmediately();
ASSERT_TRUE(TooltipIsVisible());

internal::ShelfLayoutManager* shelf = Shell::GetInstance()->shelf();
internal::ShelfLayoutManager* shelf =
Shell::GetPrimaryRootWindowController()->shelf();
shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
shelf->UpdateAutoHideState();
ASSERT_EQ(internal::ShelfLayoutManager::AUTO_HIDE_HIDDEN,
Expand Down
6 changes: 3 additions & 3 deletions ash/launcher/launcher_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace ash {
// Makes sure invoking SetStatusSize on the launcher changes the size of the
// LauncherView.
TEST_F(LauncherTest, SetStatusSize) {
Launcher* launcher = Shell::GetInstance()->launcher();
Launcher* launcher = Launcher::ForPrimaryDisplay();
LauncherView* launcher_view = launcher->GetLauncherViewForTest();

gfx::Size launcher_size =
Expand All @@ -35,7 +35,7 @@ TEST_F(LauncherTest, SetStatusSize) {

// Tests that the dimmer widget resizes itself as appropriate.
TEST_F(LauncherTest, DimmerSize) {
Launcher* launcher = Shell::GetInstance()->launcher();
Launcher* launcher = Launcher::ForPrimaryDisplay();
launcher->SetDimsShelf(true);

gfx::Size launcher_size =
Expand All @@ -54,7 +54,7 @@ TEST_F(LauncherTest, DimmerSize) {
// Confirm that launching a browser gets the appropriate state reflected in
// its button.
TEST_F(LauncherTest, OpenBrowser) {
Launcher* launcher = Shell::GetInstance()->launcher();
Launcher* launcher = Launcher::ForPrimaryDisplay();
ASSERT_TRUE(launcher);
LauncherView* launcher_view = launcher->GetLauncherViewForTest();
test::LauncherViewTestAPI test(launcher_view);
Expand Down
5 changes: 2 additions & 3 deletions ash/launcher/launcher_view_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ class LauncherViewIconObserverTest : public ash::test::AshTestBase {

virtual void SetUp() OVERRIDE {
AshTestBase::SetUp();

Launcher* launcher = Shell::GetInstance()->launcher();
Launcher* launcher = Launcher::ForPrimaryDisplay();
observer_.reset(new TestLauncherIconObserver(launcher));

launcher_view_test_.reset(new LauncherViewTestAPI(
Expand Down Expand Up @@ -125,7 +124,7 @@ TEST_F(LauncherViewIconObserverTest, AddRemove) {
}

TEST_F(LauncherViewIconObserverTest, BoundsChanged) {
Launcher* launcher = Shell::GetInstance()->launcher();
Launcher* launcher = Launcher::ForPrimaryDisplay();
gfx::Size launcher_size =
launcher->widget()->GetWindowBoundsInScreen().size();
int total_width = launcher_size.width() / 2;
Expand Down
9 changes: 9 additions & 0 deletions ash/root_window_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,15 @@ RootWindowController::~RootWindowController() {
root_window_.reset();
}

// static
internal::RootWindowController*
RootWindowController::ForLauncher(aura::Window* window) {
if (Shell::IsLauncherPerDisplayEnabled())
return GetRootWindowController(window->GetRootWindow());
else
return Shell::GetPrimaryRootWindowController();
}

void RootWindowController::Shutdown() {
CloseChildWindows();
if (Shell::GetActiveRootWindow() == root_window_.get()) {
Expand Down
17 changes: 11 additions & 6 deletions ash/root_window_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ class ASH_EXPORT RootWindowController {
explicit RootWindowController(aura::RootWindow* root_window);
~RootWindowController();

// Returns a RootWindowController that has a launcher for given
// |window|. This returns the RootWindowController for the |window|'s
// root window when multiple launcher mode is enabled, or the primary
// RootWindowController otherwise.
static RootWindowController* ForLauncher(aura::Window* window);

aura::RootWindow* root_window() { return root_window_.get(); }

RootWindowLayoutManager* root_window_layout() { return root_window_layout_; }
Expand All @@ -60,10 +66,9 @@ class ASH_EXPORT RootWindowController {

Launcher* launcher() { return launcher_.get(); }

// TODO(sky): don't expose this!
internal::ShelfLayoutManager* shelf() const { return shelf_; }
ShelfLayoutManager* shelf() const { return shelf_; }

internal::StatusAreaWidget* status_area_widget() const {
StatusAreaWidget* status_area_widget() const {
return status_area_widget_;
}

Expand Down Expand Up @@ -131,15 +136,15 @@ class ASH_EXPORT RootWindowController {
RootWindowLayoutManager* root_window_layout_;

// Widget containing system tray.
internal::StatusAreaWidget* status_area_widget_;
StatusAreaWidget* status_area_widget_;

// The shelf for managing the launcher and the status widget.
// RootWindowController does not own the shelf. Instead, it is owned
// by container of the status area.
internal::ShelfLayoutManager* shelf_;
ShelfLayoutManager* shelf_;

// Manages layout of panels. Owned by PanelContainer.
internal::PanelLayoutManager* panel_layout_manager_;
PanelLayoutManager* panel_layout_manager_;

scoped_ptr<Launcher> launcher_;

Expand Down
4 changes: 3 additions & 1 deletion ash/screen_ash.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@

#include "ash/display/display_controller.h"
#include "ash/display/multi_display_manager.h"
#include "ash/root_window_controller.h"
#include "ash/shell.h"
#include "ash/wm/property_util.h"
#include "ash/wm/coordinate_conversion.h"
#include "ash/wm/shelf_layout_manager.h"
#include "base/logging.h"
Expand Down Expand Up @@ -39,7 +41,7 @@ gfx::Display ScreenAsh::FindDisplayContainingPoint(const gfx::Point& point) {

// static
gfx::Rect ScreenAsh::GetMaximizedWindowBoundsInParent(aura::Window* window) {
if (window->GetRootWindow() == Shell::GetPrimaryRootWindow())
if (GetRootWindowController(window->GetRootWindow())->launcher())
return GetDisplayWorkAreaBoundsInParent(window);
else
return GetDisplayBoundsInParent(window);
Expand Down
Loading

0 comments on commit 88d7112

Please sign in to comment.