summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ash/focus_cycler_unittest.cc5
-rw-r--r--ash/metrics/user_metrics_recorder.cc13
-rw-r--r--ash/root_window_controller.cc7
-rw-r--r--ash/root_window_controller.h6
-rw-r--r--ash/shelf/overflow_bubble.cc4
-rw-r--r--ash/shelf/overflow_bubble_view.cc30
-rw-r--r--ash/shelf/overflow_bubble_view.h3
-rw-r--r--ash/shelf/overflow_button.cc9
-rw-r--r--ash/shelf/overflow_button.h6
-rw-r--r--ash/shelf/shelf.cc17
-rw-r--r--ash/shelf/shelf.h38
-rw-r--r--ash/shelf/shelf_alignment_menu.cc7
-rw-r--r--ash/shelf/shelf_button.cc73
-rw-r--r--ash/shelf/shelf_button.h16
-rw-r--r--ash/shelf/shelf_layout_manager.cc6
-rw-r--r--ash/shelf/shelf_layout_manager.h4
-rw-r--r--ash/shelf/shelf_layout_manager_unittest.cc8
-rw-r--r--ash/shelf/shelf_tooltip_manager.cc11
-rw-r--r--ash/shelf/shelf_view.cc149
-rw-r--r--ash/shelf/shelf_view.h21
-rw-r--r--ash/shelf/shelf_view_unittest.cc8
-rw-r--r--ash/shell.cc24
-rw-r--r--ash/system/web_notification/ash_popup_alignment_delegate_unittest.cc15
-rw-r--r--ash/wm/app_list_controller.cc9
-rw-r--r--ash/wm/dock/docked_window_layout_manager.cc22
-rw-r--r--ash/wm/panels/panel_layout_manager.cc24
-rw-r--r--ash/wm/panels/panel_layout_manager_unittest.cc20
-rw-r--r--ash/wm/window_animations.cc23
-rw-r--r--ash/wm/workspace/workspace_layout_manager_unittest.cc16
-rw-r--r--chrome/browser/chromeos/accessibility/accessibility_manager.cc5
-rw-r--r--chrome/browser/chromeos/accessibility/chromevox_panel.cc4
-rw-r--r--chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc9
-rw-r--r--chrome/browser/ui/ash/shelf_browsertest.cc35
33 files changed, 275 insertions, 372 deletions
diff --git a/ash/focus_cycler_unittest.cc b/ash/focus_cycler_unittest.cc
index 64ed1fe..e0b5ea1 100644
--- a/ash/focus_cycler_unittest.cc
+++ b/ash/focus_cycler_unittest.cc
@@ -6,7 +6,6 @@
#include "ash/root_window_controller.h"
#include "ash/shelf/shelf.h"
-#include "ash/shelf/shelf_layout_manager.h"
#include "ash/shelf/shelf_widget.h"
#include "ash/shell.h"
#include "ash/shell_factory.h"
@@ -94,9 +93,7 @@ class FocusCyclerTest : public AshTestBase {
Shell::GetPrimaryRootWindowController()->GetContainer(
ash::kShellWindowId_StatusContainer);
- StatusAreaWidget* widget = new StatusAreaWidget(
- parent,
- ShelfLayoutManager::ForShelf(parent->GetRootWindow())->shelf_widget());
+ StatusAreaWidget* widget = new StatusAreaWidget(parent, shelf_widget());
widget->CreateTrayViews();
widget->Show();
tray_.reset(widget->system_tray());
diff --git a/ash/metrics/user_metrics_recorder.cc b/ash/metrics/user_metrics_recorder.cc
index 040fc76..df523b1 100644
--- a/ash/metrics/user_metrics_recorder.cc
+++ b/ash/metrics/user_metrics_recorder.cc
@@ -6,12 +6,11 @@
#include "ash/metrics/desktop_task_switch_metric_recorder.h"
#include "ash/session/session_state_delegate.h"
+#include "ash/shelf/shelf.h"
#include "ash/shelf/shelf_delegate.h"
#include "ash/shelf/shelf_item_types.h"
-#include "ash/shelf/shelf_layout_manager.h"
#include "ash/shelf/shelf_model.h"
#include "ash/shelf/shelf_view.h"
-#include "ash/shelf/shelf_widget.h"
#include "ash/shell.h"
#include "ash/shell_window_ids.h"
#include "ash/system/tray/system_tray_delegate.h"
@@ -622,18 +621,16 @@ void UserMetricsRecorder::OnShellShuttingDown() {
}
void UserMetricsRecorder::RecordPeriodicMetrics() {
- ShelfLayoutManager* manager =
- ShelfLayoutManager::ForShelf(Shell::GetPrimaryRootWindow());
+ Shelf* shelf = Shelf::ForPrimaryDisplay();
// TODO(bruthig): Investigating whether the check for |manager| is necessary
// and add tests if it is.
- if (manager) {
+ if (shelf) {
// TODO(bruthig): Consider tracking the time spent in each alignment.
UMA_HISTOGRAM_ENUMERATION("Ash.ShelfAlignmentOverTime",
- manager->SelectValueForShelfAlignment(
+ shelf->SelectValueForShelfAlignment(
SHELF_ALIGNMENT_UMA_ENUM_VALUE_BOTTOM,
SHELF_ALIGNMENT_UMA_ENUM_VALUE_LEFT,
- SHELF_ALIGNMENT_UMA_ENUM_VALUE_RIGHT,
- -1),
+ SHELF_ALIGNMENT_UMA_ENUM_VALUE_RIGHT, -1),
SHELF_ALIGNMENT_UMA_ENUM_VALUE_COUNT);
}
diff --git a/ash/root_window_controller.cc b/ash/root_window_controller.cc
index c130e0f..1ae8355 100644
--- a/ash/root_window_controller.cc
+++ b/ash/root_window_controller.cc
@@ -274,13 +274,6 @@ void RootWindowController::CreateForSecondaryDisplay(AshWindowTreeHost* host) {
}
// static
-RootWindowController* RootWindowController::ForShelf(
- const aura::Window* window) {
- CHECK(Shell::HasInstance());
- return GetRootWindowController(window->GetRootWindow());
-}
-
-// static
RootWindowController* RootWindowController::ForWindow(
const aura::Window* window) {
CHECK(Shell::HasInstance());
diff --git a/ash/root_window_controller.h b/ash/root_window_controller.h
index 139b11e..3e1f373 100644
--- a/ash/root_window_controller.h
+++ b/ash/root_window_controller.h
@@ -85,12 +85,6 @@ class ASH_EXPORT RootWindowController : public ShellObserver {
// Creates and Initialize the RootWindowController for secondary displays.
static void CreateForSecondaryDisplay(AshWindowTreeHost* host);
- // Returns a RootWindowController that has a shelf for given
- // |window|. This returns the RootWindowController for the |window|'s
- // root window when multiple shelf mode is enabled, or the primary
- // RootWindowController otherwise.
- static RootWindowController* ForShelf(const aura::Window* window);
-
// Returns a RootWindowController of the window's root window.
static RootWindowController* ForWindow(const aura::Window* window);
diff --git a/ash/shelf/overflow_bubble.cc b/ash/shelf/overflow_bubble.cc
index 6290099..933f4a5 100644
--- a/ash/shelf/overflow_bubble.cc
+++ b/ash/shelf/overflow_bubble.cc
@@ -6,7 +6,7 @@
#include "ash/root_window_controller.h"
#include "ash/shelf/overflow_bubble_view.h"
-#include "ash/shelf/shelf_layout_manager.h"
+#include "ash/shelf/shelf.h"
#include "ash/shelf/shelf_view.h"
#include "ash/shelf/shelf_widget.h"
#include "ash/shell.h"
@@ -94,7 +94,7 @@ void OverflowBubble::OnWidgetDestroying(views::Widget* widget) {
DCHECK(widget == bubble_->GetWidget());
bubble_ = NULL;
anchor_ = NULL;
- shelf_view_->shelf_layout_manager()->shelf_widget()->shelf()->SchedulePaint();
+ shelf_view_->shelf()->SchedulePaint();
shelf_view_ = NULL;
}
diff --git a/ash/shelf/overflow_bubble_view.cc b/ash/shelf/overflow_bubble_view.cc
index b15f7b7..d982820 100644
--- a/ash/shelf/overflow_bubble_view.cc
+++ b/ash/shelf/overflow_bubble_view.cc
@@ -7,8 +7,8 @@
#include <algorithm>
#include "ash/root_window_controller.h"
+#include "ash/shelf/shelf.h"
#include "ash/shelf/shelf_constants.h"
-#include "ash/shelf/shelf_layout_manager.h"
#include "ash/shelf/shelf_view.h"
#include "ash/shell.h"
#include "ash/shell_window_ids.h"
@@ -32,12 +32,9 @@ const int kShelfViewLeadingInset = 8;
} // namespace
-OverflowBubbleView::OverflowBubbleView()
- : shelf_view_(NULL) {
-}
+OverflowBubbleView::OverflowBubbleView() : shelf_view_(NULL) {}
-OverflowBubbleView::~OverflowBubbleView() {
-}
+OverflowBubbleView::~OverflowBubbleView() {}
void OverflowBubbleView::InitOverflowBubble(views::View* anchor,
ShelfView* shelf_view) {
@@ -65,9 +62,7 @@ void OverflowBubbleView::InitOverflowBubble(views::View* anchor,
}
bool OverflowBubbleView::IsHorizontalAlignment() const {
- ShelfLayoutManager* shelf_layout_manager = GetShelfLayoutManager();
- return shelf_layout_manager ? shelf_layout_manager->IsHorizontalAlignment()
- : false;
+ return shelf_view_ ? shelf_view_->shelf()->IsHorizontalAlignment() : false;
}
const gfx::Size OverflowBubbleView::GetContentsSize() const {
@@ -76,14 +71,11 @@ const gfx::Size OverflowBubbleView::GetContentsSize() const {
// Gets arrow location based on shelf alignment.
views::BubbleBorder::Arrow OverflowBubbleView::GetBubbleArrow() const {
- ShelfLayoutManager* shelf_layout_manager = GetShelfLayoutManager();
- return shelf_layout_manager ?
- shelf_layout_manager->SelectValueForShelfAlignment(
- views::BubbleBorder::BOTTOM_LEFT,
- views::BubbleBorder::LEFT_TOP,
- views::BubbleBorder::RIGHT_TOP,
- views::BubbleBorder::TOP_LEFT) :
- views::BubbleBorder::NONE;
+ if (!shelf_view_)
+ return views::BubbleBorder::NONE;
+ return shelf_view_->shelf()->SelectValueForShelfAlignment(
+ views::BubbleBorder::BOTTOM_LEFT, views::BubbleBorder::LEFT_TOP,
+ views::BubbleBorder::RIGHT_TOP, views::BubbleBorder::TOP_LEFT);
}
void OverflowBubbleView::ScrollByXOffset(int x_offset) {
@@ -106,10 +98,6 @@ void OverflowBubbleView::ScrollByYOffset(int y_offset) {
scroll_offset_.set_y(y);
}
-ShelfLayoutManager* OverflowBubbleView::GetShelfLayoutManager() const {
- return shelf_view_ ? shelf_view_->shelf_layout_manager() : nullptr;
-}
-
gfx::Size OverflowBubbleView::GetPreferredSize() const {
gfx::Size preferred_size = GetContentsSize();
diff --git a/ash/shelf/overflow_bubble_view.h b/ash/shelf/overflow_bubble_view.h
index 5feeeed..fd31157 100644
--- a/ash/shelf/overflow_bubble_view.h
+++ b/ash/shelf/overflow_bubble_view.h
@@ -11,7 +11,6 @@
#include "ui/views/bubble/bubble_delegate.h"
namespace ash {
-class ShelfLayoutManager;
class ShelfView;
namespace test {
@@ -43,8 +42,6 @@ class ASH_EXPORT OverflowBubbleView : public views::BubbleDelegateView {
void ScrollByXOffset(int x_offset);
void ScrollByYOffset(int y_offset);
- ShelfLayoutManager* GetShelfLayoutManager() const;
-
// views::View overrides:
gfx::Size GetPreferredSize() const override;
void Layout() override;
diff --git a/ash/shelf/overflow_button.cc b/ash/shelf/overflow_button.cc
index 16db6f8..f338e5c 100644
--- a/ash/shelf/overflow_button.cc
+++ b/ash/shelf/overflow_button.cc
@@ -5,6 +5,7 @@
#include "ash/shelf/overflow_button.h"
#include "ash/ash_switches.h"
+#include "ash/shelf/shelf.h"
#include "ash/shelf/shelf_layout_manager.h"
#include "ash/shelf/shelf_widget.h"
#include "grit/ash_resources.h"
@@ -34,8 +35,7 @@ const int kBackgroundOffset = (48 - kButtonHoverSize) / 2;
} // namesapce
-OverflowButton::OverflowButton(views::ButtonListener* listener,
- ShelfLayoutManager* shelf)
+OverflowButton::OverflowButton(views::ButtonListener* listener, Shelf* shelf)
: CustomButton(listener), bottom_image_(nullptr), shelf_(shelf) {
ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance();
bottom_image_ = rb->GetImageNamed(IDR_ASH_SHELF_OVERFLOW).ToImageSkia();
@@ -80,12 +80,10 @@ void OverflowButton::PaintBackground(gfx::Canvas* canvas, int alpha) {
}
void OverflowButton::OnPaint(gfx::Canvas* canvas) {
- ShelfAlignment alignment = shelf_->GetAlignment();
-
gfx::Rect bounds(GetContentsBounds());
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
int background_image_id = 0;
- if (shelf_->shelf_widget()->shelf()->IsShowingOverflowBubble())
+ if (shelf_->IsShowingOverflowBubble())
background_image_id = IDR_AURA_NOTIFICATION_BACKGROUND_PRESSED;
else if (shelf_->shelf_widget()->GetDimsShelf())
background_image_id = IDR_AURA_NOTIFICATION_BACKGROUND_ON_BLACK;
@@ -94,6 +92,7 @@ void OverflowButton::OnPaint(gfx::Canvas* canvas) {
const gfx::ImageSkia* background =
rb.GetImageNamed(background_image_id).ToImageSkia();
+ ShelfAlignment alignment = shelf_->alignment();
if (alignment == SHELF_ALIGNMENT_LEFT) {
bounds = gfx::Rect(
bounds.right() - background->width() -
diff --git a/ash/shelf/overflow_button.h b/ash/shelf/overflow_button.h
index 23270dd..92cc6b7 100644
--- a/ash/shelf/overflow_button.h
+++ b/ash/shelf/overflow_button.h
@@ -13,12 +13,12 @@
namespace ash {
-class ShelfLayoutManager;
+class Shelf;
// Shelf overflow chevron button.
class OverflowButton : public views::CustomButton {
public:
- OverflowButton(views::ButtonListener* listener, ShelfLayoutManager* shelf);
+ OverflowButton(views::ButtonListener* listener, Shelf* shelf);
~OverflowButton() override;
void OnShelfAlignmentChanged();
@@ -35,7 +35,7 @@ class OverflowButton : public views::CustomButton {
gfx::ImageSkia right_image_;
// Bottom image is owned by the resource bundle.
const gfx::ImageSkia* bottom_image_;
- ShelfLayoutManager* shelf_;
+ Shelf* shelf_;
DISALLOW_COPY_AND_ASSIGN(OverflowButton);
};
diff --git a/ash/shelf/shelf.cc b/ash/shelf/shelf.cc
index 0a02248..5cae789 100644
--- a/ash/shelf/shelf.cc
+++ b/ash/shelf/shelf.cc
@@ -18,7 +18,6 @@
#include "ash/shelf/shelf_navigator.h"
#include "ash/shelf/shelf_util.h"
#include "ash/shelf/shelf_view.h"
-#include "ash/shelf/shelf_widget.h"
#include "ash/shell.h"
#include "ash/shell_delegate.h"
#include "ash/shell_window_ids.h"
@@ -47,8 +46,7 @@ Shelf::Shelf(ShelfModel* shelf_model,
alignment_(shelf_widget->GetAlignment()),
delegate_(shelf_delegate),
shelf_widget_(shelf_widget) {
- shelf_view_ = new ShelfView(
- shelf_model, delegate_, shelf_widget_->shelf_layout_manager());
+ shelf_view_ = new ShelfView(shelf_model, delegate_, this);
shelf_view_->Init();
shelf_widget_->GetContentsView()->AddChildView(shelf_view_);
shelf_widget_->GetNativeView()->SetName(kNativeViewName);
@@ -61,14 +59,12 @@ Shelf::~Shelf() {
// static
Shelf* Shelf::ForPrimaryDisplay() {
- ShelfWidget* shelf_widget =
- RootWindowController::ForShelf(Shell::GetPrimaryRootWindow())->shelf();
- return shelf_widget ? shelf_widget->shelf() : NULL;
+ return Shelf::ForWindow(Shell::GetPrimaryRootWindow());
}
// static
-Shelf* Shelf::ForWindow(aura::Window* window) {
- ShelfWidget* shelf_widget = RootWindowController::ForShelf(window)->shelf();
+Shelf* Shelf::ForWindow(const aura::Window* window) {
+ ShelfWidget* shelf_widget = RootWindowController::ForWindow(window)->shelf();
return shelf_widget ? shelf_widget->shelf() : NULL;
}
@@ -78,6 +74,11 @@ void Shelf::SetAlignment(ShelfAlignment alignment) {
// ShelfLayoutManager will resize the shelf.
}
+bool Shelf::IsHorizontalAlignment() const {
+ return alignment_ == SHELF_ALIGNMENT_BOTTOM ||
+ alignment_ == SHELF_ALIGNMENT_TOP;
+}
+
gfx::Rect Shelf::GetScreenBoundsOfItemIconForWindow(
const aura::Window* window) {
ShelfID id = GetShelfIDForWindow(window);
diff --git a/ash/shelf/shelf.h b/ash/shelf/shelf.h
index 59cb009..c00895f 100644
--- a/ash/shelf/shelf.h
+++ b/ash/shelf/shelf.h
@@ -8,6 +8,7 @@
#include "ash/ash_export.h"
#include "ash/shelf/shelf_constants.h"
#include "ash/shelf/shelf_types.h"
+#include "ash/shelf/shelf_widget.h"
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "ui/gfx/geometry/size.h"
@@ -35,13 +36,11 @@ class ShelfDelegate;
class ShelfIconObserver;
class ShelfModel;
class ShelfView;
-class ShelfWidget;
namespace test {
class ShelfTestAPI;
}
-
class ASH_EXPORT Shelf {
public:
static const char kNativeViewName[];
@@ -53,12 +52,36 @@ class ASH_EXPORT Shelf {
static Shelf* ForPrimaryDisplay();
// Return the shelf for the display that |window| is currently on, or a shelf
- // on primary display if the shelf per display feature is disabled. NULL if
- // no user is logged in yet.
- static Shelf* ForWindow(aura::Window* window);
+ // on primary display if the shelf per display feature is disabled. NULL if no
+ // user is logged in yet.
+ static Shelf* ForWindow(const aura::Window* window);
void SetAlignment(ShelfAlignment alignment);
ShelfAlignment alignment() const { return alignment_; }
+ bool IsHorizontalAlignment() const;
+
+ // A helper functions that chooses values specific to a shelf alignment.
+ template <typename T>
+ T SelectValueForShelfAlignment(T bottom, T left, T right, T top) const {
+ switch (alignment_) {
+ case SHELF_ALIGNMENT_BOTTOM:
+ return bottom;
+ case SHELF_ALIGNMENT_LEFT:
+ return left;
+ case SHELF_ALIGNMENT_RIGHT:
+ return right;
+ case SHELF_ALIGNMENT_TOP:
+ return top;
+ }
+ NOTREACHED();
+ return right;
+ }
+
+ // A helper functions that chooses values specific to a shelf alignment type.
+ template <typename T>
+ T PrimaryAxisValue(T horizontal, T vertical) const {
+ return IsHorizontalAlignment() ? horizontal : vertical;
+ }
// Returns the screen bounds of the item for the specified window. If there is
// no item for the specified window an empty rect is returned.
@@ -96,6 +119,11 @@ class ASH_EXPORT Shelf {
ShelfWidget* shelf_widget() { return shelf_widget_; }
+ // TODO(msw): ShelfLayoutManager should not be accessed externally.
+ ShelfLayoutManager* shelf_layout_manager() {
+ return shelf_widget_->shelf_layout_manager();
+ }
+
// Set the bounds of the shelf view.
void SetShelfViewBounds(gfx::Rect bounds);
gfx::Rect GetShelfViewBounds() const;
diff --git a/ash/shelf/shelf_alignment_menu.cc b/ash/shelf/shelf_alignment_menu.cc
index 6194b3b..5b14e8f 100644
--- a/ash/shelf/shelf_alignment_menu.cc
+++ b/ash/shelf/shelf_alignment_menu.cc
@@ -5,7 +5,7 @@
#include "ash/shelf/shelf_alignment_menu.h"
#include "ash/metrics/user_metrics_recorder.h"
-#include "ash/shelf/shelf_layout_manager.h"
+#include "ash/shelf/shelf.h"
#include "ash/shelf/shelf_types.h"
#include "ash/shell.h"
#include "grit/ash_strings.h"
@@ -33,11 +33,10 @@ ShelfAlignmentMenu::ShelfAlignmentMenu(aura::Window* root)
ShelfAlignmentMenu::~ShelfAlignmentMenu() {}
bool ShelfAlignmentMenu::IsCommandIdChecked(int command_id) const {
- return ShelfLayoutManager::ForShelf(root_window_)
+ return Shelf::ForWindow(root_window_)
->SelectValueForShelfAlignment(MENU_ALIGN_BOTTOM == command_id,
MENU_ALIGN_LEFT == command_id,
- MENU_ALIGN_RIGHT == command_id,
- false);
+ MENU_ALIGN_RIGHT == command_id, false);
}
bool ShelfAlignmentMenu::IsCommandIdEnabled(int command_id) const {
diff --git a/ash/shelf/shelf_button.cc b/ash/shelf/shelf_button.cc
index 6329694..43d98c5 100644
--- a/ash/shelf/shelf_button.cc
+++ b/ash/shelf/shelf_button.cc
@@ -8,8 +8,8 @@
#include "ash/ash_constants.h"
#include "ash/ash_switches.h"
+#include "ash/shelf/shelf.h"
#include "ash/shelf/shelf_button_host.h"
-#include "ash/shelf/shelf_layout_manager.h"
#include "base/time/time.h"
#include "grit/ash_resources.h"
#include "skia/ext/image_operations.h"
@@ -180,8 +180,7 @@ class ShelfButton::BarView : public views::ImageView,
double animation = animating_ ?
ShelfButtonAnimation::GetInstance()->GetAnimation() : 1.0;
double scale = .35 + .65 * animation;
- if (host_->shelf_layout_manager()->GetAlignment() ==
- SHELF_ALIGNMENT_BOTTOM) {
+ if (host_->shelf()->alignment() == SHELF_ALIGNMENT_BOTTOM) {
int width = base_bounds_.width() * scale;
bounds.set_width(std::min(width, kIconSize));
int x_offset = (base_bounds_.width() - bounds.width()) / 2;
@@ -236,21 +235,21 @@ const char ShelfButton::kViewClassName[] = "ash/ShelfButton";
ShelfButton* ShelfButton::Create(views::ButtonListener* listener,
ShelfButtonHost* host,
- ShelfLayoutManager* shelf_layout_manager) {
- ShelfButton* button = new ShelfButton(listener, host, shelf_layout_manager);
+ Shelf* shelf) {
+ ShelfButton* button = new ShelfButton(listener, host, shelf);
button->Init();
return button;
}
ShelfButton::ShelfButton(views::ButtonListener* listener,
ShelfButtonHost* host,
- ShelfLayoutManager* shelf_layout_manager)
+ Shelf* shelf)
: CustomButton(listener),
host_(host),
icon_view_(NULL),
bar_(new BarView(this)),
state_(STATE_NORMAL),
- shelf_layout_manager_(shelf_layout_manager),
+ shelf_(shelf),
destroyed_flag_(NULL) {
SetAccessibilityFocusable(true);
@@ -402,11 +401,9 @@ void ShelfButton::GetAccessibleState(ui::AXViewState* state) {
void ShelfButton::Layout() {
const gfx::Rect button_bounds(GetContentsBounds());
- int icon_pad =
- shelf_layout_manager_->GetAlignment() != SHELF_ALIGNMENT_BOTTOM ?
- kIconPadVertical : kIconPad;
- int x_offset = shelf_layout_manager_->PrimaryAxisValue(0, icon_pad);
- int y_offset = shelf_layout_manager_->PrimaryAxisValue(icon_pad, 0);
+ int icon_pad = shelf_->IsHorizontalAlignment() ? kIconPad : kIconPadVertical;
+ int x_offset = shelf_->PrimaryAxisValue(0, icon_pad);
+ int y_offset = shelf_->PrimaryAxisValue(icon_pad, 0);
int icon_width = std::min(kIconSize,
button_bounds.width() - x_offset);
@@ -415,15 +412,15 @@ void ShelfButton::Layout() {
// If on the left or top 'invert' the inset so the constant gap is on
// the interior (towards the center of display) edge of the shelf.
- if (SHELF_ALIGNMENT_LEFT == shelf_layout_manager_->GetAlignment())
+ if (SHELF_ALIGNMENT_LEFT == shelf_->alignment())
x_offset = button_bounds.width() - (kIconSize + icon_pad);
- if (SHELF_ALIGNMENT_TOP == shelf_layout_manager_->GetAlignment())
+ if (SHELF_ALIGNMENT_TOP == shelf_->alignment())
y_offset = button_bounds.height() - (kIconSize + icon_pad);
// Center icon with respect to the secondary axis, and ensure
// that the icon doesn't occlude the bar highlight.
- if (shelf_layout_manager_->IsHorizontalAlignment()) {
+ if (shelf_->IsHorizontalAlignment()) {
x_offset = std::max(0, button_bounds.width() - icon_width) / 2;
if (y_offset + icon_height + kBarSize > button_bounds.height())
icon_height = button_bounds.height() - (y_offset + kBarSize);
@@ -520,19 +517,13 @@ ShelfButton::IconView* ShelfButton::CreateIconView() {
return new IconView;
}
-bool ShelfButton::IsShelfHorizontal() const {
- return shelf_layout_manager_->IsHorizontalAlignment();
-}
-
void ShelfButton::UpdateState() {
UpdateBar();
- icon_view_->SetHorizontalAlignment(
- shelf_layout_manager_->PrimaryAxisValue(views::ImageView::CENTER,
- views::ImageView::LEADING));
- icon_view_->SetVerticalAlignment(
- shelf_layout_manager_->PrimaryAxisValue(views::ImageView::LEADING,
- views::ImageView::CENTER));
+ icon_view_->SetHorizontalAlignment(shelf_->PrimaryAxisValue(
+ views::ImageView::CENTER, views::ImageView::LEADING));
+ icon_view_->SetVerticalAlignment(shelf_->PrimaryAxisValue(
+ views::ImageView::LEADING, views::ImageView::CENTER));
SchedulePaint();
}
@@ -553,28 +544,22 @@ void ShelfButton::UpdateBar() {
if (bar_id != 0) {
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
const gfx::ImageSkia* image = rb.GetImageNamed(bar_id).ToImageSkia();
- if (shelf_layout_manager_->GetAlignment() == SHELF_ALIGNMENT_BOTTOM) {
+ if (shelf_->alignment() == SHELF_ALIGNMENT_BOTTOM) {
bar_->SetImage(*image);
} else {
- bar_->SetImage(gfx::ImageSkiaOperations::CreateRotatedImage(*image,
- shelf_layout_manager_->SelectValueForShelfAlignment(
- SkBitmapOperations::ROTATION_90_CW,
- SkBitmapOperations::ROTATION_90_CW,
- SkBitmapOperations::ROTATION_270_CW,
- SkBitmapOperations::ROTATION_180_CW)));
+ bar_->SetImage(gfx::ImageSkiaOperations::CreateRotatedImage(
+ *image, shelf_->SelectValueForShelfAlignment(
+ SkBitmapOperations::ROTATION_90_CW,
+ SkBitmapOperations::ROTATION_90_CW,
+ SkBitmapOperations::ROTATION_270_CW,
+ SkBitmapOperations::ROTATION_180_CW)));
}
- bar_->SetHorizontalAlignment(
- shelf_layout_manager_->SelectValueForShelfAlignment(
- views::ImageView::CENTER,
- views::ImageView::LEADING,
- views::ImageView::TRAILING,
- views::ImageView::CENTER));
- bar_->SetVerticalAlignment(
- shelf_layout_manager_->SelectValueForShelfAlignment(
- views::ImageView::TRAILING,
- views::ImageView::CENTER,
- views::ImageView::CENTER,
- views::ImageView::LEADING));
+ bar_->SetHorizontalAlignment(shelf_->SelectValueForShelfAlignment(
+ views::ImageView::CENTER, views::ImageView::LEADING,
+ views::ImageView::TRAILING, views::ImageView::CENTER));
+ bar_->SetVerticalAlignment(shelf_->SelectValueForShelfAlignment(
+ views::ImageView::TRAILING, views::ImageView::CENTER,
+ views::ImageView::CENTER, views::ImageView::LEADING));
bar_->SchedulePaint();
}
diff --git a/ash/shelf/shelf_button.h b/ash/shelf/shelf_button.h
index 20dea7d..4e63e9e 100644
--- a/ash/shelf/shelf_button.h
+++ b/ash/shelf/shelf_button.h
@@ -12,8 +12,8 @@
#include "ui/views/controls/image_view.h"
namespace ash {
+class Shelf;
class ShelfButtonHost;
-class ShelfLayoutManager;
// Button used for items on the launcher, except for the AppList.
class ASH_EXPORT ShelfButton : public views::CustomButton {
@@ -43,7 +43,7 @@ class ASH_EXPORT ShelfButton : public views::CustomButton {
// Called to create an instance of a ShelfButton.
static ShelfButton* Create(views::ButtonListener* listener,
ShelfButtonHost* host,
- ShelfLayoutManager* shelf_layout_manager);
+ Shelf* shelf);
// Sets the image to display for this entry.
void SetImage(const gfx::ImageSkia& image);
@@ -55,9 +55,7 @@ class ASH_EXPORT ShelfButton : public views::CustomButton {
void AddState(State state);
void ClearState(State state);
int state() const { return state_; }
- const ShelfLayoutManager* shelf_layout_manager() const {
- return shelf_layout_manager_;
- }
+ const Shelf* shelf() const { return shelf_; }
// Returns the bounds of the icon.
gfx::Rect GetIconBounds() const;
@@ -72,7 +70,7 @@ class ASH_EXPORT ShelfButton : public views::CustomButton {
protected:
ShelfButton(views::ButtonListener* listener,
ShelfButtonHost* host,
- ShelfLayoutManager* shelf_layout_manager);
+ Shelf* shelf);
// Class that draws the icon part of a button, so it can be animated
// independently of the rest. This can be subclassed to provide a custom
@@ -123,10 +121,6 @@ class ASH_EXPORT ShelfButton : public views::CustomButton {
private:
class BarView;
- // Returns true if the shelf is horizontal. If this returns false the shelf is
- // vertical.
- bool IsShelfHorizontal() const;
-
// Updates the parts of the button to reflect the current |state_| and
// alignment. This may add or remove views, layout and paint.
void UpdateState();
@@ -142,7 +136,7 @@ class ASH_EXPORT ShelfButton : public views::CustomButton {
// together.
int state_;
- ShelfLayoutManager* shelf_layout_manager_;
+ Shelf* shelf_;
gfx::ShadowValues icon_shadows_;
diff --git a/ash/shelf/shelf_layout_manager.cc b/ash/shelf/shelf_layout_manager.cc
index 110f38c..c2e65a5 100644
--- a/ash/shelf/shelf_layout_manager.cc
+++ b/ash/shelf/shelf_layout_manager.cc
@@ -544,12 +544,6 @@ void ShelfLayoutManager::SetChromeVoxPanelHeight(int height) {
LayoutShelf();
}
-// static
-ShelfLayoutManager* ShelfLayoutManager::ForShelf(aura::Window* window) {
- ShelfWidget* shelf = RootWindowController::ForShelf(window)->shelf();
- return shelf ? shelf->shelf_layout_manager() : NULL;
-}
-
////////////////////////////////////////////////////////////////////////////////
// ShelfLayoutManager, private:
diff --git a/ash/shelf/shelf_layout_manager.h b/ash/shelf/shelf_layout_manager.h
index 1c32e7c..3f21f004 100644
--- a/ash/shelf/shelf_layout_manager.h
+++ b/ash/shelf/shelf_layout_manager.h
@@ -219,10 +219,6 @@ class ASH_EXPORT ShelfLayoutManager
// available work area from the top of the screen.
void SetChromeVoxPanelHeight(int height);
- // Returns a ShelfLayoutManager on the display which has a shelf for
- // given |window|. See RootWindowController::ForShelf for more info.
- static ShelfLayoutManager* ForShelf(aura::Window* window);
-
private:
class AutoHideEventFilter;
class UpdateShelfObserver;
diff --git a/ash/shelf/shelf_layout_manager_unittest.cc b/ash/shelf/shelf_layout_manager_unittest.cc
index d2991be..d70cfd1 100644
--- a/ash/shelf/shelf_layout_manager_unittest.cc
+++ b/ash/shelf/shelf_layout_manager_unittest.cc
@@ -180,11 +180,9 @@ class ShelfDragCallback {
scroll_.y(),
scroll_.x());
bool increasing_drag =
- GetShelfLayoutManager()->SelectValueForShelfAlignment(
- scroll_delta < 0,
- scroll_delta > 0,
- scroll_delta < 0,
- scroll_delta > 0);
+ GetShelfWidget()->shelf()->SelectValueForShelfAlignment(
+ scroll_delta < 0, scroll_delta > 0,
+ scroll_delta < 0, scroll_delta > 0);
int shelf_size = GetShelfLayoutManager()->PrimaryAxisValue(
shelf_bounds.height(),
shelf_bounds.width());
diff --git a/ash/shelf/shelf_tooltip_manager.cc b/ash/shelf/shelf_tooltip_manager.cc
index 66f583f..3252ae1c 100644
--- a/ash/shelf/shelf_tooltip_manager.cc
+++ b/ash/shelf/shelf_tooltip_manager.cc
@@ -4,6 +4,7 @@
#include "ash/shelf/shelf_tooltip_manager.h"
+#include "ash/shelf/shelf.h"
#include "ash/shelf/shelf_layout_manager.h"
#include "ash/shelf/shelf_view.h"
#include "ash/shell.h"
@@ -344,12 +345,10 @@ void ShelfTooltipManager::CreateBubble(views::View* anchor,
anchor_ = anchor;
text_ = text;
- views::BubbleBorder::Arrow arrow =
- shelf_layout_manager_->SelectValueForShelfAlignment(
- views::BubbleBorder::BOTTOM_CENTER,
- views::BubbleBorder::LEFT_CENTER,
- views::BubbleBorder::RIGHT_CENTER,
- views::BubbleBorder::TOP_CENTER);
+ Shelf* shelf = shelf_layout_manager_->shelf_widget()->shelf();
+ views::BubbleBorder::Arrow arrow = shelf->SelectValueForShelfAlignment(
+ views::BubbleBorder::BOTTOM_CENTER, views::BubbleBorder::LEFT_CENTER,
+ views::BubbleBorder::RIGHT_CENTER, views::BubbleBorder::TOP_CENTER);
view_ = new ShelfTooltipBubble(anchor, arrow, this);
widget_ = view_->GetWidget();
diff --git a/ash/shelf/shelf_view.cc b/ash/shelf/shelf_view.cc
index 438ac43..876b90a 100644
--- a/ash/shelf/shelf_view.cc
+++ b/ash/shelf/shelf_view.cc
@@ -10,18 +10,17 @@
#include "ash/ash_switches.h"
#include "ash/drag_drop/drag_image_view.h"
#include "ash/metrics/user_metrics_recorder.h"
-#include "ash/root_window_controller.h"
#include "ash/scoped_target_root_window.h"
#include "ash/shelf/app_list_button.h"
#include "ash/shelf/overflow_bubble.h"
#include "ash/shelf/overflow_bubble_view.h"
#include "ash/shelf/overflow_button.h"
+#include "ash/shelf/shelf.h"
#include "ash/shelf/shelf_button.h"
#include "ash/shelf/shelf_constants.h"
#include "ash/shelf/shelf_delegate.h"
#include "ash/shelf/shelf_icon_observer.h"
#include "ash/shelf/shelf_item_delegate_manager.h"
-#include "ash/shelf/shelf_layout_manager.h"
#include "ash/shelf/shelf_menu_model.h"
#include "ash/shelf/shelf_model.h"
#include "ash/shelf/shelf_tooltip_manager.h"
@@ -363,11 +362,10 @@ class ShelfView::StartFadeAnimationDelegate : public gfx::AnimationDelegate {
DISALLOW_COPY_AND_ASSIGN(StartFadeAnimationDelegate);
};
-ShelfView::ShelfView(ShelfModel* model,
- ShelfDelegate* delegate,
- ShelfLayoutManager* manager)
+ShelfView::ShelfView(ShelfModel* model, ShelfDelegate* delegate, Shelf* shelf)
: model_(model),
delegate_(delegate),
+ shelf_(shelf),
view_model_(new views::ViewModel),
first_visible_index_(0),
last_visible_index_(-1),
@@ -388,7 +386,6 @@ ShelfView::ShelfView(ShelfModel* model,
dragged_off_shelf_(false),
snap_back_from_rip_off_view_(NULL),
item_manager_(Shell::GetInstance()->shelf_item_delegate_manager()),
- layout_manager_(manager),
overflow_mode_(false),
main_shelf_(NULL),
dragged_off_from_overflow_to_shelf_(false),
@@ -399,7 +396,7 @@ ShelfView::ShelfView(ShelfModel* model,
bounds_animator_->AddObserver(this);
set_context_menu_controller(this);
focus_search_.reset(new ShelfFocusSearch(view_model_.get()));
- tooltip_.reset(new ShelfTooltipManager(manager, this));
+ tooltip_.reset(new ShelfTooltipManager(shelf->shelf_layout_manager(), this));
}
ShelfView::~ShelfView() {
@@ -421,7 +418,7 @@ void ShelfView::Init() {
view_model_->Add(child, static_cast<int>(i - items.begin()));
AddChildView(child);
}
- overflow_button_ = new OverflowButton(this, shelf_layout_manager());
+ overflow_button_ = new OverflowButton(this, shelf_);
overflow_button_->set_context_menu_controller(this);
ConfigureChildView(overflow_button_);
AddChildView(overflow_button_);
@@ -486,19 +483,18 @@ void ShelfView::UpdatePanelIconPosition(ShelfID id,
midpoint.y());
int target_index = current_index;
while (target_index > first_panel_index &&
- layout_manager_->PrimaryAxisValue(
- view_model_->ideal_bounds(target_index).x(),
- view_model_->ideal_bounds(target_index).y()) >
- layout_manager_->PrimaryAxisValue(midpoint_in_view.x(),
- midpoint_in_view.y())) {
+ shelf_->PrimaryAxisValue(view_model_->ideal_bounds(target_index).x(),
+ view_model_->ideal_bounds(target_index).y()) >
+ shelf_->PrimaryAxisValue(midpoint_in_view.x(),
+ midpoint_in_view.y())) {
--target_index;
}
while (target_index < view_model_->view_size() - 1 &&
- layout_manager_->PrimaryAxisValue(
+ shelf_->PrimaryAxisValue(
view_model_->ideal_bounds(target_index).right(),
view_model_->ideal_bounds(target_index).bottom()) <
- layout_manager_->PrimaryAxisValue(midpoint_in_view.x(),
- midpoint_in_view.y())) {
+ shelf_->PrimaryAxisValue(midpoint_in_view.x(),
+ midpoint_in_view.y())) {
++target_index;
}
if (current_index != target_index)
@@ -710,7 +706,7 @@ void ShelfView::UpdateAllButtonsVisibilityInOverflowMode() {
}
void ShelfView::CalculateIdealBounds(IdealBounds* bounds) const {
- int available_size = layout_manager_->PrimaryAxisValue(width(), height());
+ int available_size = shelf_->PrimaryAxisValue(width(), height());
DCHECK(model_->item_count() == view_model_->view_size());
if (!available_size)
return;
@@ -723,8 +719,8 @@ void ShelfView::CalculateIdealBounds(IdealBounds* bounds) const {
int button_size = kShelfButtonSize;
int button_spacing = kShelfButtonSpacing;
- int w = layout_manager_->PrimaryAxisValue(button_size, width());
- int h = layout_manager_->PrimaryAxisValue(height(), button_size);
+ int w = shelf_->PrimaryAxisValue(button_size, width());
+ int h = shelf_->PrimaryAxisValue(height(), button_size);
for (int i = 0; i < view_model_->view_size(); ++i) {
if (i < first_visible_index_) {
view_model_->set_ideal_bounds(i, gfx::Rect(x, y, 0, 0));
@@ -732,8 +728,8 @@ void ShelfView::CalculateIdealBounds(IdealBounds* bounds) const {
}
view_model_->set_ideal_bounds(i, gfx::Rect(x, y, w, h));
- x = layout_manager_->PrimaryAxisValue(x + w + button_spacing, x);
- y = layout_manager_->PrimaryAxisValue(y, y + h + button_spacing);
+ x = shelf_->PrimaryAxisValue(x + w + button_spacing, x);
+ y = shelf_->PrimaryAxisValue(y, y + h + button_spacing);
}
if (is_overflow_mode()) {
@@ -743,21 +739,23 @@ void ShelfView::CalculateIdealBounds(IdealBounds* bounds) const {
// Right aligned icons.
int end_position = available_size - button_spacing;
- x = layout_manager_->PrimaryAxisValue(end_position, 0);
- y = layout_manager_->PrimaryAxisValue(0, end_position);
+ x = shelf_->PrimaryAxisValue(end_position, 0);
+ y = shelf_->PrimaryAxisValue(0, end_position);
for (int i = view_model_->view_size() - 1;
i >= first_panel_index; --i) {
- x = layout_manager_->PrimaryAxisValue(x - w - button_spacing, x);
- y = layout_manager_->PrimaryAxisValue(y, y - h - button_spacing);
+ x = shelf_->PrimaryAxisValue(x - w - button_spacing, x);
+ y = shelf_->PrimaryAxisValue(y, y - h - button_spacing);
view_model_->set_ideal_bounds(i, gfx::Rect(x, y, w, h));
- end_position = layout_manager_->PrimaryAxisValue(x, y);
+ end_position = shelf_->PrimaryAxisValue(x, y);
}
// Icons on the left / top are guaranteed up to kLeftIconProportion of
// the available space.
- int last_icon_position = layout_manager_->PrimaryAxisValue(
- view_model_->ideal_bounds(last_button_index).right(),
- view_model_->ideal_bounds(last_button_index).bottom()) + button_size;
+ int last_icon_position =
+ shelf_->PrimaryAxisValue(
+ view_model_->ideal_bounds(last_button_index).right(),
+ view_model_->ideal_bounds(last_button_index).bottom()) +
+ button_size;
int reserved_icon_space = available_size * kReservedNonPanelIconProportion;
if (last_icon_position < reserved_icon_space)
end_position = last_icon_position;
@@ -765,8 +763,8 @@ void ShelfView::CalculateIdealBounds(IdealBounds* bounds) const {
end_position = std::max(end_position, reserved_icon_space);
bounds->overflow_bounds.set_size(
- gfx::Size(layout_manager_->PrimaryAxisValue(w, width()),
- layout_manager_->PrimaryAxisValue(height(), h)));
+ gfx::Size(shelf_->PrimaryAxisValue(w, width()),
+ shelf_->PrimaryAxisValue(height(), h)));
last_visible_index_ = DetermineLastVisibleIndex(
end_position - button_size);
@@ -814,10 +812,10 @@ void ShelfView::CalculateIdealBounds(IdealBounds* bounds) const {
x = 0;
y = 0;
} else {
- x = layout_manager_->PrimaryAxisValue(
+ x = shelf_->PrimaryAxisValue(
view_model_->ideal_bounds(last_visible_index_).right(),
view_model_->ideal_bounds(last_visible_index_).x());
- y = layout_manager_->PrimaryAxisValue(
+ y = shelf_->PrimaryAxisValue(
view_model_->ideal_bounds(last_visible_index_).y(),
view_model_->ideal_bounds(last_visible_index_).bottom());
}
@@ -827,8 +825,8 @@ void ShelfView::CalculateIdealBounds(IdealBounds* bounds) const {
// Add more space between last visible item and overflow button.
// Without this, two buttons look too close compared with other items.
- x = layout_manager_->PrimaryAxisValue(x + button_spacing, x);
- y = layout_manager_->PrimaryAxisValue(y, y + button_spacing);
+ x = shelf_->PrimaryAxisValue(x + button_spacing, x);
+ y = shelf_->PrimaryAxisValue(y, y + button_spacing);
bounds->overflow_bounds.set_x(x);
bounds->overflow_bounds.set_y(y);
@@ -843,9 +841,9 @@ void ShelfView::CalculateIdealBounds(IdealBounds* bounds) const {
int ShelfView::DetermineLastVisibleIndex(int max_value) const {
int index = model_->FirstPanelIndex() - 1;
while (index >= 0 &&
- layout_manager_->PrimaryAxisValue(
- view_model_->ideal_bounds(index).right(),
- view_model_->ideal_bounds(index).bottom()) > max_value) {
+ shelf_->PrimaryAxisValue(view_model_->ideal_bounds(index).right(),
+ view_model_->ideal_bounds(index).bottom()) >
+ max_value) {
index--;
}
return index;
@@ -854,9 +852,9 @@ int ShelfView::DetermineLastVisibleIndex(int max_value) const {
int ShelfView::DetermineFirstVisiblePanelIndex(int min_value) const {
int index = model_->FirstPanelIndex();
while (index < view_model_->view_size() &&
- layout_manager_->PrimaryAxisValue(
- view_model_->ideal_bounds(index).right(),
- view_model_->ideal_bounds(index).bottom()) < min_value) {
+ shelf_->PrimaryAxisValue(view_model_->ideal_bounds(index).right(),
+ view_model_->ideal_bounds(index).bottom()) <
+ min_value) {
++index;
}
return index;
@@ -893,7 +891,7 @@ views::View* ShelfView::CreateViewForItem(const ShelfItem& item) {
case TYPE_PLATFORM_APP:
case TYPE_DIALOG:
case TYPE_APP_PANEL: {
- ShelfButton* button = ShelfButton::Create(this, this, layout_manager_);
+ ShelfButton* button = ShelfButton::Create(this, this, shelf_);
button->SetImage(item.image);
ReflectItemStatus(item, button);
view = button;
@@ -901,7 +899,7 @@ views::View* ShelfView::CreateViewForItem(const ShelfItem& item) {
}
case TYPE_APP_LIST: {
- view = new AppListButton(this, this, layout_manager_->shelf_widget());
+ view = new AppListButton(this, this, shelf_->shelf_widget());
break;
}
@@ -985,7 +983,7 @@ void ShelfView::ContinueDrag(const ui::LocatedEvent& event) {
last_drag_index > last_visible_index_)
last_drag_index = last_visible_index_;
int x = 0, y = 0;
- if (layout_manager_->IsHorizontalAlignment()) {
+ if (shelf_->IsHorizontalAlignment()) {
x = std::max(view_model_->ideal_bounds(indices.first).x(),
drag_point.x() - drag_origin_.x());
x = std::min(view_model_->ideal_bounds(last_drag_index).right() -
@@ -1005,13 +1003,11 @@ void ShelfView::ContinueDrag(const ui::LocatedEvent& event) {
drag_view_->SetY(y);
}
- int target_index =
- views::ViewModelUtils::DetermineMoveIndex(
- *view_model_, drag_view_,
- layout_manager_->IsHorizontalAlignment() ?
- views::ViewModelUtils::HORIZONTAL :
- views::ViewModelUtils::VERTICAL,
- x, y);
+ int target_index = views::ViewModelUtils::DetermineMoveIndex(
+ *view_model_, drag_view_,
+ shelf_->IsHorizontalAlignment() ? views::ViewModelUtils::HORIZONTAL
+ : views::ViewModelUtils::VERTICAL,
+ x, y);
target_index =
std::min(indices.second, std::max(target_index, indices.first));
@@ -1258,8 +1254,7 @@ void ShelfView::ToggleOverflowBubble() {
if (!overflow_bubble_)
overflow_bubble_.reset(new OverflowBubble());
- ShelfView* overflow_view =
- new ShelfView(model_, delegate_, layout_manager_);
+ ShelfView* overflow_view = new ShelfView(model_, delegate_, shelf_);
overflow_view->overflow_mode_ = true;
overflow_view->Init();
overflow_view->set_owner_overflow_bubble(overflow_bubble_.get());
@@ -1342,7 +1337,7 @@ gfx::Rect ShelfView::GetBoundsForDragInsertInScreen() {
last_button_bounds = overflow_button_->bounds();
}
- if (layout_manager_->IsHorizontalAlignment()) {
+ if (shelf_->IsHorizontalAlignment()) {
preferred_size = gfx::Size(last_button_bounds.right() + leading_inset_,
kShelfSize);
} else {
@@ -1416,9 +1411,8 @@ gfx::Size ShelfView::GetPreferredSize() const {
view_model_->ideal_bounds(last_button_index) :
gfx::Rect(gfx::Size(kShelfSize, kShelfSize));
- if (layout_manager_->IsHorizontalAlignment()) {
+ if (shelf_->IsHorizontalAlignment())
return gfx::Size(last_button_bounds.right() + leading_inset_, kShelfSize);
- }
return gfx::Size(kShelfSize,
last_button_bounds.bottom() + leading_inset_);
@@ -1619,12 +1613,11 @@ void ShelfView::PointerPressedOnButton(views::View* view,
drag_view_ = static_cast<ShelfButton*>(view);
drag_origin_ = gfx::Point(event.x(), event.y());
UMA_HISTOGRAM_ENUMERATION("Ash.ShelfAlignmentUsage",
- layout_manager_->SelectValueForShelfAlignment(
- SHELF_ALIGNMENT_UMA_ENUM_VALUE_BOTTOM,
- SHELF_ALIGNMENT_UMA_ENUM_VALUE_LEFT,
- SHELF_ALIGNMENT_UMA_ENUM_VALUE_RIGHT,
- -1),
- SHELF_ALIGNMENT_UMA_ENUM_VALUE_COUNT);
+ shelf_->SelectValueForShelfAlignment(
+ SHELF_ALIGNMENT_UMA_ENUM_VALUE_BOTTOM,
+ SHELF_ALIGNMENT_UMA_ENUM_VALUE_LEFT,
+ SHELF_ALIGNMENT_UMA_ENUM_VALUE_RIGHT, -1),
+ SHELF_ALIGNMENT_UMA_ENUM_VALUE_COUNT);
}
void ShelfView::PointerDraggedOnButton(views::View* view,
@@ -1838,11 +1831,9 @@ void ShelfView::ShowMenu(ui::MenuModel* menu_model,
views::MenuAnchorPosition menu_alignment = views::MENU_ANCHOR_TOPLEFT;
gfx::Rect anchor_point = gfx::Rect(click_point, gfx::Size());
- ShelfWidget* shelf = RootWindowController::ForShelf(
- GetWidget()->GetNativeView())->shelf();
if (!context_menu) {
// Application lists use a bubble.
- ShelfAlignment align = shelf->GetAlignment();
+ ShelfAlignment align = shelf_->alignment();
anchor_point = source->GetBoundsInScreen();
// It is possible to invoke the menu while it is sliding into view. To cover
@@ -1878,7 +1869,8 @@ void ShelfView::ShowMenu(ui::MenuModel* menu_model,
bool got_deleted = false;
got_deleted_ = &got_deleted;
- shelf->ForceUndimming(true);
+ ShelfWidget* shelf_widget = shelf_->shelf_widget();
+ shelf_widget->ForceUndimming(true);
// NOTE: if you convert to HAS_MNEMONICS be sure and update menu building
// code.
if (launcher_menu_runner_->RunMenuAt(source->GetWidget(),
@@ -1889,12 +1881,12 @@ void ShelfView::ShowMenu(ui::MenuModel* menu_model,
views::MenuRunner::MENU_DELETED) {
if (!got_deleted) {
got_deleted_ = NULL;
- shelf->ForceUndimming(false);
+ shelf_widget->ForceUndimming(false);
}
return;
}
got_deleted_ = NULL;
- shelf->ForceUndimming(false);
+ shelf_widget->ForceUndimming(false);
// If it is a context menu and we are showing overflow bubble
// we want to hide overflow bubble.
@@ -1967,25 +1959,10 @@ bool ShelfView::ShouldShowTooltipForView(const views::View* view) const {
}
int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const {
- ShelfWidget* shelf = RootWindowController::ForShelf(
- GetWidget()->GetNativeView())->shelf();
- ShelfAlignment align = shelf->GetAlignment();
const gfx::Rect bounds = GetBoundsInScreen();
- int distance = 0;
- switch (align) {
- case SHELF_ALIGNMENT_BOTTOM:
- distance = bounds.y() - coordinate.y();
- break;
- case SHELF_ALIGNMENT_LEFT:
- distance = coordinate.x() - bounds.right();
- break;
- case SHELF_ALIGNMENT_RIGHT:
- distance = bounds.x() - coordinate.x();
- break;
- case SHELF_ALIGNMENT_TOP:
- distance = coordinate.y() - bounds.bottom();
- break;
- }
+ int distance = shelf_->SelectValueForShelfAlignment(
+ bounds.y() - coordinate.y(), coordinate.x() - bounds.right(),
+ bounds.x() - coordinate.x(), coordinate.y() - bounds.bottom());
return distance > 0 ? distance : 0;
}
diff --git a/ash/shelf/shelf_view.h b/ash/shelf/shelf_view.h
index c9c32b1..4b37d39 100644
--- a/ash/shelf/shelf_view.h
+++ b/ash/shelf/shelf_view.h
@@ -34,6 +34,7 @@ class MenuRunner;
}
namespace ash {
+class Shelf;
class ShelfDelegate;
class ShelfIconObserver;
class ShelfItemDelegateManager;
@@ -43,7 +44,6 @@ class DragImageView;
class OverflowBubble;
class OverflowButton;
class ShelfButton;
-class ShelfLayoutManager;
class ShelfTooltipManager;
namespace test {
@@ -64,16 +64,13 @@ class ASH_EXPORT ShelfView : public views::View,
public views::BoundsAnimatorObserver,
public app_list::ApplicationDragAndDropHost {
public:
- ShelfView(ShelfModel* model,
- ShelfDelegate* delegate,
- ShelfLayoutManager* manager);
+ ShelfView(ShelfModel* model, ShelfDelegate* delegate, Shelf* shelf);
~ShelfView() override;
ShelfTooltipManager* tooltip_manager() { return tooltip_.get(); }
- ShelfLayoutManager* shelf_layout_manager() { return layout_manager_; }
-
- ShelfModel* model() { return model_; }
+ Shelf* shelf() const { return shelf_; }
+ ShelfModel* model() const { return model_; }
void Init();
@@ -163,9 +160,7 @@ class ASH_EXPORT ShelfView : public views::View,
// button.
bool is_overflow_mode() const { return overflow_mode_; }
- bool dragging() const {
- return drag_pointer_ != NONE;
- }
+ bool dragging() const { return drag_pointer_ != NONE; }
// Sets the bounds of each view to its ideal bounds.
void LayoutToIdealBounds();
@@ -329,6 +324,9 @@ class ASH_EXPORT ShelfView : public views::View,
// Delegate; owned by Launcher.
ShelfDelegate* delegate_;
+ // The shelf; owned by ShelfWidget.
+ Shelf* shelf_;
+
// Used to manage the set of active launcher buttons. There is a view per
// item in |model_|.
scoped_ptr<views::ViewModel> view_model_;
@@ -428,9 +426,6 @@ class ASH_EXPORT ShelfView : public views::View,
// Holds ShelfItemDelegateManager.
ShelfItemDelegateManager* item_manager_;
- // Holds ShelfLayoutManager.
- ShelfLayoutManager* layout_manager_;
-
// True when this ShelfView is used for Overflow Bubble.
bool overflow_mode_;
diff --git a/ash/shelf/shelf_view_unittest.cc b/ash/shelf/shelf_view_unittest.cc
index c347c60..d5e108d 100644
--- a/ash/shelf/shelf_view_unittest.cc
+++ b/ash/shelf/shelf_view_unittest.cc
@@ -981,7 +981,7 @@ TEST_F(ShelfViewTest, AssertNoButtonsOverlap) {
};
for (ShelfAlignment alignment : kAlignments) {
- EXPECT_TRUE(shelf_view_->shelf_layout_manager()->SetAlignment(alignment));
+ shelf_view_->shelf()->SetAlignment(alignment);
// For every 2 successive visible icons, expect that their bounds don't
// intersect.
for (int i = 1; i < test_api_->GetButtonCount() - 1; ++i) {
@@ -1340,11 +1340,11 @@ TEST_F(ShelfViewTest, ShelfItemStatusPlatformApp) {
// Confirm that shelf item bounds are correctly updated on shelf changes.
TEST_F(ShelfViewTest, ShelfItemBoundsCheck) {
VerifyShelfItemBoundsAreValid();
- shelf_view_->shelf_layout_manager()->SetAutoHideBehavior(
+ shelf_view_->shelf()->shelf_layout_manager()->SetAutoHideBehavior(
SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
test_api_->RunMessageLoopUntilAnimationsDone();
VerifyShelfItemBoundsAreValid();
- shelf_view_->shelf_layout_manager()->SetAutoHideBehavior(
+ shelf_view_->shelf()->shelf_layout_manager()->SetAutoHideBehavior(
SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
test_api_->RunMessageLoopUntilAnimationsDone();
VerifyShelfItemBoundsAreValid();
@@ -1395,7 +1395,7 @@ TEST_F(ShelfViewTest, ShelfTooltipTest) {
EXPECT_EQ(platform_button, GetTooltipAnchorView());
}
-// Verify a fix for crash caused by a tooltip update for a deletedshelf
+// Verify a fix for crash caused by a tooltip update for a deleted shelf
// button, see crbug.com/288838.
TEST_F(ShelfViewTest, RemovingItemClosesTooltip) {
ShelfButtonHost* button_host = shelf_view_;
diff --git a/ash/shell.cc b/ash/shell.cc
index 5cd7aa9..d8987ee 100644
--- a/ash/shell.cc
+++ b/ash/shell.cc
@@ -510,26 +510,28 @@ void Shell::UpdateShelfVisibility() {
void Shell::SetShelfAutoHideBehavior(ShelfAutoHideBehavior behavior,
aura::Window* root_window) {
- ash::ShelfLayoutManager::ForShelf(root_window)->SetAutoHideBehavior(behavior);
+ ShelfWidget* shelf_widget = GetRootWindowController(root_window)->shelf();
+ shelf_widget->shelf_layout_manager()->SetAutoHideBehavior(behavior);
}
ShelfAutoHideBehavior Shell::GetShelfAutoHideBehavior(
aura::Window* root_window) const {
- return ash::ShelfLayoutManager::ForShelf(root_window)->auto_hide_behavior();
+ ShelfWidget* shelf_widget = GetRootWindowController(root_window)->shelf();
+ return shelf_widget->shelf_layout_manager()->auto_hide_behavior();
}
void Shell::SetShelfAlignment(ShelfAlignment alignment,
aura::Window* root_window) {
- if (ash::ShelfLayoutManager::ForShelf(root_window)->SetAlignment(alignment)) {
+ ShelfWidget* shelf_widget = GetRootWindowController(root_window)->shelf();
+ if (shelf_widget->shelf_layout_manager()->SetAlignment(alignment)) {
FOR_EACH_OBSERVER(
ShellObserver, observers_, OnShelfAlignmentChanged(root_window));
}
}
ShelfAlignment Shell::GetShelfAlignment(const aura::Window* root_window) {
- return GetRootWindowController(root_window)
- ->GetShelfLayoutManager()
- ->GetAlignment();
+ ShelfWidget* shelf_widget = GetRootWindowController(root_window)->shelf();
+ return shelf_widget->shelf_layout_manager()->GetAlignment();
}
void Shell::NotifyFullscreenStateChange(bool is_fullscreen,
@@ -614,8 +616,8 @@ void Shell::SetTouchHudProjectionEnabled(bool enabled) {
}
#if defined(OS_CHROMEOS)
-ash::FirstRunHelper* Shell::CreateFirstRunHelper() {
- return new ash::FirstRunHelperImpl;
+FirstRunHelper* Shell::CreateFirstRunHelper() {
+ return new FirstRunHelperImpl;
}
void Shell::SetCursorCompositingEnabled(bool enabled) {
@@ -1038,7 +1040,7 @@ void Shell::Init(const ShellInitParams& init_params) {
new ::wm::ShadowController(activation_client_));
// Create system_tray_notifier_ before the delegate.
- system_tray_notifier_.reset(new ash::SystemTrayNotifier());
+ system_tray_notifier_.reset(new SystemTrayNotifier());
// Initialize system_tray_delegate_ before initializing StatusAreaWidget.
system_tray_delegate_.reset(delegate()->CreateSystemTrayDelegate());
@@ -1090,8 +1092,8 @@ void Shell::Init(const ShellInitParams& init_params) {
#if defined(OS_CHROMEOS)
// Set accelerator controller delegates.
accelerator_controller_->SetBrightnessControlDelegate(
- scoped_ptr<ash::BrightnessControlDelegate>(
- new ash::system::BrightnessControllerChromeos));
+ scoped_ptr<BrightnessControlDelegate>(
+ new system::BrightnessControllerChromeos));
power_event_observer_.reset(new PowerEventObserver());
user_activity_notifier_.reset(
diff --git a/ash/system/web_notification/ash_popup_alignment_delegate_unittest.cc b/ash/system/web_notification/ash_popup_alignment_delegate_unittest.cc
index 6679987..c432d28 100644
--- a/ash/system/web_notification/ash_popup_alignment_delegate_unittest.cc
+++ b/ash/system/web_notification/ash_popup_alignment_delegate_unittest.cc
@@ -10,6 +10,7 @@
#include "ash/display/display_manager.h"
#include "ash/display/window_tree_host_manager.h"
#include "ash/screen_util.h"
+#include "ash/shelf/shelf.h"
#include "ash/shelf/shelf_layout_manager.h"
#include "ash/shelf/shelf_types.h"
#include "ash/shell.h"
@@ -34,7 +35,7 @@ class AshPopupAlignmentDelegateTest : public test::AshTestBase {
keyboard::switches::kEnableVirtualKeyboard);
test::AshTestBase::SetUp();
SetAlignmentDelegate(make_scoped_ptr(new AshPopupAlignmentDelegate(
- ShelfLayoutManager::ForShelf(Shell::GetPrimaryRootWindow()))));
+ Shelf::ForPrimaryDisplay()->shelf_layout_manager())));
}
void TearDown() override {
@@ -43,7 +44,8 @@ class AshPopupAlignmentDelegateTest : public test::AshTestBase {
}
void SetKeyboardBounds(const gfx::Rect& new_bounds) {
- ShelfLayoutManager::ForShelf(Shell::GetPrimaryRootWindow())
+ Shelf::ForPrimaryDisplay()
+ ->shelf_layout_manager()
->OnKeyboardBoundsChanging(new_bounds);
}
@@ -179,8 +181,7 @@ TEST_F(AshPopupAlignmentDelegateTest, AutoHide) {
Shell::GetInstance()->SetShelfAutoHideBehavior(
SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS,
Shell::GetPrimaryRootWindow());
- ShelfLayoutManager::ForShelf(Shell::GetPrimaryRootWindow())->
- UpdateAutoHideStateNow();
+ Shelf::ForPrimaryDisplay()->shelf_layout_manager()->UpdateAutoHideStateNow();
EXPECT_EQ(origin_x, alignment_delegate()->GetToastOriginX(toast_size));
EXPECT_LT(baseline, alignment_delegate()->GetBaseLine());
}
@@ -281,7 +282,7 @@ TEST_F(AshPopupAlignmentDelegateTest, Extended) {
return;
UpdateDisplay("600x600,800x800");
SetAlignmentDelegate(make_scoped_ptr(new AshPopupAlignmentDelegate(
- ShelfLayoutManager::ForShelf(Shell::GetPrimaryRootWindow()))));
+ Shelf::ForPrimaryDisplay()->shelf_layout_manager())));
gfx::Display second_display = ScreenUtil::GetSecondaryDisplay();
aura::Window* second_root =
@@ -289,7 +290,7 @@ TEST_F(AshPopupAlignmentDelegateTest, Extended) {
->window_tree_host_manager()
->GetRootWindowForDisplayId(second_display.id());
AshPopupAlignmentDelegate for_2nd_display(
- ShelfLayoutManager::ForShelf(second_root));
+ Shelf::ForWindow(second_root)->shelf_layout_manager());
UpdateWorkArea(&for_2nd_display, second_display);
// Make sure that the toast position on the secondary display is
// positioned correctly.
@@ -309,7 +310,7 @@ TEST_F(AshPopupAlignmentDelegateTest, Unified) {
UpdateDisplay("600x600,800x800");
SetAlignmentDelegate(make_scoped_ptr(new AshPopupAlignmentDelegate(
- ShelfLayoutManager::ForShelf(Shell::GetPrimaryRootWindow()))));
+ Shelf::ForPrimaryDisplay()->shelf_layout_manager())));
EXPECT_GT(600,
alignment_delegate()->GetToastOriginX(gfx::Rect(0, 0, 10, 10)));
diff --git a/ash/wm/app_list_controller.cc b/ash/wm/app_list_controller.cc
index 67a50c3..d6465d2 100644
--- a/ash/wm/app_list_controller.cc
+++ b/ash/wm/app_list_controller.cc
@@ -55,12 +55,9 @@ ui::Layer* GetLayer(views::Widget* widget) {
// Gets arrow location based on shelf alignment.
views::BubbleBorder::Arrow GetBubbleArrow(aura::Window* window) {
DCHECK(Shell::HasInstance());
- return ShelfLayoutManager::ForShelf(window)->
- SelectValueForShelfAlignment(
- views::BubbleBorder::BOTTOM_CENTER,
- views::BubbleBorder::LEFT_CENTER,
- views::BubbleBorder::RIGHT_CENTER,
- views::BubbleBorder::TOP_CENTER);
+ return Shelf::ForWindow(window)->SelectValueForShelfAlignment(
+ views::BubbleBorder::BOTTOM_CENTER, views::BubbleBorder::LEFT_CENTER,
+ views::BubbleBorder::RIGHT_CENTER, views::BubbleBorder::TOP_CENTER);
}
// Offset given |rect| towards shelf.
diff --git a/ash/wm/dock/docked_window_layout_manager.cc b/ash/wm/dock/docked_window_layout_manager.cc
index f010910..517a4d2 100644
--- a/ash/wm/dock/docked_window_layout_manager.cc
+++ b/ash/wm/dock/docked_window_layout_manager.cc
@@ -425,10 +425,8 @@ DockedWindowLayoutManager::~DockedWindowLayoutManager() {
}
void DockedWindowLayoutManager::Shutdown() {
- if (shelf_ && shelf_->shelf_widget()) {
- ShelfLayoutManager* shelf_layout_manager =
- shelf_->shelf_widget()->shelf_layout_manager();
- shelf_layout_manager->RemoveObserver(this);
+ if (shelf_ && shelf_->shelf_layout_manager()) {
+ shelf_->shelf_layout_manager()->RemoveObserver(this);
shelf_observer_.reset();
}
shelf_ = NULL;
@@ -539,10 +537,8 @@ void DockedWindowLayoutManager::FinishDragging(DockedAction action,
void DockedWindowLayoutManager::SetShelf(Shelf* shelf) {
DCHECK(!shelf_);
shelf_ = shelf;
- if (shelf_->shelf_widget()) {
- ShelfLayoutManager* shelf_layout_manager =
- shelf_->shelf_widget()->shelf_layout_manager();
- shelf_layout_manager->AddObserver(this);
+ if (shelf_->shelf_layout_manager()) {
+ shelf_->shelf_layout_manager()->AddObserver(this);
shelf_observer_.reset(new ShelfWindowObserver(this));
}
}
@@ -755,8 +751,7 @@ void DockedWindowLayoutManager::SetChildBounds(
if (IsPopupOrTransient(child))
return;
// Whenever one of our windows is moved or resized enforce layout.
- ShelfLayoutManager* shelf_layout =
- shelf_->shelf_widget()->shelf_layout_manager();
+ ShelfLayoutManager* shelf_layout = shelf_->shelf_layout_manager();
if (shelf_layout)
shelf_layout->UpdateVisibilityState();
}
@@ -807,15 +802,12 @@ void DockedWindowLayoutManager::OnShelfAlignmentChanged(
if (dock_container_->GetRootWindow() != root_window)
return;
- if (!shelf_ || !shelf_->shelf_widget())
- return;
-
- if (alignment_ == DOCKED_ALIGNMENT_NONE)
+ if (!shelf_ || alignment_ == DOCKED_ALIGNMENT_NONE)
return;
// Do not allow shelf and dock on the same side. Switch side that
// the dock is attached to and move all dock windows to that new side.
- ShelfAlignment shelf_alignment = shelf_->shelf_widget()->GetAlignment();
+ ShelfAlignment shelf_alignment = shelf_->alignment();
if (alignment_ == DOCKED_ALIGNMENT_LEFT &&
shelf_alignment == SHELF_ALIGNMENT_LEFT) {
alignment_ = DOCKED_ALIGNMENT_RIGHT;
diff --git a/ash/wm/panels/panel_layout_manager.cc b/ash/wm/panels/panel_layout_manager.cc
index fdb6e07..e1bd6a7 100644
--- a/ash/wm/panels/panel_layout_manager.cc
+++ b/ash/wm/panels/panel_layout_manager.cc
@@ -311,8 +311,8 @@ void PanelLayoutManager::SetShelf(Shelf* shelf) {
DCHECK(!shelf_layout_manager_);
shelf_ = shelf;
shelf_->AddIconObserver(this);
- if (shelf_->shelf_widget()) {
- shelf_layout_manager_ = shelf_->shelf_widget()->shelf_layout_manager();
+ if (shelf_->shelf_layout_manager()) {
+ shelf_layout_manager_ = shelf_->shelf_layout_manager();
WillChangeVisibilityState(shelf_layout_manager_->visibility_state());
shelf_layout_manager_->AddObserver(this);
}
@@ -584,8 +584,7 @@ void PanelLayoutManager::MinimizePanel(aura::Window* panel) {
panel_slide_settings.SetTransitionDuration(
base::TimeDelta::FromMilliseconds(kPanelSlideDurationMilliseconds));
gfx::Rect bounds(panel->bounds());
- bounds.Offset(GetSlideInAnimationOffset(
- shelf_->shelf_widget()->GetAlignment()));
+ bounds.Offset(GetSlideInAnimationOffset(shelf_->alignment()));
SetChildBoundsDirect(panel, bounds);
panel->Hide();
layer->SetOpacity(0);
@@ -618,9 +617,8 @@ void PanelLayoutManager::Relayout() {
return;
base::AutoReset<bool> auto_reset_in_layout(&in_layout_, true);
- ShelfAlignment alignment = shelf_->shelf_widget()->GetAlignment();
- bool horizontal = alignment == SHELF_ALIGNMENT_TOP ||
- alignment == SHELF_ALIGNMENT_BOTTOM;
+ const ShelfAlignment alignment = shelf_->alignment();
+ const bool horizontal = shelf_->IsHorizontalAlignment();
gfx::Rect shelf_bounds = ash::ScreenUtil::ConvertRectFromScreen(
panel_container_, shelf_->shelf_widget()->GetWindowBoundsInScreen());
int panel_start_bounds = kPanelIdealSpacing;
@@ -778,10 +776,6 @@ void PanelLayoutManager::UpdateStacking(aura::Window* active_panel) {
active_panel = last_active_panel_;
}
- ShelfAlignment alignment = shelf_->alignment();
- bool horizontal = alignment == SHELF_ALIGNMENT_TOP ||
- alignment == SHELF_ALIGNMENT_BOTTOM;
-
// We want to to stack the panels like a deck of cards:
// ,--,--,--,-------.--.--.
// | | | | | | |
@@ -792,6 +786,7 @@ void PanelLayoutManager::UpdateStacking(aura::Window* active_panel) {
// the titlebar--even though it doesn't update the shelf icon positions, we
// still want the visual effect.
std::map<int, aura::Window*> window_ordering;
+ const bool horizontal = shelf_->IsHorizontalAlignment();
for (PanelList::const_iterator it = panel_windows_.begin();
it != panel_windows_.end(); ++it) {
gfx::Rect bounds = it->window->bounds();
@@ -826,10 +821,7 @@ void PanelLayoutManager::UpdateStacking(aura::Window* active_panel) {
}
void PanelLayoutManager::UpdateCallouts() {
- ShelfAlignment alignment = shelf_->alignment();
- bool horizontal = alignment == SHELF_ALIGNMENT_TOP ||
- alignment == SHELF_ALIGNMENT_BOTTOM;
-
+ const bool horizontal = shelf_->IsHorizontalAlignment();
for (PanelList::iterator iter = panel_windows_.begin();
iter != panel_windows_.end(); ++iter) {
aura::Window* panel = iter->window;
@@ -865,7 +857,7 @@ void PanelLayoutManager::UpdateCallouts() {
current_bounds.y() - callout_bounds.y(),
callout_bounds.bottom() - current_bounds.bottom());
}
- switch (alignment) {
+ switch (shelf_->alignment()) {
case SHELF_ALIGNMENT_BOTTOM:
callout_bounds.set_y(bounds.bottom());
break;
diff --git a/ash/wm/panels/panel_layout_manager_unittest.cc b/ash/wm/panels/panel_layout_manager_unittest.cc
index 9c270b5..a8f23cd 100644
--- a/ash/wm/panels/panel_layout_manager_unittest.cc
+++ b/ash/wm/panels/panel_layout_manager_unittest.cc
@@ -5,7 +5,6 @@
#include "ash/wm/panels/panel_layout_manager.h"
#include "ash/ash_switches.h"
-#include "ash/root_window_controller.h"
#include "ash/screen_util.h"
#include "ash/shelf/shelf.h"
#include "ash/shelf/shelf_button.h"
@@ -119,7 +118,7 @@ class PanelLayoutManagerTest : public test::AshTestBase {
// Waits until all shelf view animations are done.
shelf_view_test()->RunMessageLoopUntilAnimationsDone();
- Shelf* shelf = RootWindowController::ForShelf(panel)->shelf()->shelf();
+ Shelf* shelf = Shelf::ForWindow(panel);
gfx::Rect icon_bounds = shelf->GetScreenBoundsOfItemIconForWindow(panel);
ASSERT_FALSE(icon_bounds.width() == 0 && icon_bounds.height() == 0);
@@ -162,7 +161,7 @@ class PanelLayoutManagerTest : public test::AshTestBase {
base::RunLoop().RunUntilIdle();
views::Widget* widget = GetCalloutWidgetForPanel(panel);
- Shelf* shelf = RootWindowController::ForShelf(panel)->shelf()->shelf();
+ Shelf* shelf = Shelf::ForWindow(panel);
gfx::Rect icon_bounds = shelf->GetScreenBoundsOfItemIconForWindow(panel);
ASSERT_FALSE(icon_bounds.IsEmpty());
@@ -237,21 +236,16 @@ class PanelLayoutManagerTest : public test::AshTestBase {
void SetShelfAutoHideBehavior(aura::Window* window,
ShelfAutoHideBehavior behavior) {
- ShelfLayoutManager* shelf = RootWindowController::ForWindow(window)
- ->shelf()
- ->shelf_layout_manager();
- shelf->SetAutoHideBehavior(behavior);
- ShelfView* shelf_view = GetShelfView(Shelf::ForWindow(window));
- test::ShelfViewTestAPI test_api(shelf_view);
+ Shelf* shelf = Shelf::ForWindow(window);
+ shelf->shelf_layout_manager()->SetAutoHideBehavior(behavior);
+ test::ShelfViewTestAPI test_api(GetShelfView(shelf));
test_api.RunMessageLoopUntilAnimationsDone();
}
void SetShelfVisibilityState(aura::Window* window,
ShelfVisibilityState visibility_state) {
- ShelfLayoutManager* shelf = RootWindowController::ForWindow(window)
- ->shelf()
- ->shelf_layout_manager();
- shelf->SetState(visibility_state);
+ Shelf* shelf = Shelf::ForWindow(window);
+ shelf->shelf_layout_manager()->SetState(visibility_state);
}
ShelfView* GetShelfView(Shelf* shelf) {
diff --git a/ash/wm/window_animations.cc b/ash/wm/window_animations.cc
index 9857448..3689f3f 100644
--- a/ash/wm/window_animations.cc
+++ b/ash/wm/window_animations.cc
@@ -466,12 +466,10 @@ gfx::Rect GetMinimizeAnimationTargetBoundsInScreen(aura::Window* window) {
// width will be 0 but the position in the launcher and the major dimension
// are still reported correctly and the window can be animated to the launcher
// item's light bar.
- ShelfLayoutManager* layout_manager =
- shelf->shelf_widget()->shelf_layout_manager();
if (item_rect.width() != 0 || item_rect.height() != 0) {
- if (layout_manager->visibility_state() == SHELF_AUTO_HIDE) {
+ if (shelf->shelf_layout_manager()->visibility_state() == SHELF_AUTO_HIDE) {
gfx::Rect shelf_bounds = shelf->shelf_widget()->GetWindowBoundsInScreen();
- switch (layout_manager->GetAlignment()) {
+ switch (shelf->alignment()) {
case SHELF_ALIGNMENT_BOTTOM:
item_rect.set_y(shelf_bounds.y());
break;
@@ -495,18 +493,11 @@ gfx::Rect GetMinimizeAnimationTargetBoundsInScreen(aura::Window* window) {
gfx::Rect work_area =
gfx::Screen::GetScreen()->GetDisplayNearestWindow(window).work_area();
int ltr_adjusted_x = base::i18n::IsRTL() ? work_area.right() : work_area.x();
- switch (layout_manager->GetAlignment()) {
- case SHELF_ALIGNMENT_BOTTOM:
- return gfx::Rect(ltr_adjusted_x, work_area.bottom(), 0, 0);
- case SHELF_ALIGNMENT_TOP:
- return gfx::Rect(ltr_adjusted_x, work_area.y(), 0, 0);
- case SHELF_ALIGNMENT_LEFT:
- return gfx::Rect(work_area.x(), work_area.y(), 0, 0);
- case SHELF_ALIGNMENT_RIGHT:
- return gfx::Rect(work_area.right(), work_area.y(), 0, 0);
- }
- NOTREACHED();
- return gfx::Rect();
+ return shelf->SelectValueForShelfAlignment(
+ gfx::Rect(ltr_adjusted_x, work_area.bottom(), 0, 0),
+ gfx::Rect(work_area.x(), work_area.y(), 0, 0),
+ gfx::Rect(work_area.right(), work_area.y(), 0, 0),
+ gfx::Rect(ltr_adjusted_x, work_area.y(), 0, 0));
}
} // namespace ash
diff --git a/ash/wm/workspace/workspace_layout_manager_unittest.cc b/ash/wm/workspace/workspace_layout_manager_unittest.cc
index d2bc5da..918b2fd 100644
--- a/ash/wm/workspace/workspace_layout_manager_unittest.cc
+++ b/ash/wm/workspace/workspace_layout_manager_unittest.cc
@@ -12,6 +12,7 @@
#include "ash/root_window_controller.h"
#include "ash/screen_util.h"
#include "ash/session/session_state_delegate.h"
+#include "ash/shelf/shelf.h"
#include "ash/shelf/shelf_layout_manager.h"
#include "ash/shell.h"
#include "ash/shell_observer.h"
@@ -315,8 +316,8 @@ class DontClobberRestoreBoundsWindowObserver : public aura::WindowObserver {
aura::Window* w = window_;
window_ = nullptr;
- gfx::Rect shelf_bounds(Shell::GetPrimaryRootWindowController()->
- GetShelfLayoutManager()->GetIdealBounds());
+ gfx::Rect shelf_bounds(
+ Shelf::ForPrimaryDisplay()->shelf_layout_manager()->GetIdealBounds());
const gfx::Rect& window_bounds(w->bounds());
w->SetBounds(gfx::Rect(window_bounds.x(), shelf_bounds.y() - 1,
window_bounds.width(), window_bounds.height()));
@@ -792,8 +793,9 @@ TEST_F(WorkspaceLayoutManagerSoloTest, NotResizeWhenScreenIsLocked) {
window->SetProperty(aura::client::kAlwaysOnTopKey, true);
window->Show();
- ShelfLayoutManager* shelf = ShelfLayoutManager::ForShelf(window.get());
- shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
+ ShelfLayoutManager* shelf_layout_manager =
+ Shelf::ForWindow(window.get())->shelf_layout_manager();
+ shelf_layout_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
window->SetBounds(ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()));
gfx::Rect window_bounds = window->bounds();
@@ -803,12 +805,12 @@ TEST_F(WorkspaceLayoutManagerSoloTest, NotResizeWhenScreenIsLocked) {
// The window size should not get touched while we are in lock screen.
Shell::GetInstance()->session_state_delegate()->LockScreen();
- shelf->UpdateVisibilityState();
+ shelf_layout_manager->UpdateVisibilityState();
EXPECT_EQ(window_bounds.ToString(), window->bounds().ToString());
// Coming out of the lock screen the window size should still remain.
Shell::GetInstance()->session_state_delegate()->UnlockScreen();
- shelf->UpdateVisibilityState();
+ shelf_layout_manager->UpdateVisibilityState();
EXPECT_EQ(
ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()).ToString(),
window_bounds.ToString());
@@ -984,7 +986,7 @@ TEST_F(WorkspaceLayoutManagerBackdropTest, VerifyBackdropAndItsStacking) {
// entire workspace area.
TEST_F(WorkspaceLayoutManagerBackdropTest, ShelfVisibilityChangesBounds) {
ShelfLayoutManager* shelf_layout_manager =
- Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager();
+ Shelf::ForPrimaryDisplay()->shelf_layout_manager();
ShowTopWindowBackdrop(true);
RunAllPendingInMessageLoop();
diff --git a/chrome/browser/chromeos/accessibility/accessibility_manager.cc b/chrome/browser/chromeos/accessibility/accessibility_manager.cc
index 6da2f94..add91d4 100644
--- a/chrome/browser/chromeos/accessibility/accessibility_manager.cc
+++ b/chrome/browser/chromeos/accessibility/accessibility_manager.cc
@@ -13,6 +13,7 @@
#include "ash/high_contrast/high_contrast_controller.h"
#include "ash/metrics/user_metrics_recorder.h"
#include "ash/session/session_state_delegate.h"
+#include "ash/shelf/shelf.h"
#include "ash/shelf/shelf_layout_manager.h"
#include "ash/shell.h"
#include "ash/sticky_keys/sticky_keys_controller.h"
@@ -1221,7 +1222,9 @@ void AccessibilityManager::OnChromeVoxPanelClosing() {
aura::Window* root_window = chromevox_panel_->GetRootWindow();
chromevox_panel_widget_observer_.reset(nullptr);
chromevox_panel_ = nullptr;
- ash::ShelfLayoutManager::ForShelf(root_window)->SetChromeVoxPanelHeight(0);
+ ash::Shelf::ForWindow(root_window)
+ ->shelf_layout_manager()
+ ->SetChromeVoxPanelHeight(0);
}
void AccessibilityManager::OnChromeVoxPanelDestroying() {
diff --git a/chrome/browser/chromeos/accessibility/chromevox_panel.cc b/chrome/browser/chromeos/accessibility/chromevox_panel.cc
index 01c9805..2fa56ebe 100644
--- a/chrome/browser/chromeos/accessibility/chromevox_panel.cc
+++ b/chrome/browser/chromeos/accessibility/chromevox_panel.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "ash/shelf/shelf.h"
#include "ash/shelf/shelf_layout_manager.h"
#include "ash/shell.h"
#include "ash/shell_window_ids.h"
@@ -105,7 +106,8 @@ void ChromeVoxPanel::Close() {
void ChromeVoxPanel::DidFirstVisuallyNonEmptyPaint() {
widget_->Show();
- ash::ShelfLayoutManager::ForShelf(GetRootWindow())
+ ash::Shelf::ForWindow(GetRootWindow())
+ ->shelf_layout_manager()
->SetChromeVoxPanelHeight(kPanelHeight);
}
diff --git a/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc b/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc
index 3a0c7f4..03c840b 100644
--- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc
+++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc
@@ -16,7 +16,6 @@
#include "ash/shelf/shelf_item_delegate_manager.h"
#include "ash/shelf/shelf_layout_manager.h"
#include "ash/shelf/shelf_model.h"
-#include "ash/shelf/shelf_widget.h"
#include "ash/shell.h"
#include "ash/system/tray/system_tray_delegate.h"
#include "ash/wm/window_util.h"
@@ -504,10 +503,8 @@ ChromeLauncherController::~ChromeLauncherController() {
// Reset the app window controller here since it has a weak pointer to this.
app_window_controller_.reset();
- for (std::set<ash::Shelf*>::iterator iter = shelves_.begin();
- iter != shelves_.end();
- ++iter)
- (*iter)->shelf_widget()->shelf_layout_manager()->RemoveObserver(this);
+ for (auto iter : shelves_)
+ iter->shelf_layout_manager()->RemoveObserver(this);
model_->RemoveObserver(this);
if (ash::Shell::HasInstance())
@@ -1170,7 +1167,7 @@ ChromeLauncherController::ActivateWindowOrMinimizeIfActive(
void ChromeLauncherController::OnShelfCreated(ash::Shelf* shelf) {
shelves_.insert(shelf);
- shelf->shelf_widget()->shelf_layout_manager()->AddObserver(this);
+ shelf->shelf_layout_manager()->AddObserver(this);
}
void ChromeLauncherController::OnShelfDestroyed(ash::Shelf* shelf) {
diff --git a/chrome/browser/ui/ash/shelf_browsertest.cc b/chrome/browser/ui/ash/shelf_browsertest.cc
index 313fdef..7a3112e 100644
--- a/chrome/browser/ui/ash/shelf_browsertest.cc
+++ b/chrome/browser/ui/ash/shelf_browsertest.cc
@@ -2,10 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ash/root_window_controller.h"
+#include "ash/shelf/shelf.h"
#include "ash/shelf/shelf_layout_manager.h"
-#include "ash/shell.h"
-#include "ash/wm/workspace_controller.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h"
@@ -16,26 +14,27 @@ typedef InProcessBrowserTest ShelfBrowserTest;
// Confirm that a status bubble doesn't cause the shelf to darken.
IN_PROC_BROWSER_TEST_F(ShelfBrowserTest, StatusBubble) {
- ash::ShelfLayoutManager* shelf =
- ash::RootWindowController::ForShelf(
- browser()->window()->GetNativeWindow())->GetShelfLayoutManager();
- EXPECT_TRUE(shelf->IsVisible());
+ ash::ShelfLayoutManager* shelf_layout_manager =
+ ash::Shelf::ForWindow(browser()->window()->GetNativeWindow())
+ ->shelf_layout_manager();
+ EXPECT_TRUE(shelf_layout_manager->IsVisible());
// Ensure that the browser abuts the shelf.
- const gfx::Rect old_bounds = browser()->window()->GetBounds();
- const gfx::Rect new_bounds(
- old_bounds.x(),
- old_bounds.y(),
- old_bounds.width(),
- shelf->GetIdealBounds().y() - old_bounds.y());
- browser()->window()->SetBounds(new_bounds);
- EXPECT_FALSE(shelf->window_overlaps_shelf());
+ gfx::Rect bounds = browser()->window()->GetBounds();
+ bounds.set_height(shelf_layout_manager->GetIdealBounds().y() - bounds.y());
+ browser()->window()->SetBounds(bounds);
+ EXPECT_FALSE(shelf_layout_manager->window_overlaps_shelf());
- // Show status, which will overlap the shelf by a pixel.
+ // Show status, which may overlap the shelf by a pixel.
browser()->window()->GetStatusBubble()->SetStatus(
base::UTF8ToUTF16("Dummy Status Text"));
- shelf->UpdateVisibilityState();
+ shelf_layout_manager->UpdateVisibilityState();
// Ensure that status doesn't cause overlap.
- EXPECT_FALSE(shelf->window_overlaps_shelf());
+ EXPECT_FALSE(shelf_layout_manager->window_overlaps_shelf());
+
+ // Ensure that moving the browser slightly down does cause overlap.
+ bounds.Offset(0, 1);
+ browser()->window()->SetBounds(bounds);
+ EXPECT_TRUE(shelf_layout_manager->window_overlaps_shelf());
}