[content shell] implement testRunner.overridePreference
[chromium-blink-merge.git] / ash / wm / status_area_layout_manager.cc
blobdf379696d74939460276fe7dd2a1dc32c5d1a44d
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ash/wm/status_area_layout_manager.h"
7 #include "ash/system/status_area_widget.h"
8 #include "ash/wm/shelf_layout_manager.h"
9 #include "base/auto_reset.h"
10 #include "ui/aura/window.h"
11 #include "ui/views/widget/widget.h"
13 namespace ash {
14 namespace internal {
16 ////////////////////////////////////////////////////////////////////////////////
17 // StatusAreaLayoutManager, public:
19 StatusAreaLayoutManager::StatusAreaLayoutManager(ShelfLayoutManager* shelf)
20 : in_layout_(false),
21 shelf_(shelf) {
24 StatusAreaLayoutManager::~StatusAreaLayoutManager() {
27 ////////////////////////////////////////////////////////////////////////////////
28 // StatusAreaLayoutManager, aura::LayoutManager implementation:
30 void StatusAreaLayoutManager::OnWindowResized() {
31 LayoutStatusArea();
34 void StatusAreaLayoutManager::OnWindowAddedToLayout(aura::Window* child) {
37 void StatusAreaLayoutManager::OnWillRemoveWindowFromLayout(
38 aura::Window* child) {
41 void StatusAreaLayoutManager::OnWindowRemovedFromLayout(aura::Window* child) {
44 void StatusAreaLayoutManager::OnChildWindowVisibilityChanged(
45 aura::Window* child, bool visible) {
48 void StatusAreaLayoutManager::SetChildBounds(
49 aura::Window* child,
50 const gfx::Rect& requested_bounds) {
51 // Only need to have the shelf do a layout if the child changing is the status
52 // area and the shelf isn't in the process of doing a layout.
53 if (child != shelf_->status_area_widget()->GetNativeView() || in_layout_) {
54 SetChildBoundsDirect(child, requested_bounds);
55 return;
58 // If the size matches, no need to do anything. We don't check the location as
59 // that is managed by the shelf.
60 if (requested_bounds == child->bounds())
61 return;
63 SetChildBoundsDirect(child, requested_bounds);
64 LayoutStatusArea();
67 ////////////////////////////////////////////////////////////////////////////////
68 // StatusAreaLayoutManager, private:
70 void StatusAreaLayoutManager::LayoutStatusArea() {
71 // Shelf layout manager may be already doing layout.
72 if (shelf_->in_layout())
73 return;
75 base::AutoReset<bool> auto_reset_in_layout(&in_layout_, true);
76 shelf_->LayoutShelf();
79 } // namespace internal
80 } // namespace ash