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

Side by Side Diff: ash/common/frame/custom_frame_view_ash.cc

Issue 2699033002: Replace WmWindowObserver with aura::WindowObserver. (Closed)
Patch Set: Check for null images in ShelfWindowWatcher. Created 3 years, 10 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 unified diff | Download patch
« no previous file with comments | « ash/common/devtools/ash_devtools_dom_agent.cc ('k') | ash/common/shelf/shelf_window_watcher.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/common/frame/custom_frame_view_ash.h" 5 #include "ash/common/frame/custom_frame_view_ash.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/common/frame/caption_buttons/frame_caption_button_container_view.h " 10 #include "ash/common/frame/caption_buttons/frame_caption_button_container_view.h "
11 #include "ash/common/frame/frame_border_hit_test.h" 11 #include "ash/common/frame/frame_border_hit_test.h"
12 #include "ash/common/frame/header_view.h" 12 #include "ash/common/frame/header_view.h"
13 #include "ash/common/wm/window_state.h" 13 #include "ash/common/wm/window_state.h"
14 #include "ash/common/wm/window_state_delegate.h" 14 #include "ash/common/wm/window_state_delegate.h"
15 #include "ash/common/wm/window_state_observer.h" 15 #include "ash/common/wm/window_state_observer.h"
16 #include "ash/common/wm_lookup.h" 16 #include "ash/common/wm_lookup.h"
17 #include "ash/common/wm_shell.h" 17 #include "ash/common/wm_shell.h"
18 #include "ash/common/wm_window.h" 18 #include "ash/common/wm_window.h"
19 #include "ash/common/wm_window_observer.h"
20 #include "ash/common/wm_window_property.h" 19 #include "ash/common/wm_window_property.h"
21 #include "ash/shared/immersive_fullscreen_controller.h" 20 #include "ash/shared/immersive_fullscreen_controller.h"
22 #include "ash/shared/immersive_fullscreen_controller_delegate.h" 21 #include "ash/shared/immersive_fullscreen_controller_delegate.h"
22 #include "ui/aura/window.h"
23 #include "ui/aura/window_observer.h"
23 #include "ui/gfx/geometry/rect.h" 24 #include "ui/gfx/geometry/rect.h"
24 #include "ui/gfx/geometry/rect_conversions.h" 25 #include "ui/gfx/geometry/rect_conversions.h"
25 #include "ui/gfx/geometry/size.h" 26 #include "ui/gfx/geometry/size.h"
26 #include "ui/views/view.h" 27 #include "ui/views/view.h"
27 #include "ui/views/view_targeter.h" 28 #include "ui/views/view_targeter.h"
28 #include "ui/views/widget/widget.h" 29 #include "ui/views/widget/widget.h"
29 #include "ui/views/widget/widget_delegate.h" 30 #include "ui/views/widget/widget_delegate.h"
30 31
31 namespace ash { 32 namespace ash {
32 33
33 namespace { 34 namespace {
34 35
35 /////////////////////////////////////////////////////////////////////////////// 36 ///////////////////////////////////////////////////////////////////////////////
36 // CustomFrameViewAshWindowStateDelegate 37 // CustomFrameViewAshWindowStateDelegate
37 38
38 // Handles a user's fullscreen request (Shift+F4/F4). Puts the window into 39 // Handles a user's fullscreen request (Shift+F4/F4). Puts the window into
39 // immersive fullscreen if immersive fullscreen is enabled for non-browser 40 // immersive fullscreen if immersive fullscreen is enabled for non-browser
40 // windows. 41 // windows.
41 class CustomFrameViewAshWindowStateDelegate : public wm::WindowStateDelegate, 42 class CustomFrameViewAshWindowStateDelegate : public wm::WindowStateDelegate,
42 public wm::WindowStateObserver, 43 public wm::WindowStateObserver,
43 public WmWindowObserver { 44 public aura::WindowObserver {
44 public: 45 public:
45 CustomFrameViewAshWindowStateDelegate(wm::WindowState* window_state, 46 CustomFrameViewAshWindowStateDelegate(wm::WindowState* window_state,
46 CustomFrameViewAsh* custom_frame_view, 47 CustomFrameViewAsh* custom_frame_view,
47 bool enable_immersive) 48 bool enable_immersive)
48 : window_state_(nullptr) { 49 : window_state_(nullptr) {
49 // Add a window state observer to exit fullscreen properly in case 50 // Add a window state observer to exit fullscreen properly in case
50 // fullscreen is exited without going through 51 // fullscreen is exited without going through
51 // WindowState::ToggleFullscreen(). This is the case when exiting 52 // WindowState::ToggleFullscreen(). This is the case when exiting
52 // immersive fullscreen via the "Restore" window control. 53 // immersive fullscreen via the "Restore" window control.
53 // TODO(pkotwicz): This is a hack. Remove ASAP. http://crbug.com/319048 54 // TODO(pkotwicz): This is a hack. Remove ASAP. http://crbug.com/319048
54 window_state_ = window_state; 55 window_state_ = window_state;
55 window_state_->AddObserver(this); 56 window_state_->AddObserver(this);
56 window_state_->window()->AddObserver(this); 57 window_state_->window()->aura_window()->AddObserver(this);
57 58
58 if (!enable_immersive) 59 if (!enable_immersive)
59 return; 60 return;
60 61
61 immersive_fullscreen_controller_ = 62 immersive_fullscreen_controller_ =
62 WmShell::Get()->CreateImmersiveFullscreenController(); 63 WmShell::Get()->CreateImmersiveFullscreenController();
63 if (immersive_fullscreen_controller_) { 64 if (immersive_fullscreen_controller_) {
64 custom_frame_view->InitImmersiveFullscreenControllerForView( 65 custom_frame_view->InitImmersiveFullscreenControllerForView(
65 immersive_fullscreen_controller_.get()); 66 immersive_fullscreen_controller_.get());
66 } 67 }
67 } 68 }
68 ~CustomFrameViewAshWindowStateDelegate() override { 69 ~CustomFrameViewAshWindowStateDelegate() override {
69 if (window_state_) { 70 if (window_state_) {
70 window_state_->RemoveObserver(this); 71 window_state_->RemoveObserver(this);
71 window_state_->window()->RemoveObserver(this); 72 window_state_->window()->aura_window()->RemoveObserver(this);
72 } 73 }
73 } 74 }
74 75
75 private: 76 private:
76 // Overridden from wm::WindowStateDelegate: 77 // Overridden from wm::WindowStateDelegate:
77 bool ToggleFullscreen(wm::WindowState* window_state) override { 78 bool ToggleFullscreen(wm::WindowState* window_state) override {
78 bool enter_fullscreen = !window_state->IsFullscreen(); 79 bool enter_fullscreen = !window_state->IsFullscreen();
79 if (enter_fullscreen) 80 if (enter_fullscreen)
80 window_state_->window()->SetShowState(ui::SHOW_STATE_FULLSCREEN); 81 window_state_->window()->SetShowState(ui::SHOW_STATE_FULLSCREEN);
81 else 82 else
82 window_state->Restore(); 83 window_state->Restore();
83 if (immersive_fullscreen_controller_) { 84 if (immersive_fullscreen_controller_) {
84 immersive_fullscreen_controller_->SetEnabled( 85 immersive_fullscreen_controller_->SetEnabled(
85 ImmersiveFullscreenController::WINDOW_TYPE_OTHER, enter_fullscreen); 86 ImmersiveFullscreenController::WINDOW_TYPE_OTHER, enter_fullscreen);
86 } 87 }
87 return true; 88 return true;
88 } 89 }
89 // Overridden from WmWindowObserver: 90 // Overridden from aura::WindowObserver:
90 void OnWindowDestroying(WmWindow* window) override { 91 void OnWindowDestroying(aura::Window* window) override {
91 window_state_->RemoveObserver(this); 92 window_state_->RemoveObserver(this);
92 window->RemoveObserver(this); 93 window->RemoveObserver(this);
93 window_state_ = nullptr; 94 window_state_ = nullptr;
94 } 95 }
95 // Overridden from wm::WindowStateObserver: 96 // Overridden from wm::WindowStateObserver:
96 void OnPostWindowStateTypeChange(wm::WindowState* window_state, 97 void OnPostWindowStateTypeChange(wm::WindowState* window_state,
97 wm::WindowStateType old_type) override { 98 wm::WindowStateType old_type) override {
98 if (!window_state->IsFullscreen() && !window_state->IsMinimized() && 99 if (!window_state->IsFullscreen() && !window_state->IsMinimized() &&
99 immersive_fullscreen_controller_ && 100 immersive_fullscreen_controller_ &&
100 immersive_fullscreen_controller_->IsEnabled()) { 101 immersive_fullscreen_controller_->IsEnabled()) {
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 FrameCaptionButtonContainerView* 354 FrameCaptionButtonContainerView*
354 CustomFrameViewAsh::GetFrameCaptionButtonContainerViewForTest() { 355 CustomFrameViewAsh::GetFrameCaptionButtonContainerViewForTest() {
355 return header_view_->caption_button_container(); 356 return header_view_->caption_button_container();
356 } 357 }
357 358
358 int CustomFrameViewAsh::NonClientTopBorderHeight() const { 359 int CustomFrameViewAsh::NonClientTopBorderHeight() const {
359 return frame_->IsFullscreen() ? 0 : header_view_->GetPreferredHeight(); 360 return frame_->IsFullscreen() ? 0 : header_view_->GetPreferredHeight();
360 } 361 }
361 362
362 } // namespace ash 363 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/devtools/ash_devtools_dom_agent.cc ('k') | ash/common/shelf/shelf_window_watcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698