Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(227)

Unified Diff: ui/aura_shell/shadow_controller.cc

Issue 9026017: Move some more files into ash... this time seed the window manager dir. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/aura_shell/shadow_controller.h ('k') | ui/aura_shell/shadow_controller_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura_shell/shadow_controller.cc
===================================================================
--- ui/aura_shell/shadow_controller.cc (revision 115643)
+++ ui/aura_shell/shadow_controller.cc (working copy)
@@ -1,117 +0,0 @@
-// Copyright (c) 2011 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 "ui/aura_shell/shadow_controller.h"
-
-#include <utility>
-
-#include "base/command_line.h"
-#include "base/logging.h"
-#include "ui/aura/root_window.h"
-#include "ui/aura/window.h"
-#include "ui/aura_shell/aura_shell_switches.h"
-#include "ui/aura_shell/shadow.h"
-#include "ui/aura_shell/shadow_types.h"
-#include "ui/aura_shell/window_properties.h"
-
-using std::make_pair;
-
-namespace aura_shell {
-namespace internal {
-
-namespace {
-
-ShadowType GetShadowTypeFromWindowType(aura::Window* window) {
- switch (window->type()) {
- case aura::client::WINDOW_TYPE_NORMAL:
- return CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kAuraTranslucentFrames) ?
- SHADOW_TYPE_NONE : SHADOW_TYPE_RECTANGULAR;
- case aura::client::WINDOW_TYPE_MENU:
- case aura::client::WINDOW_TYPE_TOOLTIP:
- return SHADOW_TYPE_RECTANGULAR;
- default:
- break;
- }
- return SHADOW_TYPE_NONE;
-}
-
-} // namespace
-
-ShadowController::ShadowController() {
- aura::RootWindow::GetInstance()->AddRootWindowObserver(this);
-}
-
-ShadowController::~ShadowController() {
- for (WindowShadowMap::const_iterator it = window_shadows_.begin();
- it != window_shadows_.end(); ++it) {
- it->first->RemoveObserver(this);
- }
- aura::RootWindow::GetInstance()->RemoveRootWindowObserver(this);
-}
-
-void ShadowController::OnWindowInitialized(aura::Window* window) {
- window->AddObserver(this);
- SetShadowType(window, GetShadowTypeFromWindowType(window));
- HandlePossibleShadowVisibilityChange(window);
-}
-
-void ShadowController::OnWindowPropertyChanged(aura::Window* window,
- const char* name,
- void* old) {
- if (name == kShadowTypeKey)
- HandlePossibleShadowVisibilityChange(window);
-}
-
-void ShadowController::OnWindowBoundsChanged(aura::Window* window,
- const gfx::Rect& bounds) {
- Shadow* shadow = GetShadowForWindow(window);
- if (shadow)
- shadow->SetContentBounds(gfx::Rect(bounds.size()));
-}
-
-void ShadowController::OnWindowDestroyed(aura::Window* window) {
- window_shadows_.erase(window);
-}
-
-bool ShadowController::ShouldShowShadowForWindow(aura::Window* window) const {
- const ShadowType type = GetShadowType(window);
- switch (type) {
- case SHADOW_TYPE_NONE:
- return false;
- case SHADOW_TYPE_RECTANGULAR:
- return true;
- default:
- NOTREACHED() << "Unknown shadow type " << type;
- return false;
- }
-}
-
-Shadow* ShadowController::GetShadowForWindow(aura::Window* window) {
- WindowShadowMap::const_iterator it = window_shadows_.find(window);
- return it != window_shadows_.end() ? it->second.get() : NULL;
-}
-
-void ShadowController::HandlePossibleShadowVisibilityChange(
- aura::Window* window) {
- const bool should_show = ShouldShowShadowForWindow(window);
- Shadow* shadow = GetShadowForWindow(window);
- if (shadow)
- shadow->layer()->SetVisible(should_show);
- else if (should_show && !shadow)
- CreateShadowForWindow(window);
-}
-
-void ShadowController::CreateShadowForWindow(aura::Window* window) {
- linked_ptr<Shadow> shadow(new Shadow());
- window_shadows_.insert(make_pair(window, shadow));
-
- shadow->Init();
- shadow->SetContentBounds(gfx::Rect(window->bounds().size()));
- shadow->layer()->SetVisible(ShouldShowShadowForWindow(window));
- window->layer()->Add(shadow->layer());
-}
-
-} // namespace internal
-} // namespace aura_shell
« no previous file with comments | « ui/aura_shell/shadow_controller.h ('k') | ui/aura_shell/shadow_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698