OLD | NEW |
(Empty) | |
| 1 // Copyright 2013 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. |
| 4 |
| 5 #include "chrome/browser/ui/views/frame/non_client_frame_view_switcher_ash.h" |
| 6 |
| 7 #include "ash/wm/window_state.h" |
| 8 #include "ui/aura/window.h" |
| 9 #include "ui/views/widget/widget.h" |
| 10 #include "ui/views/window/non_client_view.h" |
| 11 |
| 12 NonClientFrameViewSwitcherAsh::NonClientFrameViewSwitcherAsh( |
| 13 views::Widget* frame_widget, |
| 14 aura::Window* frame_window) |
| 15 : frame_widget_(frame_widget), |
| 16 frame_window_(frame_window) { |
| 17 frame_window_->AddObserver(this); |
| 18 ash::wm::GetWindowState(frame_window_)->AddObserver(this); |
| 19 } |
| 20 |
| 21 NonClientFrameViewSwitcherAsh::~NonClientFrameViewSwitcherAsh() { |
| 22 if (frame_window_) { |
| 23 frame_window_->RemoveObserver(this); |
| 24 ash::wm::GetWindowState(frame_window_)->RemoveObserver(this); |
| 25 } |
| 26 } |
| 27 |
| 28 void NonClientFrameViewSwitcherAsh::OnWindowDestroying(aura::Window* window) { |
| 29 frame_window_->RemoveObserver(this); |
| 30 ash::wm::GetWindowState(frame_window_)->RemoveObserver(this); |
| 31 frame_window_ = NULL; |
| 32 } |
| 33 |
| 34 void NonClientFrameViewSwitcherAsh::OnWindowShowTypeChanged( |
| 35 ash::wm::WindowState* window_state, |
| 36 ash::wm::WindowShowType type) { |
| 37 if (frame_widget_->non_client_view() && |
| 38 (window_state->window_show_type() == ash::wm::SHOW_TYPE_MAXIMIZED || |
| 39 type == ash::wm::SHOW_TYPE_MAXIMIZED)) { |
| 40 // Defer frame layout when replacing the frame. Layout will occur as a |
| 41 // result of WorkspaceLayoutManager::OnWindowShowTypeChanged(). |
| 42 frame_widget_->non_client_view()->UpdateFrame( |
| 43 type == ash::wm::SHOW_TYPE_MINIMIZED); |
| 44 } |
| 45 } |
OLD | NEW |