[iOS] Cleanup ios/chrome/ios_chrome.gyp
[chromium-blink-merge.git] / ash / wm / status_area_layout_manager.cc
blobb4e6abf0b74ca294ec979c81eef4f5c2d1f43f66
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/shelf/shelf_layout_manager.h"
8 #include "ash/shelf/shelf_widget.h"
9 #include "ash/system/status_area_widget.h"
10 #include "base/auto_reset.h"
11 #include "ui/aura/window.h"
12 #include "ui/views/widget/widget.h"
14 namespace ash {
16 ////////////////////////////////////////////////////////////////////////////////
17 // StatusAreaLayoutManager, public:
19 StatusAreaLayoutManager::StatusAreaLayoutManager(aura::Window* container,
20 ShelfWidget* shelf)
21 : SnapToPixelLayoutManager(container), in_layout_(false), shelf_(shelf) {
24 StatusAreaLayoutManager::~StatusAreaLayoutManager() {
27 ////////////////////////////////////////////////////////////////////////////////
28 // StatusAreaLayoutManager, aura::LayoutManager implementation:
30 void StatusAreaLayoutManager::OnWindowResized() {
31 LayoutStatusArea();
34 void StatusAreaLayoutManager::SetChildBounds(
35 aura::Window* child,
36 const gfx::Rect& requested_bounds) {
37 // Only need to have the shelf do a layout if the child changing is the status
38 // area and the shelf isn't in the process of doing a layout.
39 if (child != shelf_->status_area_widget()->GetNativeView() || in_layout_) {
40 SnapToPixelLayoutManager::SetChildBounds(child, requested_bounds);
41 return;
44 // If the bounds match, no need to do anything. Check for target bounds to
45 // ensure any active animation is retargeted.
46 if (requested_bounds == child->GetTargetBounds())
47 return;
49 SnapToPixelLayoutManager::SetChildBounds(child, requested_bounds);
50 LayoutStatusArea();
53 ////////////////////////////////////////////////////////////////////////////////
54 // StatusAreaLayoutManager, private:
56 void StatusAreaLayoutManager::LayoutStatusArea() {
57 // Shelf layout manager may be already doing layout.
58 if (shelf_->shelf_layout_manager()->updating_bounds())
59 return;
61 base::AutoReset<bool> auto_reset_in_layout(&in_layout_, true);
62 shelf_->shelf_layout_manager()->LayoutShelf();
65 } // namespace ash