ServiceWorker: Consolidate version manipulation functions in SWProviderContext
[chromium-blink-merge.git] / athena / util / fill_layout_manager.cc
blob2fe7722bd87f8f0237deba93bd237ce27c6e5460
1 // Copyright 2014 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 "athena/util/fill_layout_manager.h"
7 #include "base/logging.h"
8 #include "ui/aura/window.h"
9 #include "ui/aura/window_property.h"
11 namespace athena {
12 namespace {
14 DEFINE_LOCAL_WINDOW_PROPERTY_KEY(bool, kAlwaysFillWindowKey, false);
16 // TODO(oshima): Implement real window/layout manager. crbug.com/388362.
17 bool ShouldFill(aura::Window* window) {
18 return window->GetProperty(kAlwaysFillWindowKey) ||
19 (window->type() != ui::wm::WINDOW_TYPE_MENU &&
20 window->type() != ui::wm::WINDOW_TYPE_TOOLTIP &&
21 window->type() != ui::wm::WINDOW_TYPE_POPUP);
24 } // namespace
26 // static
27 void FillLayoutManager::SetAlwaysFill(aura::Window* window) {
28 window->SetProperty(kAlwaysFillWindowKey, true);
31 FillLayoutManager::FillLayoutManager(aura::Window* container)
32 : container_(container) {
33 DCHECK(container_);
36 FillLayoutManager::~FillLayoutManager() {
39 void FillLayoutManager::OnWindowResized() {
40 gfx::Rect full_bounds = gfx::Rect(container_->bounds().size());
41 for (aura::Window::Windows::const_iterator iter =
42 container_->children().begin();
43 iter != container_->children().end();
44 ++iter) {
45 if (ShouldFill(*iter))
46 SetChildBoundsDirect(*iter, full_bounds);
50 void FillLayoutManager::OnWindowAddedToLayout(aura::Window* child) {
51 if (ShouldFill(child))
52 SetChildBoundsDirect(child, gfx::Rect(container_->bounds().size()));
55 void FillLayoutManager::OnWillRemoveWindowFromLayout(aura::Window* child) {
58 void FillLayoutManager::OnWindowRemovedFromLayout(aura::Window* child) {
61 void FillLayoutManager::OnChildWindowVisibilityChanged(aura::Window* child,
62 bool visible) {
63 if (visible && ShouldFill(child))
64 SetChildBoundsDirect(child, gfx::Rect(container_->bounds().size()));
67 void FillLayoutManager::SetChildBounds(aura::Window* child,
68 const gfx::Rect& requested_bounds) {
69 if (!ShouldFill(child))
70 SetChildBoundsDirect(child, requested_bounds);
73 } // namespace athena