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

Unified Diff: ash/wm/lock_layout_manager.cc

Issue 254673004: Add LockLayoutManager responsible for lock container (login/lock). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cl Created 6 years, 6 months 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
Index: ash/wm/lock_layout_manager.cc
diff --git a/ash/wm/lock_layout_manager.cc b/ash/wm/lock_layout_manager.cc
new file mode 100644
index 0000000000000000000000000000000000000000..3377d375238bbe5b5b6c67435e0db5bf02977721
--- /dev/null
+++ b/ash/wm/lock_layout_manager.cc
@@ -0,0 +1,167 @@
+// 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 "ash/wm/lock_layout_manager.h"
+
+#include "ash/shell.h"
+#include "ash/shell_delegate.h"
+#include "ash/wm/lock_window_state.h"
+#include "ash/wm/window_state.h"
+#include "ash/wm/wm_event.h"
+#include "ui/aura/window.h"
+#include "ui/aura/window_observer.h"
+#include "ui/events/event.h"
+#include "ui/keyboard/keyboard_controller.h"
+#include "ui/keyboard/keyboard_util.h"
+
+using aura::Window;
+
+namespace ash {
+
+LockLayoutManager::LockLayoutManager(aura::Window* window)
+ : window_(window),
+ root_window_(window->GetRootWindow()),
+ is_observing_keyboard_(false) {
+ Shell::GetInstance()->delegate()->AddVirtualKeyboardStateObserver(this);
+ root_window_->AddObserver(this);
+ if (keyboard::KeyboardController::GetInstance()) {
+ keyboard::KeyboardController::GetInstance()->AddObserver(this);
+ is_observing_keyboard_ = true;
+ }
+}
+
+LockLayoutManager::~LockLayoutManager() {
+ if (root_window_)
+ root_window_->RemoveObserver(this);
+
+ for (WindowSet::const_iterator i = windows_.begin(); i != windows_.end(); ++i)
+ (*i)->RemoveObserver(this);
+
+ Shell::GetInstance()->delegate()->RemoveVirtualKeyboardStateObserver(this);
+
+ if (keyboard::KeyboardController::GetInstance() && is_observing_keyboard_) {
+ keyboard::KeyboardController::GetInstance()->RemoveObserver(this);
+ is_observing_keyboard_ = false;
+ }
+}
+
+void LockLayoutManager::OnWindowResized() {
+ const wm::WMEvent event(wm::WM_EVENT_WORKAREA_BOUNDS_CHANGED);
+ AdjustWindowsForWorkAreaChange(&event);
+}
+
+void LockLayoutManager::OnWindowAddedToLayout(Window* child) {
+ windows_.insert(child);
+ child->AddObserver(this);
+
+ window_state_map_[child] = new LockWindowState(child);
+ wm::WindowState* window_state = wm::GetWindowState(child);
+ wm::WMEvent event(wm::WM_EVENT_ADDED_TO_WORKSPACE);
+ window_state->OnWMEvent(&event);
+}
+
+void LockLayoutManager::OnWillRemoveWindowFromLayout(Window* child) {
+ windows_.erase(child);
+ child->RemoveObserver(this);
+}
+
+void LockLayoutManager::OnWindowRemovedFromLayout(Window* child) {
+}
+
+void LockLayoutManager::OnChildWindowVisibilityChanged(Window* child,
+ bool visible) {
+}
+
+void LockLayoutManager::SetChildBounds(
+ Window* child,
+ const gfx::Rect& requested_bounds) {
+ wm::WindowState* window_state = wm::GetWindowState(child);
+ wm::SetBoundsEvent event(wm::WM_EVENT_SET_BOUNDS, requested_bounds);
+ window_state->OnWMEvent(&event);
+}
+
+void LockLayoutManager::OnWindowHierarchyChanged(
+ const WindowObserver::HierarchyChangeParams& params) {
+}
+
+void LockLayoutManager::OnWindowPropertyChanged(Window* window,
+ const void* key,
+ intptr_t old) {
+}
+
+void LockLayoutManager::OnWindowStackingChanged(aura::Window* window) {
+}
+
+void LockLayoutManager::OnWindowDestroying(aura::Window* window) {
+ if (root_window_ == window) {
+ root_window_->RemoveObserver(this);
+ root_window_ = NULL;
+ } else {
+ ForgetWindow(window);
+ }
+}
+
+void LockLayoutManager::OnWindowBoundsChanged(aura::Window* window,
+ const gfx::Rect& old_bounds,
+ const gfx::Rect& new_bounds) {
+ if (root_window_ == window) {
+ const wm::WMEvent wm_event(wm::WM_EVENT_DISPLAY_BOUNDS_CHANGED);
+ AdjustWindowsForWorkAreaChange(&wm_event);
+ }
+}
+
+void LockLayoutManager::OnVirtualKeyboardStateChanged(bool activated) {
+ if (keyboard::KeyboardController::GetInstance()) {
+ if (activated) {
+ if (!is_observing_keyboard_) {
+ keyboard::KeyboardController::GetInstance()->AddObserver(this);
+ is_observing_keyboard_ = true;
+ }
+ } else {
+ keyboard::KeyboardController::GetInstance()->RemoveObserver(this);
+ is_observing_keyboard_ = false;
+ }
+ }
+}
+
+void LockLayoutManager::OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) {
+ keyboard_bounds_ = new_bounds;
+ OnWindowResized();
+}
+
+void LockLayoutManager::AdjustWindowsForWorkAreaChange(
+ const wm::WMEvent* event) {
+ for (WindowToState::iterator it = window_state_map_.begin();
+ it != window_state_map_.end();
+ ++it) {
+ wm::GetWindowState(it->first)->OnWMEvent(event);
+ }
+
+ DCHECK(event->type() == wm::WM_EVENT_DISPLAY_BOUNDS_CHANGED ||
+ event->type() == wm::WM_EVENT_WORKAREA_BOUNDS_CHANGED);
+
+ // If a user plugs an external display into a laptop running Aura the
+ // display size will change. Maximized windows need to resize to match.
+ // We also do this when developers running Aura on a desktop manually resize
+ // the host window.
+ // We also need to do this when the work area insets changes.
+ for (WindowSet::const_iterator it = windows_.begin();
+ it != windows_.end();
+ ++it) {
+ wm::GetWindowState(*it)->OnWMEvent(event);
+ }
oshima 2014/06/04 19:20:14 looks to me that you're sending the same event twi
+}
+
+void LockLayoutManager::ForgetWindow(aura::Window* window) {
+ WindowToState::iterator it = window_state_map_.find(window);
+
+ // The following DCHECK could fail if our window state object was destroyed
+ // earlier by someone else. However - at this point there is no other client
+ // which replaces the state object and therefore this should not happen.
+ DCHECK(it != window_state_map_.end());
+ window->RemoveObserver(this);
+ window_state_map_.erase(it);
+}
+
+} // namespace ash

Powered by Google App Engine
This is Rietveld 408576698