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

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

Issue 2277563002: Wires up immersive mode for chrome and mash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix crash Created 4 years, 4 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
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/ash_switches.h" 10 #include "ash/common/ash_switches.h"
(...skipping 26 matching lines...) Expand all
37 // CustomFrameViewAshWindowStateDelegate 37 // CustomFrameViewAshWindowStateDelegate
38 38
39 // 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
40 // immersive fullscreen if immersive fullscreen is enabled for non-browser 40 // immersive fullscreen if immersive fullscreen is enabled for non-browser
41 // windows. 41 // windows.
42 class CustomFrameViewAshWindowStateDelegate : public wm::WindowStateDelegate, 42 class CustomFrameViewAshWindowStateDelegate : public wm::WindowStateDelegate,
43 public wm::WindowStateObserver, 43 public wm::WindowStateObserver,
44 public WmWindowObserver { 44 public WmWindowObserver {
45 public: 45 public:
46 CustomFrameViewAshWindowStateDelegate(wm::WindowState* window_state, 46 CustomFrameViewAshWindowStateDelegate(wm::WindowState* window_state,
47 CustomFrameViewAsh* custom_frame_view) 47 CustomFrameViewAsh* custom_frame_view,
48 bool enable_immersive)
48 : window_state_(nullptr) { 49 : window_state_(nullptr) {
49 immersive_fullscreen_controller_ =
50 WmShell::Get()->CreateImmersiveFullscreenController();
51 if (immersive_fullscreen_controller_) {
52 custom_frame_view->InitImmersiveFullscreenControllerForView(
53 immersive_fullscreen_controller_.get());
54 }
55
56 // Add a window state observer to exit fullscreen properly in case 50 // Add a window state observer to exit fullscreen properly in case
57 // fullscreen is exited without going through 51 // fullscreen is exited without going through
58 // WindowState::ToggleFullscreen(). This is the case when exiting 52 // WindowState::ToggleFullscreen(). This is the case when exiting
59 // immersive fullscreen via the "Restore" window control. 53 // immersive fullscreen via the "Restore" window control.
60 // 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
61 window_state_ = window_state; 55 window_state_ = window_state;
62 window_state_->AddObserver(this); 56 window_state_->AddObserver(this);
63 window_state_->window()->AddObserver(this); 57 window_state_->window()->AddObserver(this);
58
59 if (!enable_immersive)
60 return;
61
62 immersive_fullscreen_controller_ =
63 WmShell::Get()->CreateImmersiveFullscreenController();
64 if (immersive_fullscreen_controller_) {
65 custom_frame_view->InitImmersiveFullscreenControllerForView(
66 immersive_fullscreen_controller_.get());
67 }
64 } 68 }
65 ~CustomFrameViewAshWindowStateDelegate() override { 69 ~CustomFrameViewAshWindowStateDelegate() override {
66 if (window_state_) { 70 if (window_state_) {
67 window_state_->RemoveObserver(this); 71 window_state_->RemoveObserver(this);
68 window_state_->window()->RemoveObserver(this); 72 window_state_->window()->RemoveObserver(this);
69 } 73 }
70 } 74 }
71 75
72 private: 76 private:
73 // Overridden from wm::WindowStateDelegate: 77 // Overridden from wm::WindowStateDelegate:
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 // can be handled by the client view. 176 // can be handled by the client view.
173 return header_view_->HitTestRect(rect); 177 return header_view_->HitTestRect(rect);
174 } 178 }
175 179
176 //////////////////////////////////////////////////////////////////////////////// 180 ////////////////////////////////////////////////////////////////////////////////
177 // CustomFrameViewAsh, public: 181 // CustomFrameViewAsh, public:
178 182
179 // static 183 // static
180 const char CustomFrameViewAsh::kViewClassName[] = "CustomFrameViewAsh"; 184 const char CustomFrameViewAsh::kViewClassName[] = "CustomFrameViewAsh";
181 185
182 CustomFrameViewAsh::CustomFrameViewAsh(views::Widget* frame) 186 CustomFrameViewAsh::CustomFrameViewAsh(
183 : frame_(frame), header_view_(new HeaderView(frame)) { 187 views::Widget* frame,
188 ImmersiveFullscreenControllerDelegate* immersive_delegate,
189 bool enable_immersive)
190 : frame_(frame),
191 header_view_(new HeaderView(frame)),
192 immersive_delegate_(immersive_delegate ? immersive_delegate
193 : header_view_) {
184 WmWindow* frame_window = WmLookup::Get()->GetWindowForWidget(frame); 194 WmWindow* frame_window = WmLookup::Get()->GetWindowForWidget(frame);
185 frame_window->InstallResizeHandleWindowTargeter(nullptr); 195 frame_window->InstallResizeHandleWindowTargeter(nullptr);
186 // |header_view_| is set as the non client view's overlay view so that it can 196 // |header_view_| is set as the non client view's overlay view so that it can
187 // overlay the web contents in immersive fullscreen. 197 // overlay the web contents in immersive fullscreen.
188 frame->non_client_view()->SetOverlayView(new OverlayView(header_view_)); 198 frame->non_client_view()->SetOverlayView(new OverlayView(header_view_));
189 199
190 // A delegate for a more complex way of fullscreening the window may already 200 // A delegate for a more complex way of fullscreening the window may already
191 // be set. This is the case for packaged apps. 201 // be set. This is the case for packaged apps.
192 wm::WindowState* window_state = frame_window->GetWindowState(); 202 wm::WindowState* window_state = frame_window->GetWindowState();
193 if (!window_state->HasDelegate()) { 203 if (!window_state->HasDelegate()) {
194 window_state->SetDelegate(std::unique_ptr<wm::WindowStateDelegate>( 204 window_state->SetDelegate(std::unique_ptr<wm::WindowStateDelegate>(
195 new CustomFrameViewAshWindowStateDelegate(window_state, this))); 205 new CustomFrameViewAshWindowStateDelegate(window_state, this,
206 enable_immersive)));
196 } 207 }
197 } 208 }
198 209
199 CustomFrameViewAsh::~CustomFrameViewAsh() {} 210 CustomFrameViewAsh::~CustomFrameViewAsh() {}
200 211
201 void CustomFrameViewAsh::InitImmersiveFullscreenControllerForView( 212 void CustomFrameViewAsh::InitImmersiveFullscreenControllerForView(
202 ImmersiveFullscreenController* immersive_fullscreen_controller) { 213 ImmersiveFullscreenController* immersive_fullscreen_controller) {
203 immersive_fullscreen_controller->Init(header_view_, frame_, header_view_); 214 immersive_fullscreen_controller->Init(immersive_delegate_, frame_,
215 header_view_);
204 } 216 }
205 217
206 void CustomFrameViewAsh::SetFrameColors(SkColor active_frame_color, 218 void CustomFrameViewAsh::SetFrameColors(SkColor active_frame_color,
207 SkColor inactive_frame_color) { 219 SkColor inactive_frame_color) {
208 header_view_->SetFrameColors(active_frame_color, inactive_frame_color); 220 header_view_->SetFrameColors(active_frame_color, inactive_frame_color);
209 } 221 }
210 222
211 //////////////////////////////////////////////////////////////////////////////// 223 ////////////////////////////////////////////////////////////////////////////////
212 // CustomFrameViewAsh, views::NonClientFrameView overrides: 224 // CustomFrameViewAsh, views::NonClientFrameView overrides:
213 225
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 views::NonClientFrameView::SchedulePaintInRect(r); 319 views::NonClientFrameView::SchedulePaintInRect(r);
308 } 320 }
309 } 321 }
310 322
311 void CustomFrameViewAsh::VisibilityChanged(views::View* starting_from, 323 void CustomFrameViewAsh::VisibilityChanged(views::View* starting_from,
312 bool is_visible) { 324 bool is_visible) {
313 if (is_visible) 325 if (is_visible)
314 header_view_->UpdateAvatarIcon(); 326 header_view_->UpdateAvatarIcon();
315 } 327 }
316 328
317 ////////////////////////////////////////////////////////////////////////////////
318 // CustomFrameViewAsh, views::ViewTargeterDelegate overrides:
319
320 views::View* CustomFrameViewAsh::GetHeaderView() { 329 views::View* CustomFrameViewAsh::GetHeaderView() {
321 return header_view_; 330 return header_view_;
322 } 331 }
323 332
324 const views::View* CustomFrameViewAsh::GetAvatarIconViewForTest() const { 333 const views::View* CustomFrameViewAsh::GetAvatarIconViewForTest() const {
325 return header_view_->avatar_icon(); 334 return header_view_->avatar_icon();
326 } 335 }
327 336
328 //////////////////////////////////////////////////////////////////////////////// 337 ////////////////////////////////////////////////////////////////////////////////
329 // CustomFrameViewAsh, private: 338 // CustomFrameViewAsh, private:
(...skipping 10 matching lines...) Expand all
340 FrameCaptionButtonContainerView* 349 FrameCaptionButtonContainerView*
341 CustomFrameViewAsh::GetFrameCaptionButtonContainerViewForTest() { 350 CustomFrameViewAsh::GetFrameCaptionButtonContainerViewForTest() {
342 return header_view_->caption_button_container(); 351 return header_view_->caption_button_container();
343 } 352 }
344 353
345 int CustomFrameViewAsh::NonClientTopBorderHeight() const { 354 int CustomFrameViewAsh::NonClientTopBorderHeight() const {
346 return frame_->IsFullscreen() ? 0 : header_view_->GetPreferredHeight(); 355 return frame_->IsFullscreen() ? 0 : header_view_->GetPreferredHeight();
347 } 356 }
348 357
349 } // namespace ash 358 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698