OLD | NEW |
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/frame/custom_frame_view_ash.h" | 5 #include "ash/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/frame/caption_buttons/frame_caption_button_container_view.h" | 10 #include "ash/frame/caption_buttons/frame_caption_button_container_view.h" |
11 #include "ash/frame/frame_border_hit_test.h" | 11 #include "ash/frame/frame_border_hit_test.h" |
12 #include "ash/frame/header_view.h" | 12 #include "ash/frame/header_view.h" |
13 #include "ash/shared/immersive_fullscreen_controller.h" | 13 #include "ash/shared/immersive_fullscreen_controller.h" |
14 #include "ash/shared/immersive_fullscreen_controller_delegate.h" | 14 #include "ash/shared/immersive_fullscreen_controller_delegate.h" |
15 #include "ash/shell_port.h" | 15 #include "ash/shell_port.h" |
| 16 #include "ash/wm/resize_handle_window_targeter.h" |
16 #include "ash/wm/window_state.h" | 17 #include "ash/wm/window_state.h" |
17 #include "ash/wm/window_state_delegate.h" | 18 #include "ash/wm/window_state_delegate.h" |
18 #include "ash/wm/window_state_observer.h" | 19 #include "ash/wm/window_state_observer.h" |
19 #include "ash/wm_window.h" | 20 #include "ash/wm/window_util.h" |
20 #include "base/memory/ptr_util.h" | 21 #include "base/memory/ptr_util.h" |
21 #include "ui/aura/client/aura_constants.h" | 22 #include "ui/aura/client/aura_constants.h" |
22 #include "ui/aura/window.h" | 23 #include "ui/aura/window.h" |
23 #include "ui/aura/window_observer.h" | 24 #include "ui/aura/window_observer.h" |
24 #include "ui/gfx/geometry/rect.h" | 25 #include "ui/gfx/geometry/rect.h" |
25 #include "ui/gfx/geometry/rect_conversions.h" | 26 #include "ui/gfx/geometry/rect_conversions.h" |
26 #include "ui/gfx/geometry/size.h" | 27 #include "ui/gfx/geometry/size.h" |
27 #include "ui/gfx/image/image_skia.h" | 28 #include "ui/gfx/image/image_skia.h" |
28 #include "ui/views/view.h" | 29 #include "ui/views/view.h" |
29 #include "ui/views/view_targeter.h" | 30 #include "ui/views/view_targeter.h" |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 views::Widget* frame, | 255 views::Widget* frame, |
255 ImmersiveFullscreenControllerDelegate* immersive_delegate, | 256 ImmersiveFullscreenControllerDelegate* immersive_delegate, |
256 bool enable_immersive, | 257 bool enable_immersive, |
257 mojom::WindowStyle window_style) | 258 mojom::WindowStyle window_style) |
258 : frame_(frame), | 259 : frame_(frame), |
259 header_view_(new HeaderView(frame, window_style)), | 260 header_view_(new HeaderView(frame, window_style)), |
260 overlay_view_(new OverlayView(header_view_)), | 261 overlay_view_(new OverlayView(header_view_)), |
261 immersive_delegate_(immersive_delegate ? immersive_delegate | 262 immersive_delegate_(immersive_delegate ? immersive_delegate |
262 : header_view_), | 263 : header_view_), |
263 avatar_observer_(base::MakeUnique<AvatarObserver>(frame_, header_view_)) { | 264 avatar_observer_(base::MakeUnique<AvatarObserver>(frame_, header_view_)) { |
264 WmWindow* frame_window = WmWindow::Get(frame->GetNativeWindow()); | 265 aura::Window* frame_window = frame->GetNativeWindow(); |
265 frame_window->InstallResizeHandleWindowTargeter(nullptr); | 266 wm::InstallResizeHandleWindowTargeterForWindow(frame_window, nullptr); |
266 // |header_view_| is set as the non client view's overlay view so that it can | 267 // |header_view_| is set as the non client view's overlay view so that it can |
267 // overlay the web contents in immersive fullscreen. | 268 // overlay the web contents in immersive fullscreen. |
268 frame->non_client_view()->SetOverlayView(overlay_view_); | 269 frame->non_client_view()->SetOverlayView(overlay_view_); |
269 frame_window->aura_window()->SetProperty( | 270 frame_window->SetProperty(aura::client::kTopViewColor, |
270 aura::client::kTopViewColor, header_view_->GetInactiveFrameColor()); | 271 header_view_->GetInactiveFrameColor()); |
271 | 272 |
272 // A delegate for a more complex way of fullscreening the window may already | 273 // A delegate for a more complex way of fullscreening the window may already |
273 // be set. This is the case for packaged apps. | 274 // be set. This is the case for packaged apps. |
274 wm::WindowState* window_state = frame_window->GetWindowState(); | 275 wm::WindowState* window_state = wm::GetWindowState(frame_window); |
275 if (!window_state->HasDelegate()) { | 276 if (!window_state->HasDelegate()) { |
276 window_state->SetDelegate(std::unique_ptr<wm::WindowStateDelegate>( | 277 window_state->SetDelegate(std::unique_ptr<wm::WindowStateDelegate>( |
277 new CustomFrameViewAshWindowStateDelegate(window_state, this, | 278 new CustomFrameViewAshWindowStateDelegate(window_state, this, |
278 enable_immersive))); | 279 enable_immersive))); |
279 } | 280 } |
280 } | 281 } |
281 | 282 |
282 CustomFrameViewAsh::~CustomFrameViewAsh() {} | 283 CustomFrameViewAsh::~CustomFrameViewAsh() {} |
283 | 284 |
284 void CustomFrameViewAsh::InitImmersiveFullscreenControllerForView( | 285 void CustomFrameViewAsh::InitImmersiveFullscreenControllerForView( |
285 ImmersiveFullscreenController* immersive_fullscreen_controller) { | 286 ImmersiveFullscreenController* immersive_fullscreen_controller) { |
286 immersive_fullscreen_controller->Init(immersive_delegate_, frame_, | 287 immersive_fullscreen_controller->Init(immersive_delegate_, frame_, |
287 header_view_); | 288 header_view_); |
288 } | 289 } |
289 | 290 |
290 void CustomFrameViewAsh::SetFrameColors(SkColor active_frame_color, | 291 void CustomFrameViewAsh::SetFrameColors(SkColor active_frame_color, |
291 SkColor inactive_frame_color) { | 292 SkColor inactive_frame_color) { |
292 header_view_->SetFrameColors(active_frame_color, inactive_frame_color); | 293 header_view_->SetFrameColors(active_frame_color, inactive_frame_color); |
293 WmWindow* frame_window = WmWindow::Get(frame_->GetNativeWindow()); | 294 aura::Window* frame_window = frame_->GetNativeWindow(); |
294 frame_window->aura_window()->SetProperty( | 295 frame_window->SetProperty(aura::client::kTopViewColor, |
295 aura::client::kTopViewColor, header_view_->GetInactiveFrameColor()); | 296 header_view_->GetInactiveFrameColor()); |
296 } | 297 } |
297 | 298 |
298 void CustomFrameViewAsh::SetHeaderHeight(base::Optional<int> height) { | 299 void CustomFrameViewAsh::SetHeaderHeight(base::Optional<int> height) { |
299 overlay_view_->SetHeaderHeight(height); | 300 overlay_view_->SetHeaderHeight(height); |
300 } | 301 } |
301 | 302 |
302 views::View* CustomFrameViewAsh::GetHeaderView() { | 303 views::View* CustomFrameViewAsh::GetHeaderView() { |
303 return header_view_; | 304 return header_view_; |
304 } | 305 } |
305 | 306 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 gfx::Size CustomFrameViewAsh::CalculatePreferredSize() const { | 355 gfx::Size CustomFrameViewAsh::CalculatePreferredSize() const { |
355 gfx::Size pref = frame_->client_view()->GetPreferredSize(); | 356 gfx::Size pref = frame_->client_view()->GetPreferredSize(); |
356 gfx::Rect bounds(0, 0, pref.width(), pref.height()); | 357 gfx::Rect bounds(0, 0, pref.width(), pref.height()); |
357 return frame_->non_client_view() | 358 return frame_->non_client_view() |
358 ->GetWindowBoundsForClientBounds(bounds) | 359 ->GetWindowBoundsForClientBounds(bounds) |
359 .size(); | 360 .size(); |
360 } | 361 } |
361 | 362 |
362 void CustomFrameViewAsh::Layout() { | 363 void CustomFrameViewAsh::Layout() { |
363 views::NonClientFrameView::Layout(); | 364 views::NonClientFrameView::Layout(); |
364 WmWindow* frame_window = WmWindow::Get(frame_->GetNativeWindow()); | 365 aura::Window* frame_window = frame_->GetNativeWindow(); |
365 frame_window->aura_window()->SetProperty(aura::client::kTopViewInset, | 366 frame_window->SetProperty(aura::client::kTopViewInset, |
366 NonClientTopBorderHeight()); | 367 NonClientTopBorderHeight()); |
367 } | 368 } |
368 | 369 |
369 const char* CustomFrameViewAsh::GetClassName() const { | 370 const char* CustomFrameViewAsh::GetClassName() const { |
370 return kViewClassName; | 371 return kViewClassName; |
371 } | 372 } |
372 | 373 |
373 gfx::Size CustomFrameViewAsh::GetMinimumSize() const { | 374 gfx::Size CustomFrameViewAsh::GetMinimumSize() const { |
374 if (use_empty_minimum_size_for_test_) | 375 if (use_empty_minimum_size_for_test_) |
375 return gfx::Size(); | 376 return gfx::Size(); |
376 | 377 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 FrameCaptionButtonContainerView* | 426 FrameCaptionButtonContainerView* |
426 CustomFrameViewAsh::GetFrameCaptionButtonContainerViewForTest() { | 427 CustomFrameViewAsh::GetFrameCaptionButtonContainerViewForTest() { |
427 return header_view_->caption_button_container(); | 428 return header_view_->caption_button_container(); |
428 } | 429 } |
429 | 430 |
430 int CustomFrameViewAsh::NonClientTopBorderHeight() const { | 431 int CustomFrameViewAsh::NonClientTopBorderHeight() const { |
431 return frame_->IsFullscreen() ? 0 : header_view_->GetPreferredHeight(); | 432 return frame_->IsFullscreen() ? 0 : header_view_->GetPreferredHeight(); |
432 } | 433 } |
433 | 434 |
434 } // namespace ash | 435 } // namespace ash |
OLD | NEW |