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

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

Issue 148003003: Use white header for app windows part #2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | 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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 236
237 void BrowserNonClientFrameViewAsh::OnPaint(gfx::Canvas* canvas) { 237 void BrowserNonClientFrameViewAsh::OnPaint(gfx::Canvas* canvas) {
238 if (!ShouldPaint()) 238 if (!ShouldPaint())
239 return; 239 return;
240 240
241 if (UseImmersiveLightbarHeaderStyle()) { 241 if (UseImmersiveLightbarHeaderStyle()) {
242 PaintImmersiveLightbarStyleHeader(canvas); 242 PaintImmersiveLightbarStyleHeader(canvas);
243 return; 243 return;
244 } 244 }
245 245
246 caption_button_container_->SetPaintAsActive(ShouldPaintAsActive());
247
246 // The primary header image changes based on window activation state and 248 // The primary header image changes based on window activation state and
247 // theme, so we look it up for each paint. 249 // theme, so we look it up for each paint.
248 int theme_frame_image_id = GetThemeFrameImageId(); 250 int theme_frame_image_id = 0;
249 int theme_frame_overlay_image_id = GetThemeFrameOverlayImageId(); 251 int theme_frame_overlay_image_id = 0;
252 GetFrameImageIds(&theme_frame_image_id, &theme_frame_overlay_image_id);
250 253
251 ui::ThemeProvider* theme_provider = GetThemeProvider(); 254 ash::HeaderPainter::Mode header_mode = ShouldPaintAsActive() ?
252 if (!theme_provider->HasCustomImage(theme_frame_image_id) && 255 ash::HeaderPainter::MODE_ACTIVE : ash::HeaderPainter::MODE_INACTIVE;
253 (theme_frame_overlay_image_id == 0 ||
254 !theme_provider->HasCustomImage(theme_frame_overlay_image_id))) {
255 if (frame()->IsMaximized() || frame()->IsFullscreen())
256 theme_frame_image_id = IDR_AURA_WINDOW_HEADER_BASE_MINIMAL;
257 }
258 header_painter_->PaintHeader( 256 header_painter_->PaintHeader(
259 canvas, 257 canvas,
258 header_mode,
260 theme_frame_image_id, 259 theme_frame_image_id,
261 theme_frame_overlay_image_id); 260 theme_frame_overlay_image_id);
262 if (browser_view()->ShouldShowWindowTitle()) 261 if (browser_view()->ShouldShowWindowTitle())
263 header_painter_->PaintTitleBar(canvas, BrowserFrame::GetTitleFontList()); 262 header_painter_->PaintTitleBar(canvas, BrowserFrame::GetTitleFontList());
264 if (browser_view()->IsToolbarVisible()) 263 if (browser_view()->IsToolbarVisible())
265 PaintToolbarBackground(canvas); 264 PaintToolbarBackground(canvas);
266 else 265 else
267 PaintContentEdge(canvas); 266 PaintContentEdge(canvas);
268 } 267 }
269 268
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 browser_view()->immersive_mode_controller(); 428 browser_view()->immersive_mode_controller();
430 return immersive_mode_controller->IsEnabled() && 429 return immersive_mode_controller->IsEnabled() &&
431 (immersive_mode_controller->IsRevealed() || 430 (immersive_mode_controller->IsRevealed() ||
432 UseImmersiveLightbarHeaderStyle()); 431 UseImmersiveLightbarHeaderStyle());
433 } 432 }
434 433
435 void BrowserNonClientFrameViewAsh::PaintImmersiveLightbarStyleHeader( 434 void BrowserNonClientFrameViewAsh::PaintImmersiveLightbarStyleHeader(
436 gfx::Canvas* canvas) { 435 gfx::Canvas* canvas) {
437 // The light bar header is not themed because theming it does not look good. 436 // The light bar header is not themed because theming it does not look good.
438 gfx::ImageSkia* frame_image = GetThemeProvider()->GetImageSkiaNamed( 437 gfx::ImageSkia* frame_image = GetThemeProvider()->GetImageSkiaNamed(
439 IDR_AURA_WINDOW_HEADER_BASE_MINIMAL); 438 IDR_AURA_BROWSER_WINDOW_HEADER_BASE_MAXIMIZED);
440 canvas->TileImageInt(*frame_image, 0, 0, width(), frame_image->height()); 439 canvas->TileImageInt(*frame_image, 0, 0, width(), frame_image->height());
441 } 440 }
442 441
443 void BrowserNonClientFrameViewAsh::PaintToolbarBackground(gfx::Canvas* canvas) { 442 void BrowserNonClientFrameViewAsh::PaintToolbarBackground(gfx::Canvas* canvas) {
444 gfx::Rect toolbar_bounds(browser_view()->GetToolbarBounds()); 443 gfx::Rect toolbar_bounds(browser_view()->GetToolbarBounds());
445 if (toolbar_bounds.IsEmpty()) 444 if (toolbar_bounds.IsEmpty())
446 return; 445 return;
447 gfx::Point toolbar_origin(toolbar_bounds.origin()); 446 gfx::Point toolbar_origin(toolbar_bounds.origin());
448 View::ConvertPointToTarget(browser_view(), this, &toolbar_origin); 447 View::ConvertPointToTarget(browser_view(), this, &toolbar_origin);
449 toolbar_bounds.set_origin(toolbar_origin); 448 toolbar_bounds.set_origin(toolbar_origin);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 gfx::Rect(x + kClientEdgeThickness, 508 gfx::Rect(x + kClientEdgeThickness,
510 toolbar_bounds.bottom() - kClientEdgeThickness, 509 toolbar_bounds.bottom() - kClientEdgeThickness,
511 w - (2 * kClientEdgeThickness), 510 w - (2 * kClientEdgeThickness),
512 kClientEdgeThickness), 511 kClientEdgeThickness),
513 ThemeProperties::GetDefaultColor( 512 ThemeProperties::GetDefaultColor(
514 ThemeProperties::COLOR_TOOLBAR_SEPARATOR)); 513 ThemeProperties::COLOR_TOOLBAR_SEPARATOR));
515 } 514 }
516 515
517 void BrowserNonClientFrameViewAsh::PaintContentEdge(gfx::Canvas* canvas) { 516 void BrowserNonClientFrameViewAsh::PaintContentEdge(gfx::Canvas* canvas) {
518 if (UsePackagedAppHeaderStyle()) { 517 if (UsePackagedAppHeaderStyle()) {
519 header_painter_->PaintHeaderContentSeparator(canvas); 518 ash::HeaderPainter::Mode header_mode = ShouldPaintAsActive() ?
519 ash::HeaderPainter::MODE_ACTIVE : ash::HeaderPainter::MODE_INACTIVE;
520 header_painter_->PaintHeaderContentSeparator(canvas, header_mode);
520 } else { 521 } else {
521 canvas->FillRect(gfx::Rect(0, caption_button_container_->bounds().bottom(), 522 canvas->FillRect(gfx::Rect(0, caption_button_container_->bounds().bottom(),
522 width(), kClientEdgeThickness), 523 width(), kClientEdgeThickness),
523 ThemeProperties::GetDefaultColor( 524 ThemeProperties::GetDefaultColor(
524 ThemeProperties::COLOR_TOOLBAR_SEPARATOR)); 525 ThemeProperties::COLOR_TOOLBAR_SEPARATOR));
525 } 526 }
526 } 527 }
527 528
528 int BrowserNonClientFrameViewAsh::GetThemeFrameImageId() const { 529 void BrowserNonClientFrameViewAsh::GetFrameImageIds(
James Cook 2014/02/03 18:46:35 This function is long and complex. I suggest break
530 int* frame_image_id,
531 int* frame_overlay_image_id) const {
532 *frame_overlay_image_id = 0;
533
529 bool is_incognito = !browser_view()->IsRegularOrGuestSession(); 534 bool is_incognito = !browser_view()->IsRegularOrGuestSession();
530 if (browser_view()->IsBrowserTypeNormal()) { 535 if (browser_view()->IsBrowserTypeNormal()) {
531 // Use the standard resource ids to allow users to theme the frames. 536 // Tabbed browser windows.
537 ui::ThemeProvider* tp = GetThemeProvider();
538 if (tp->HasCustomImage(IDR_THEME_FRAME_OVERLAY) &&
539 !is_incognito) {
540 *frame_overlay_image_id = ShouldPaintAsActive() ?
541 IDR_THEME_FRAME_OVERLAY : IDR_THEME_FRAME_OVERLAY_INACTIVE;
542 }
543
532 if (ShouldPaintAsActive()) { 544 if (ShouldPaintAsActive()) {
533 return is_incognito ? 545 *frame_image_id = is_incognito ?
534 IDR_THEME_FRAME_INCOGNITO : IDR_THEME_FRAME; 546 IDR_THEME_FRAME_INCOGNITO : IDR_THEME_FRAME;
547 } else {
548 *frame_image_id = is_incognito ?
549 IDR_THEME_FRAME_INCOGNITO_INACTIVE : IDR_THEME_FRAME_INACTIVE;
535 } 550 }
536 return is_incognito ? 551
537 IDR_THEME_FRAME_INCOGNITO_INACTIVE : IDR_THEME_FRAME_INACTIVE; 552 if ((frame()->IsMaximized() || frame()->IsFullscreen()) &&
553 !tp->HasCustomImage(IDR_THEME_FRAME) &&
554 !tp->HasCustomImage(*frame_image_id) &&
555 *frame_overlay_image_id == 0) {
556 *frame_image_id = IDR_AURA_BROWSER_WINDOW_HEADER_BASE_MAXIMIZED;
557 }
558 } else if (UsePackagedAppHeaderStyle()) {
559 // Apps are not themeable.
560 *frame_image_id = ShouldPaintAsActive() ?
561 IDR_AURA_WINDOW_HEADER_BASE_ACTIVE :
562 IDR_AURA_WINDOW_HEADER_BASE_INACTIVE;
563 } else {
564 // Browser popups are not themeable.
565 if (frame()->IsMaximized() || frame()->IsFullscreen()) {
566 *frame_image_id = IDR_AURA_BROWSER_WINDOW_HEADER_BASE_MAXIMIZED;
567 } else if (ShouldPaintAsActive()) {
568 *frame_image_id = is_incognito ?
569 IDR_AURA_BROWSER_WINDOW_HEADER_BASE_RESTORED_INCOGNITO_ACTIVE :
570 IDR_AURA_BROWSER_WINDOW_HEADER_BASE_RESTORED_ACTIVE;
571 } else {
572 *frame_image_id = is_incognito ?
573 IDR_AURA_BROWSER_WINDOW_HEADER_BASE_RESTORED_INCOGNITO_INACTIVE :
574 IDR_AURA_BROWSER_WINDOW_HEADER_BASE_RESTORED_INACTIVE;
575 }
538 } 576 }
539 // Never theme app and popup windows.
540 if (ShouldPaintAsActive()) {
541 return is_incognito ?
542 IDR_AURA_WINDOW_HEADER_BASE_INCOGNITO_ACTIVE :
543 IDR_AURA_WINDOW_HEADER_BASE_ACTIVE;
544 }
545 return is_incognito ?
546 IDR_AURA_WINDOW_HEADER_BASE_INCOGNITO_INACTIVE :
547 IDR_AURA_WINDOW_HEADER_BASE_INACTIVE;
548 } 577 }
549
550 int BrowserNonClientFrameViewAsh::GetThemeFrameOverlayImageId() const {
551 ui::ThemeProvider* tp = GetThemeProvider();
552 if (tp->HasCustomImage(IDR_THEME_FRAME_OVERLAY) &&
553 browser_view()->IsBrowserTypeNormal() &&
554 !browser_view()->IsOffTheRecord()) {
555 return ShouldPaintAsActive() ?
556 IDR_THEME_FRAME_OVERLAY : IDR_THEME_FRAME_OVERLAY_INACTIVE;
557 }
558 return 0;
559 }
OLDNEW
« ash/wm/header_painter.cc ('K') | « chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698