Skip to content

Commit

Permalink
Refactor: Shelf Widget
Browse files Browse the repository at this point in the history
Refactor the classes related with displaying the shelf (background behind the launcher/status area widget) to be a separate class. Removing background delegates from the launcher and status area widget (represented on tray views).

TBR=ben@chromium.org
BUG=163002

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@187122 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
harrym@chromium.org committed Mar 9, 2013
1 parent 62ad309 commit 478c6c3
Show file tree
Hide file tree
Showing 88 changed files with 1,193 additions and 1,182 deletions.
5 changes: 3 additions & 2 deletions ash/accelerators/accelerator_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "ash/root_window_controller.h"
#include "ash/rotator/screen_rotation.h"
#include "ash/screenshot_delegate.h"
#include "ash/shelf/shelf_widget.h"
#include "ash/shell.h"
#include "ash/shell_delegate.h"
#include "ash/shell_window_ids.h"
Expand Down Expand Up @@ -614,7 +615,7 @@ bool AcceleratorController::PerformAction(int action,
break;
case FOCUS_LAUNCHER:
return shell->focus_cycler()->FocusWidget(
Launcher::ForPrimaryDisplay()->widget());
Launcher::ForPrimaryDisplay()->shelf_widget());
break;
case FOCUS_NEXT_PANE:
return HandleRotatePaneFocus(Shell::FORWARD);
Expand Down Expand Up @@ -645,7 +646,7 @@ bool AcceleratorController::PerformAction(int action,
internal::RootWindowController::ForActiveRootWindow() :
Shell::GetPrimaryRootWindowController();
internal::StatusAreaWidget* status_area_widget =
controller->status_area_widget();
controller->shelf()->status_area_widget();
if (status_area_widget) {
WebNotificationTray* notification_tray =
status_area_widget->web_notification_tray();
Expand Down
15 changes: 9 additions & 6 deletions ash/ash.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,6 @@
'keyboard_overlay/keyboard_overlay_view.h',
'launcher/app_list_button.cc',
'launcher/app_list_button.h',
'launcher/background_animator.cc',
'launcher/background_animator.h',
'launcher/launcher.cc',
'launcher/launcher.h',
'launcher/launcher_alignment_menu.cc',
Expand Down Expand Up @@ -161,11 +159,17 @@
'screensaver/screensaver_view.cc',
'screensaver/screensaver_view.h',
'screenshot_delegate.h',
'shelf/background_animator.cc',
'shelf/background_animator.h',
'shelf/shelf_layout_manager.cc',
'shelf/shelf_layout_manager.h',
'shelf/shelf_types.h',
'shelf/shelf_widget.cc',
'shelf/shelf_widget.h',
'shell.cc',
'shell.h',
'shell_delegate.h',
'shell_factory.h',
'shelf_types.h',
'shell_window_ids.h',
'system/audio/audio_observer.h',
'system/audio/tray_volume.cc',
Expand Down Expand Up @@ -388,8 +392,6 @@
'wm/session_state_controller_impl2.cc',
'wm/session_state_controller_impl2.h',
'wm/session_state_observer.h',
'wm/shelf_layout_manager.cc',
'wm/shelf_layout_manager.h',
'wm/stacking_controller.cc',
'wm/stacking_controller.h',
'wm/status_area_layout_manager.cc',
Expand Down Expand Up @@ -613,6 +615,8 @@
'root_window_controller_unittest.cc',
'screen_ash_unittest.cc',
'screensaver/screensaver_view_unittest.cc',
'shelf/shelf_layout_manager_unittest.cc',
'shelf/shelf_widget_unittest.cc',
'shell_unittest.cc',
'shell/app_list.cc',
'shell/bubble.cc',
Expand Down Expand Up @@ -644,7 +648,6 @@
'wm/power_button_controller_unittest.cc',
'wm/screen_dimmer_unittest.cc',
'wm/session_state_controller_impl2_unittest.cc',
'wm/shelf_layout_manager_unittest.cc',
'wm/stacking_controller_unittest.cc',
'wm/system_gesture_event_filter_unittest.cc',
'wm/system_modal_container_layout_manager_unittest.cc',
Expand Down
3 changes: 2 additions & 1 deletion ash/dip_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include "ash/display/display_manager.h"
#include "ash/launcher/launcher.h"
#include "ash/shelf/shelf_widget.h"
#include "ash/shell.h"
#include "ash/test/ash_test_base.h"
#include "ash/wm/window_properties.h"
Expand Down Expand Up @@ -63,7 +64,7 @@ TEST_F(DIPTest, WorkArea) {
Launcher* launcher = Launcher::ForPrimaryDisplay();
EXPECT_EQ(
display_2x.bounds().InsetsFrom(work_area).height(),
launcher->widget()->GetNativeView()->layer()->bounds().height());
launcher->shelf_widget()->GetNativeView()->layer()->bounds().height());
}

} // namespace ash
5 changes: 3 additions & 2 deletions ash/display/display_controller_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "ash/display/display_manager.h"
#include "ash/launcher/launcher.h"
#include "ash/screen_ash.h"
#include "ash/shelf/shelf_widget.h"
#include "ash/shell.h"
#include "ash/test/ash_test_base.h"
#include "ash/test/cursor_manager_test_api.h"
Expand Down Expand Up @@ -249,7 +250,7 @@ TEST_F(DisplayControllerTest, SwapPrimary) {
display_controller->GetRootWindowForDisplayId(secondary_display.id());
EXPECT_NE(primary_root, secondary_root);
aura::Window* launcher_window =
Launcher::ForPrimaryDisplay()->widget()->GetNativeView();
Launcher::ForPrimaryDisplay()->shelf_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 @@ -340,7 +341,7 @@ TEST_F(DisplayControllerTest, SwapPrimaryById) {
aura::RootWindow* secondary_root =
display_controller->GetRootWindowForDisplayId(secondary_display.id());
aura::Window* launcher_window =
Launcher::ForPrimaryDisplay()->widget()->GetNativeView();
Launcher::ForPrimaryDisplay()->shelf_widget()->GetNativeView();
EXPECT_TRUE(primary_root->Contains(launcher_window));
EXPECT_FALSE(secondary_root->Contains(launcher_window));
EXPECT_NE(primary_root, secondary_root);
Expand Down
92 changes: 46 additions & 46 deletions ash/focus_cycler_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include "ash/launcher/launcher.h"
#include "ash/root_window_controller.h"
#include "ash/shelf/shelf_widget.h"
#include "ash/shell.h"
#include "ash/shell_window_ids.h"
#include "ash/system/status_area_widget.h"
Expand Down Expand Up @@ -54,7 +55,7 @@ class FocusCyclerTest : public AshTestBase {
tray_.reset();
}

Launcher::ForPrimaryDisplay()->SetFocusCycler(NULL);
shelf_widget()->SetFocusCycler(NULL);

focus_cycler_.reset();

Expand Down Expand Up @@ -85,14 +86,13 @@ class FocusCyclerTest : public AshTestBase {

SystemTray* tray() { return tray_.get(); }

views::Widget* launcher_widget() {
return Launcher::ForPrimaryDisplay()->widget();
ShelfWidget* shelf_widget() {
return Launcher::ForPrimaryDisplay()->shelf_widget();
}

void InstallFocusCycleOnLauncher() {
// Add the launcher
Launcher* launcher = Launcher::ForPrimaryDisplay();
launcher->SetFocusCycler(focus_cycler());
void InstallFocusCycleOnShelf() {
// Add the shelf.
shelf_widget()->SetFocusCycler(focus_cycler());
}

private:
Expand All @@ -116,147 +116,147 @@ TEST_F(FocusCyclerTest, CycleFocusBrowserOnly) {
TEST_F(FocusCyclerTest, CycleFocusForward) {
ASSERT_TRUE(CreateTray());

InstallFocusCycleOnLauncher();
InstallFocusCycleOnShelf();

// Create a single test window.
scoped_ptr<Window> window0(CreateTestWindowInShellWithId(0));
wm::ActivateWindow(window0.get());
EXPECT_TRUE(wm::IsActiveWindow(window0.get()));

// Cycle focus to the status area
// Cycle focus to the status area.
focus_cycler()->RotateFocus(FocusCycler::FORWARD);
EXPECT_TRUE(tray()->GetWidget()->IsActive());

// Cycle focus to the launcher
// Cycle focus to the shelf.
focus_cycler()->RotateFocus(FocusCycler::FORWARD);
EXPECT_TRUE(launcher_widget()->IsActive());
EXPECT_TRUE(shelf_widget()->IsActive());

// Cycle focus to the browser
// Cycle focus to the browser.
focus_cycler()->RotateFocus(FocusCycler::FORWARD);
EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
}

TEST_F(FocusCyclerTest, CycleFocusBackward) {
ASSERT_TRUE(CreateTray());

InstallFocusCycleOnLauncher();
InstallFocusCycleOnShelf();

// Create a single test window.
scoped_ptr<Window> window0(CreateTestWindowInShellWithId(0));
wm::ActivateWindow(window0.get());
EXPECT_TRUE(wm::IsActiveWindow(window0.get()));

// Cycle focus to the launcher
// Cycle focus to the shelf.
focus_cycler()->RotateFocus(FocusCycler::BACKWARD);
EXPECT_TRUE(launcher_widget()->IsActive());
EXPECT_TRUE(shelf_widget()->IsActive());

// Cycle focus to the status area
// Cycle focus to the status area.
focus_cycler()->RotateFocus(FocusCycler::BACKWARD);
EXPECT_TRUE(tray()->GetWidget()->IsActive());

// Cycle focus to the browser
// Cycle focus to the browser.
focus_cycler()->RotateFocus(FocusCycler::BACKWARD);
EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
}

TEST_F(FocusCyclerTest, CycleFocusForwardBackward) {
ASSERT_TRUE(CreateTray());

InstallFocusCycleOnLauncher();
InstallFocusCycleOnShelf();

// Create a single test window.
scoped_ptr<Window> window0(CreateTestWindowInShellWithId(0));
wm::ActivateWindow(window0.get());
EXPECT_TRUE(wm::IsActiveWindow(window0.get()));

// Cycle focus to the launcher
// Cycle focus to the shelf.
focus_cycler()->RotateFocus(FocusCycler::BACKWARD);
EXPECT_TRUE(launcher_widget()->IsActive());
EXPECT_TRUE(shelf_widget()->IsActive());

// Cycle focus to the status area
// Cycle focus to the status area.
focus_cycler()->RotateFocus(FocusCycler::BACKWARD);
EXPECT_TRUE(tray()->GetWidget()->IsActive());

// Cycle focus to the browser
// Cycle focus to the browser.
focus_cycler()->RotateFocus(FocusCycler::BACKWARD);
EXPECT_TRUE(wm::IsActiveWindow(window0.get()));

// Cycle focus to the status area
// Cycle focus to the status area.
focus_cycler()->RotateFocus(FocusCycler::FORWARD);
EXPECT_TRUE(tray()->GetWidget()->IsActive());

// Cycle focus to the launcher
// Cycle focus to the shelf.
focus_cycler()->RotateFocus(FocusCycler::FORWARD);
EXPECT_TRUE(launcher_widget()->IsActive());
EXPECT_TRUE(shelf_widget()->IsActive());

// Cycle focus to the browser
// Cycle focus to the browser.
focus_cycler()->RotateFocus(FocusCycler::FORWARD);
EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
}

TEST_F(FocusCyclerTest, CycleFocusNoBrowser) {
ASSERT_TRUE(CreateTray());

InstallFocusCycleOnLauncher();
InstallFocusCycleOnShelf();

// Add the launcher and focus it
focus_cycler()->FocusWidget(launcher_widget());
// Add the shelf and focus it.
focus_cycler()->FocusWidget(shelf_widget());

// Cycle focus to the status area
// Cycle focus to the status area.
focus_cycler()->RotateFocus(FocusCycler::FORWARD);
EXPECT_TRUE(tray()->GetWidget()->IsActive());

// Cycle focus to the launcher
// Cycle focus to the shelf.
focus_cycler()->RotateFocus(FocusCycler::FORWARD);
EXPECT_TRUE(launcher_widget()->IsActive());
EXPECT_TRUE(shelf_widget()->IsActive());

// Cycle focus to the status area
// Cycle focus to the status area.
focus_cycler()->RotateFocus(FocusCycler::FORWARD);
EXPECT_TRUE(tray()->GetWidget()->IsActive());

// Cycle focus to the launcher
// Cycle focus to the shelf.
focus_cycler()->RotateFocus(FocusCycler::BACKWARD);
EXPECT_TRUE(launcher_widget()->IsActive());
EXPECT_TRUE(shelf_widget()->IsActive());

// Cycle focus to the status area
// Cycle focus to the status area.
focus_cycler()->RotateFocus(FocusCycler::BACKWARD);
EXPECT_TRUE(tray()->GetWidget()->IsActive());
}

TEST_F(FocusCyclerTest, Launcher_CycleFocusForward) {
TEST_F(FocusCyclerTest, Shelf_CycleFocusForward) {
ASSERT_TRUE(CreateTray());
InstallFocusCycleOnLauncher();
launcher_widget()->Hide();
InstallFocusCycleOnShelf();
shelf_widget()->Hide();

// Create a single test window.
scoped_ptr<Window> window0(CreateTestWindowInShellWithId(0));
wm::ActivateWindow(window0.get());
EXPECT_TRUE(wm::IsActiveWindow(window0.get()));

// Cycle focus to the status area
// Cycle focus to the status area.
focus_cycler()->RotateFocus(FocusCycler::FORWARD);
EXPECT_TRUE(tray()->GetWidget()->IsActive());

// Cycle focus to the browser
// Cycle focus to the browser.
focus_cycler()->RotateFocus(FocusCycler::FORWARD);
EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
}

TEST_F(FocusCyclerTest, Launcher_CycleFocusBackwardInvisible) {
TEST_F(FocusCyclerTest, Shelf_CycleFocusBackwardInvisible) {
ASSERT_TRUE(CreateTray());
InstallFocusCycleOnLauncher();
launcher_widget()->Hide();
InstallFocusCycleOnShelf();
shelf_widget()->Hide();

// Create a single test window.
scoped_ptr<Window> window0(CreateTestWindowInShellWithId(0));
wm::ActivateWindow(window0.get());
EXPECT_TRUE(wm::IsActiveWindow(window0.get()));

// Cycle focus to the status area
// Cycle focus to the status area.
focus_cycler()->RotateFocus(FocusCycler::BACKWARD);
EXPECT_TRUE(tray()->GetWidget()->IsActive());

// Cycle focus to the browser
// Cycle focus to the browser.
focus_cycler()->RotateFocus(FocusCycler::BACKWARD);
EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
}
Expand Down
Loading

0 comments on commit 478c6c3

Please sign in to comment.