diff options
author | oshima <oshima@chromium.org> | 2014-09-09 15:52:45 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-09-09 23:00:39 +0000 |
commit | 6f4aaa635947f11cf1a9edf9f4221290fa9af2a6 (patch) | |
tree | 4749b3bbe8f1f0735f3454983e67a31b05c9a7cb /athena/util | |
parent | 0c8cc979ef6f678cfad1a7cd0a204b3d29ba3fcd (diff) | |
download | chromium_src-6f4aaa635947f11cf1a9edf9f4221290fa9af2a6.zip chromium_src-6f4aaa635947f11cf1a9edf9f4221290fa9af2a6.tar.gz chromium_src-6f4aaa635947f11cf1a9edf9f4221290fa9af2a6.tar.bz2 |
Rename athena/common to athena/util
"common" is used for the code that is common better renderer and browser. Rename to "util" instead.
BUG=None
TBR=danakj@chromium.org
Review URL: https://codereview.chromium.org/558483003
Cr-Commit-Position: refs/heads/master@{#294025}
Diffstat (limited to 'athena/util')
-rw-r--r-- | athena/util/DEPS | 5 | ||||
-rw-r--r-- | athena/util/container_priorities.h | 20 | ||||
-rw-r--r-- | athena/util/fill_layout_manager.cc | 46 | ||||
-rw-r--r-- | athena/util/fill_layout_manager.h | 36 | ||||
-rw-r--r-- | athena/util/fill_layout_manager_unittest.cc | 32 | ||||
-rw-r--r-- | athena/util/switches.cc | 22 | ||||
-rw-r--r-- | athena/util/switches.h | 16 |
7 files changed, 177 insertions, 0 deletions
diff --git a/athena/util/DEPS b/athena/util/DEPS new file mode 100644 index 0000000..8755565 --- /dev/null +++ b/athena/util/DEPS @@ -0,0 +1,5 @@ +include_rules = [ + "+athena/athena_export.h", + "+ui/aura", + "+ui/compositor", +] diff --git a/athena/util/container_priorities.h b/athena/util/container_priorities.h new file mode 100644 index 0000000..8a38277 --- /dev/null +++ b/athena/util/container_priorities.h @@ -0,0 +1,20 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef ATHENA_UTIL_CONTAINER_PRIORITIES_H_ +#define ATHENA_UTIL_CONTAINER_PRIORITIES_H_ + +namespace athena { + +enum ContainerPriorities { + CP_BACKGROUND = 0, + CP_DEFAULT, + CP_HOME_CARD, + CP_SYSTEM_MODAL, + CP_VIRTUAL_KEYBOARD, +}; + +} // namespace athena + +#endif // ATHENA_UTIL_CONTAINER_PRIORITIES_H_ diff --git a/athena/util/fill_layout_manager.cc b/athena/util/fill_layout_manager.cc new file mode 100644 index 0000000..8ee546b --- /dev/null +++ b/athena/util/fill_layout_manager.cc @@ -0,0 +1,46 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "athena/util/fill_layout_manager.h" + +#include "base/logging.h" +#include "ui/aura/window.h" + +namespace athena { + +FillLayoutManager::FillLayoutManager(aura::Window* container) + : container_(container) { + DCHECK(container_); +} + +FillLayoutManager::~FillLayoutManager() { +} + +void FillLayoutManager::OnWindowResized() { + gfx::Rect full_bounds = gfx::Rect(container_->bounds().size()); + for (aura::Window::Windows::const_iterator iter = + container_->children().begin(); + iter != container_->children().end(); + ++iter) { + SetChildBoundsDirect(*iter, full_bounds); + } +} + +void FillLayoutManager::OnWindowAddedToLayout(aura::Window* child) { + SetChildBoundsDirect(child, (gfx::Rect(container_->bounds().size()))); +} + +void FillLayoutManager::OnWillRemoveWindowFromLayout(aura::Window* child) { +} +void FillLayoutManager::OnWindowRemovedFromLayout(aura::Window* child) { +} +void FillLayoutManager::OnChildWindowVisibilityChanged(aura::Window* child, + bool visible) { +} +void FillLayoutManager::SetChildBounds(aura::Window* child, + const gfx::Rect& requested_bounds) { + // Ignore SetBounds request. +} + +} // namespace athena diff --git a/athena/util/fill_layout_manager.h b/athena/util/fill_layout_manager.h new file mode 100644 index 0000000..15406f3 --- /dev/null +++ b/athena/util/fill_layout_manager.h @@ -0,0 +1,36 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef ATHENA_UTIL_FILL_LAYOUT_MANAGER_H_ +#define ATHENA_UTIL_FILL_LAYOUT_MANAGER_H_ + +#include "athena/athena_export.h" +#include "ui/aura/layout_manager.h" + +namespace athena { + +class ATHENA_EXPORT FillLayoutManager : public aura::LayoutManager { + public: + explicit FillLayoutManager(aura::Window* container); + virtual ~FillLayoutManager(); + + // aura::LayoutManager: + virtual void OnWindowResized() OVERRIDE; + virtual void OnWindowAddedToLayout(aura::Window* child) OVERRIDE; + virtual void OnWillRemoveWindowFromLayout(aura::Window* child) OVERRIDE; + virtual void OnWindowRemovedFromLayout(aura::Window* child) OVERRIDE; + virtual void OnChildWindowVisibilityChanged(aura::Window* child, + bool visible) OVERRIDE; + virtual void SetChildBounds(aura::Window* child, + const gfx::Rect& requested_bounds) OVERRIDE; + + private: + aura::Window* container_; + + DISALLOW_COPY_AND_ASSIGN(FillLayoutManager); +}; + +} // namespace athena + +#endif // ATHENA_UTIL_FILL_LAYOUT_MANAGER_H_ diff --git a/athena/util/fill_layout_manager_unittest.cc b/athena/util/fill_layout_manager_unittest.cc new file mode 100644 index 0000000..e183efe --- /dev/null +++ b/athena/util/fill_layout_manager_unittest.cc @@ -0,0 +1,32 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "athena/util/fill_layout_manager.h" + +#include "testing/gtest/include/gtest/gtest.h" +#include "ui/aura/window.h" + +namespace athena { + +TEST(FillLayoutManagerTest, ChildWindowSizedCorrectly) { + scoped_ptr<aura::Window> parent(new aura::Window(NULL)); + parent->SetBounds(gfx::Rect(10, 20, 30, 40)); + parent->SetLayoutManager(new FillLayoutManager(parent.get())); + + scoped_ptr<aura::Window> child(new aura::Window(NULL)); + child->SetBounds(gfx::Rect(0, 0, 5, 10)); + + EXPECT_NE(child->bounds().size().ToString(), + parent->bounds().size().ToString()); + + parent->AddChild(child.get()); + EXPECT_EQ(child->bounds().size().ToString(), + parent->bounds().size().ToString()); + + parent->SetBounds(gfx::Rect(0, 0, 100, 200)); + EXPECT_EQ(child->bounds().size().ToString(), + parent->bounds().size().ToString()); +} + +} // namespace athena diff --git a/athena/util/switches.cc b/athena/util/switches.cc new file mode 100644 index 0000000..1b76f1f --- /dev/null +++ b/athena/util/switches.cc @@ -0,0 +1,22 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "athena/util/switches.h" + +#include "base/command_line.h" + +namespace athena { +namespace switches { + +bool IsDebugAcceleratorsEnabled() { +#if NDEBUG + return base::CommandLine::ForCurrentProcess()->HasSwitch( + "debug-accelerators"); +#else + return true; +#endif +} + +} // namespace switches +} // namespace athena diff --git a/athena/util/switches.h b/athena/util/switches.h new file mode 100644 index 0000000..b598e8a --- /dev/null +++ b/athena/util/switches.h @@ -0,0 +1,16 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef ATHENA_UTIL_SWITCHES_H_ +#define ATHENA_UTIL_SWITCHES_H_ + +namespace athena { +namespace switches { + +bool IsDebugAcceleratorsEnabled(); + +} // namespace switches +} // namespace athena + +#endif // ATHENA_UTIL_SWITCHES_H_ |