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

Side by Side Diff: chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.cc

Issue 83343006: Enable immersive fullscreen for hosted apps part 2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 | Annotate | Revision Log
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 "chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.h" 5 #include "chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.h"
6 6
7 #include "ash/ash_switches.h" 7 #include "ash/ash_switches.h"
8 #include "ash/wm/caption_buttons/frame_caption_button_container_view.h" 8 #include "ash/wm/caption_buttons/frame_caption_button_container_view.h"
9 #include "ash/wm/frame_border_hit_test_controller.h" 9 #include "ash/wm/frame_border_hit_test_controller.h"
10 #include "ash/wm/header_painter.h" 10 #include "ash/wm/header_painter.h"
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 152
153 void BrowserNonClientFrameViewAsh::UpdateThrobber(bool running) { 153 void BrowserNonClientFrameViewAsh::UpdateThrobber(bool running) {
154 if (window_icon_) 154 if (window_icon_)
155 window_icon_->Update(); 155 window_icon_->Update();
156 } 156 }
157 157
158 /////////////////////////////////////////////////////////////////////////////// 158 ///////////////////////////////////////////////////////////////////////////////
159 // views::NonClientFrameView overrides: 159 // views::NonClientFrameView overrides:
160 160
161 gfx::Rect BrowserNonClientFrameViewAsh::GetBoundsForClientView() const { 161 gfx::Rect BrowserNonClientFrameViewAsh::GetBoundsForClientView() const {
162 int top_height = NonClientTopBorderHeight(); 162 // The ClientView must be flush with the top edge of the widget so that the
163 return ash::HeaderPainter::GetBoundsForClientView(top_height, bounds()); 163 // web contents can take up the entire screen in immersive fullscreen (with
164 // or without the top-of-window views revealed). When in immersive fullscreen
165 // and the top-of-window views are revealed, the TopContainerView paints the
166 // window header by redirecting paints from its background to
167 // BrowserNonClientFrameViewAsh.
168 return ash::HeaderPainter::GetBoundsForClientView(0, bounds());
164 } 169 }
165 170
166 gfx::Rect BrowserNonClientFrameViewAsh::GetWindowBoundsForClientBounds( 171 gfx::Rect BrowserNonClientFrameViewAsh::GetWindowBoundsForClientBounds(
167 const gfx::Rect& client_bounds) const { 172 const gfx::Rect& client_bounds) const {
168 int top_height = NonClientTopBorderHeight(); 173 return ash::HeaderPainter::GetWindowBoundsForClientBounds(0, client_bounds);
169 return ash::HeaderPainter::GetWindowBoundsForClientBounds(top_height,
170 client_bounds);
171 } 174 }
172 175
173 int BrowserNonClientFrameViewAsh::NonClientHitTest(const gfx::Point& point) { 176 int BrowserNonClientFrameViewAsh::NonClientHitTest(const gfx::Point& point) {
174 int hit_test = ash::FrameBorderHitTestController::NonClientHitTest(this, 177 int hit_test = ash::FrameBorderHitTestController::NonClientHitTest(this,
175 header_painter_.get(), point); 178 header_painter_.get(), point);
176 179
177 // See if the point is actually within the avatar menu button or within 180 // See if the point is actually within the avatar menu button or within
178 // the avatar label. 181 // the avatar label.
179 if (hit_test == HTCAPTION && ((avatar_button() && 182 if (hit_test == HTCAPTION && ((avatar_button() &&
180 avatar_button()->GetMirroredBounds().Contains(point)) || 183 avatar_button()->GetMirroredBounds().Contains(point)) ||
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 theme_frame_overlay_image_id); 260 theme_frame_overlay_image_id);
258 if (browser_view()->ShouldShowWindowTitle()) 261 if (browser_view()->ShouldShowWindowTitle())
259 header_painter_->PaintTitleBar(canvas, BrowserFrame::GetTitleFont()); 262 header_painter_->PaintTitleBar(canvas, BrowserFrame::GetTitleFont());
260 if (browser_view()->IsToolbarVisible()) 263 if (browser_view()->IsToolbarVisible())
261 PaintToolbarBackground(canvas); 264 PaintToolbarBackground(canvas);
262 else 265 else
263 PaintContentEdge(canvas); 266 PaintContentEdge(canvas);
264 } 267 }
265 268
266 void BrowserNonClientFrameViewAsh::Layout() { 269 void BrowserNonClientFrameViewAsh::Layout() {
267 header_painter_->LayoutHeader(UseShortHeader());
268 int header_height = 0; 270 int header_height = 0;
269 if (browser_view()->IsTabStripVisible()) { 271 if (browser_view()->IsTabStripVisible()) {
270 header_height = GetTopInset() + 272 header_height = GetTopInset() +
271 browser_view()->GetTabStripHeight(); 273 browser_view()->GetTabStripHeight();
272 } else if (browser_view()->IsToolbarVisible()) { 274 } else if (browser_view()->IsToolbarVisible()) {
273 // Set the header's height so that it overlaps with the toolbar because the 275 // Set the header's height so that it overlaps with the toolbar because the
274 // top few pixels of the toolbar are not opaque. 276 // top few pixels of the toolbar are not opaque.
275 gfx::Point toolbar_origin(browser_view()->GetToolbarBounds().origin()); 277 header_height = GetTopInset() + kFrameShadowThickness * 2;
276 View::ConvertPointToTarget(browser_view(), this, &toolbar_origin);
277 header_height = toolbar_origin.y() + kFrameShadowThickness * 2;
278 } else { 278 } else {
279 header_height = NonClientTopBorderHeight(); 279 header_height = GetTopInset();
280 } 280 }
281 header_painter_->set_header_height(header_height); 281 header_painter_->set_header_height(header_height);
282 header_painter_->LayoutHeader(UseShortHeader());
282 if (avatar_button()) 283 if (avatar_button())
283 LayoutAvatar(); 284 LayoutAvatar();
284 BrowserNonClientFrameView::Layout(); 285 BrowserNonClientFrameView::Layout();
285 } 286 }
286 287
287 const char* BrowserNonClientFrameViewAsh::GetClassName() const { 288 const char* BrowserNonClientFrameViewAsh::GetClassName() const {
288 return kViewClassName; 289 return kViewClassName;
289 } 290 }
290 291
291 bool BrowserNonClientFrameViewAsh::HitTestRect(const gfx::Rect& rect) const { 292 bool BrowserNonClientFrameViewAsh::HitTestRect(const gfx::Rect& rect) const {
292 if (!views::View::HitTestRect(rect)) { 293 if (!views::View::HitTestRect(rect)) {
293 // |rect| is outside BrowserNonClientFrameViewAsh's bounds. 294 // |rect| is outside BrowserNonClientFrameViewAsh's bounds.
294 return false; 295 return false;
295 } 296 }
296 // If the rect is outside the bounds of the client area, claim it.
297 gfx::RectF rect_in_client_view_coords_f(rect);
298 View::ConvertRectToTarget(this, frame()->client_view(),
299 &rect_in_client_view_coords_f);
300 gfx::Rect rect_in_client_view_coords = gfx::ToEnclosingRect(
301 rect_in_client_view_coords_f);
302 if (!frame()->client_view()->HitTestRect(rect_in_client_view_coords))
303 return true;
304 297
305 // Otherwise, claim |rect| only if it is above the bottom of the tabstrip in
306 // a non-tab portion.
307 TabStrip* tabstrip = browser_view()->tabstrip(); 298 TabStrip* tabstrip = browser_view()->tabstrip();
308 if (!tabstrip || !browser_view()->IsTabStripVisible()) 299 if (tabstrip && browser_view()->IsTabStripVisible()) {
309 return false; 300 // Claim |rect| only if it is above the bottom of the tabstrip in a non-tab
301 // portion.
302 gfx::RectF rect_in_tabstrip_coords_f(rect);
303 View::ConvertRectToTarget(this, tabstrip, &rect_in_tabstrip_coords_f);
304 gfx::Rect rect_in_tabstrip_coords = gfx::ToEnclosingRect(
305 rect_in_tabstrip_coords_f);
310 306
311 gfx::RectF rect_in_tabstrip_coords_f(rect); 307 if (rect_in_tabstrip_coords.y() > tabstrip->height())
312 View::ConvertRectToTarget(this, tabstrip, &rect_in_tabstrip_coords_f); 308 return false;
313 gfx::Rect rect_in_tabstrip_coords = gfx::ToEnclosingRect(
314 rect_in_tabstrip_coords_f);
315 309
316 if (rect_in_tabstrip_coords.y() > tabstrip->GetLocalBounds().bottom()) { 310 return !tabstrip->HitTestRect(rect_in_tabstrip_coords) ||
317 // |rect| is below the tabstrip. 311 tabstrip->IsRectInWindowCaption(rect_in_tabstrip_coords);
318 return false;
319 } 312 }
320 313
321 if (tabstrip->HitTestRect(rect_in_tabstrip_coords)) { 314 // Claim |rect| if it is above the top of the topmost view in the client area.
322 // Claim |rect| if it is in a non-tab portion of the tabstrip. 315 return rect.y() < GetTopInset();
323 return tabstrip->IsRectInWindowCaption(rect_in_tabstrip_coords);
324 }
325
326 // We claim |rect| because it is above the bottom of the tabstrip, but
327 // not in the tabstrip. In particular, the window controls are right of
328 // the tabstrip.
329 return true;
330 } 316 }
331 317
332 void BrowserNonClientFrameViewAsh::GetAccessibleState( 318 void BrowserNonClientFrameViewAsh::GetAccessibleState(
333 ui::AccessibleViewState* state) { 319 ui::AccessibleViewState* state) {
334 state->role = ui::AccessibilityTypes::ROLE_TITLEBAR; 320 state->role = ui::AccessibilityTypes::ROLE_TITLEBAR;
335 } 321 }
336 322
337 gfx::Size BrowserNonClientFrameViewAsh::GetMinimumSize() { 323 gfx::Size BrowserNonClientFrameViewAsh::GetMinimumSize() {
338 gfx::Size min_client_view_size(frame()->client_view()->GetMinimumSize()); 324 gfx::Size min_client_view_size(frame()->client_view()->GetMinimumSize());
339 int min_width = std::max(header_painter_->GetMinimumHeaderWidth(), 325 int min_width = std::max(header_painter_->GetMinimumHeaderWidth(),
340 min_client_view_size.width()); 326 min_client_view_size.width());
341 if (browser_view()->IsTabStripVisible()) { 327 if (browser_view()->IsTabStripVisible()) {
342 // Ensure that the minimum width is enough to hold a minimum width tab strip 328 // Ensure that the minimum width is enough to hold a minimum width tab strip
343 // at its usual insets. 329 // at its usual insets.
344 int min_tabstrip_width = 330 int min_tabstrip_width =
345 browser_view()->tabstrip()->GetMinimumSize().width(); 331 browser_view()->tabstrip()->GetMinimumSize().width();
346 min_width = std::max(min_width, 332 min_width = std::max(min_width,
347 min_tabstrip_width + GetTabStripLeftInset() + GetTabStripRightInset()); 333 min_tabstrip_width + GetTabStripLeftInset() + GetTabStripRightInset());
348 } 334 }
349 return gfx::Size(min_width, 335 return gfx::Size(min_width, min_client_view_size.height());
350 NonClientTopBorderHeight() + min_client_view_size.height());
351 } 336 }
352 337
353 void BrowserNonClientFrameViewAsh::OnThemeChanged() { 338 void BrowserNonClientFrameViewAsh::OnThemeChanged() {
354 BrowserNonClientFrameView::OnThemeChanged(); 339 BrowserNonClientFrameView::OnThemeChanged();
355 header_painter_->OnThemeChanged(); 340 header_painter_->OnThemeChanged();
356 } 341 }
357 342
358 /////////////////////////////////////////////////////////////////////////////// 343 ///////////////////////////////////////////////////////////////////////////////
359 // chrome::TabIconViewModel overrides: 344 // chrome::TabIconViewModel overrides:
360 345
(...skipping 18 matching lines...) Expand all
379 int BrowserNonClientFrameViewAsh::GetTabStripLeftInset() const { 364 int BrowserNonClientFrameViewAsh::GetTabStripLeftInset() const {
380 return avatar_button() ? kAvatarSideSpacing + 365 return avatar_button() ? kAvatarSideSpacing +
381 browser_view()->GetOTRAvatarIcon().width() + kAvatarSideSpacing : 366 browser_view()->GetOTRAvatarIcon().width() + kAvatarSideSpacing :
382 kTabstripLeftSpacing; 367 kTabstripLeftSpacing;
383 } 368 }
384 369
385 int BrowserNonClientFrameViewAsh::GetTabStripRightInset() const { 370 int BrowserNonClientFrameViewAsh::GetTabStripRightInset() const {
386 return header_painter_->GetRightInset() + kTabstripRightSpacing; 371 return header_painter_->GetRightInset() + kTabstripRightSpacing;
387 } 372 }
388 373
389 int BrowserNonClientFrameViewAsh::NonClientTopBorderHeight() const {
390 if (!ShouldPaint() || browser_view()->IsTabStripVisible())
391 return 0;
392
393 int caption_buttons_bottom = caption_button_container_->bounds().bottom();
394 if (browser_view()->IsToolbarVisible())
395 return caption_buttons_bottom - kContentShadowHeight;
396 return caption_buttons_bottom + kClientEdgeThickness;
397 }
398
399 bool BrowserNonClientFrameViewAsh::UseShortHeader() const { 374 bool BrowserNonClientFrameViewAsh::UseShortHeader() const {
400 // Restored tabbed browser windows use the tall header. All other windows use 375 // Restored tabbed browser windows use the tall header. All other windows use
401 // the short header. 376 // the short header.
402 return frame()->IsMaximized() || 377 return frame()->IsMaximized() ||
403 frame()->IsFullscreen() || 378 frame()->IsFullscreen() ||
404 !browser_view()->IsBrowserTypeNormal(); 379 !browser_view()->IsBrowserTypeNormal();
405 } 380 }
406 381
407 bool BrowserNonClientFrameViewAsh::UseImmersiveLightbarHeaderStyle() const { 382 bool BrowserNonClientFrameViewAsh::UseImmersiveLightbarHeaderStyle() const {
408 ImmersiveModeController* immersive_controller = 383 ImmersiveModeController* immersive_controller =
(...skipping 28 matching lines...) Expand all
437 avatar_button()->SetVisible(avatar_visible); 412 avatar_button()->SetVisible(avatar_visible);
438 } 413 }
439 414
440 bool BrowserNonClientFrameViewAsh::ShouldPaint() const { 415 bool BrowserNonClientFrameViewAsh::ShouldPaint() const {
441 if (!frame()->IsFullscreen()) 416 if (!frame()->IsFullscreen())
442 return true; 417 return true;
443 418
444 // We need to paint when in immersive fullscreen and either: 419 // We need to paint when in immersive fullscreen and either:
445 // - The top-of-window views are revealed. 420 // - The top-of-window views are revealed.
446 // - The lightbar style tabstrip is visible. 421 // - The lightbar style tabstrip is visible.
447 // Because immersive fullscreen is only supported for tabbed browser windows, 422 ImmersiveModeController* immersive_mode_controller =
448 // checking whether the tab strip is visible is sufficient. 423 browser_view()->immersive_mode_controller();
449 return browser_view()->IsTabStripVisible(); 424 return immersive_mode_controller->IsEnabled() &&
425 (immersive_mode_controller->IsRevealed() ||
426 UseImmersiveLightbarHeaderStyle());
450 } 427 }
451 428
452 void BrowserNonClientFrameViewAsh::PaintImmersiveLightbarStyleHeader( 429 void BrowserNonClientFrameViewAsh::PaintImmersiveLightbarStyleHeader(
453 gfx::Canvas* canvas) { 430 gfx::Canvas* canvas) {
454 // The light bar header is not themed because theming it does not look good. 431 // The light bar header is not themed because theming it does not look good.
455 gfx::ImageSkia* frame_image = GetThemeProvider()->GetImageSkiaNamed( 432 gfx::ImageSkia* frame_image = GetThemeProvider()->GetImageSkiaNamed(
456 IDR_AURA_WINDOW_HEADER_BASE_MINIMAL); 433 IDR_AURA_WINDOW_HEADER_BASE_MINIMAL);
457 canvas->TileImageInt(*frame_image, 0, 0, width(), frame_image->height()); 434 canvas->TileImageInt(*frame_image, 0, 0, width(), frame_image->height());
458 } 435 }
459 436
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 int BrowserNonClientFrameViewAsh::GetThemeFrameOverlayImageId() const { 540 int BrowserNonClientFrameViewAsh::GetThemeFrameOverlayImageId() const {
564 ui::ThemeProvider* tp = GetThemeProvider(); 541 ui::ThemeProvider* tp = GetThemeProvider();
565 if (tp->HasCustomImage(IDR_THEME_FRAME_OVERLAY) && 542 if (tp->HasCustomImage(IDR_THEME_FRAME_OVERLAY) &&
566 browser_view()->IsBrowserTypeNormal() && 543 browser_view()->IsBrowserTypeNormal() &&
567 !browser_view()->IsOffTheRecord()) { 544 !browser_view()->IsOffTheRecord()) {
568 return ShouldPaintAsActive() ? 545 return ShouldPaintAsActive() ?
569 IDR_THEME_FRAME_OVERLAY : IDR_THEME_FRAME_OVERLAY_INACTIVE; 546 IDR_THEME_FRAME_OVERLAY : IDR_THEME_FRAME_OVERLAY_INACTIVE;
570 } 547 }
571 return 0; 548 return 0;
572 } 549 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698