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

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

Issue 2441863002: Remove some more !IsModeMaterial code. (Closed)
Patch Set: pull more shades Created 4 years, 2 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_mus.h" 5 #include "chrome/browser/ui/views/frame/browser_non_client_frame_view_mus.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "chrome/app/chrome_command_ids.h"
10 #include "chrome/browser/extensions/extension_util.h"
11 #include "chrome/browser/profiles/profiles_state.h" 9 #include "chrome/browser/profiles/profiles_state.h"
12 #include "chrome/browser/themes/theme_properties.h" 10 #include "chrome/browser/themes/theme_properties.h"
13 #include "chrome/browser/ui/browser.h" 11 #include "chrome/browser/ui/browser.h"
14 #include "chrome/browser/ui/browser_commands.h"
15 #include "chrome/browser/ui/layout_constants.h" 12 #include "chrome/browser/ui/layout_constants.h"
16 #include "chrome/browser/ui/views/frame/browser_frame.h" 13 #include "chrome/browser/ui/views/frame/browser_frame.h"
17 #include "chrome/browser/ui/views/frame/browser_frame_mus.h" 14 #include "chrome/browser/ui/views/frame/browser_frame_mus.h"
18 #include "chrome/browser/ui/views/frame/browser_header_painter_ash.h" 15 #include "chrome/browser/ui/views/frame/browser_header_painter_ash.h"
19 #include "chrome/browser/ui/views/frame/browser_view.h" 16 #include "chrome/browser/ui/views/frame/browser_view.h"
20 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h" 17 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h"
21 #include "chrome/browser/ui/views/frame/web_app_left_header_view_ash.h" 18 #include "chrome/browser/ui/views/frame/web_app_left_header_view_ash.h"
22 #include "chrome/browser/ui/views/profiles/profile_indicator_icon.h" 19 #include "chrome/browser/ui/views/profiles/profile_indicator_icon.h"
23 #include "chrome/browser/ui/views/tab_icon_view.h" 20 #include "chrome/browser/ui/views/tab_icon_view.h"
24 #include "chrome/browser/ui/views/tabs/tab_strip.h" 21 #include "chrome/browser/ui/views/tabs/tab_strip.h"
25 #include "chrome/browser/web_applications/web_app.h" 22 #include "chrome/browser/web_applications/web_app.h"
26 #include "chrome/grit/theme_resources.h" 23 #include "chrome/grit/theme_resources.h"
27 #include "components/signin/core/common/profile_management_switches.h"
28 #include "content/public/browser/web_contents.h" 24 #include "content/public/browser/web_contents.h"
29 #include "extensions/browser/extension_registry.h"
30 #include "services/ui/public/cpp/window.h" 25 #include "services/ui/public/cpp/window.h"
31 #include "ui/accessibility/ax_view_state.h" 26 #include "ui/accessibility/ax_view_state.h"
32 #include "ui/aura/client/aura_constants.h" 27 #include "ui/aura/client/aura_constants.h"
33 #include "ui/aura/window.h" 28 #include "ui/aura/window.h"
34 #include "ui/base/hit_test.h" 29 #include "ui/base/hit_test.h"
35 #include "ui/base/layout.h" 30 #include "ui/base/layout.h"
36 #include "ui/base/material_design/material_design_controller.h"
37 #include "ui/base/resource/resource_bundle.h"
38 #include "ui/base/theme_provider.h" 31 #include "ui/base/theme_provider.h"
39 #include "ui/compositor/layer_animator.h" 32 #include "ui/compositor/layer_animator.h"
40 #include "ui/gfx/canvas.h" 33 #include "ui/gfx/canvas.h"
41 #include "ui/gfx/geometry/rect_conversions.h" 34 #include "ui/gfx/geometry/rect_conversions.h"
42 #include "ui/gfx/image/image_skia.h" 35 #include "ui/gfx/image/image_skia.h"
43 #include "ui/gfx/scoped_canvas.h" 36 #include "ui/gfx/scoped_canvas.h"
44 #include "ui/views/controls/label.h" 37 #include "ui/views/controls/label.h"
45 #include "ui/views/layout/layout_constants.h" 38 #include "ui/views/layout/layout_constants.h"
46 #include "ui/views/mus/window_manager_frame_values.h" 39 #include "ui/views/mus/window_manager_frame_values.h"
47 #include "ui/views/widget/widget.h" 40 #include "ui/views/widget/widget.h"
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 DCHECK(profile_indicator_icon()); 420 DCHECK(profile_indicator_icon());
428 #if !defined(OS_CHROMEOS) 421 #if !defined(OS_CHROMEOS)
429 // ChromeOS shows avatar on V1 app. 422 // ChromeOS shows avatar on V1 app.
430 DCHECK(browser_view()->IsTabStripVisible()); 423 DCHECK(browser_view()->IsTabStripVisible());
431 #endif 424 #endif
432 gfx::ImageSkia incognito_icon = GetIncognitoAvatarIcon(); 425 gfx::ImageSkia incognito_icon = GetIncognitoAvatarIcon();
433 gfx::Insets avatar_insets = GetLayoutInsets(AVATAR_ICON); 426 gfx::Insets avatar_insets = GetLayoutInsets(AVATAR_ICON);
434 int avatar_bottom = GetTopInset(false) + browser_view()->GetTabStripHeight() - 427 int avatar_bottom = GetTopInset(false) + browser_view()->GetTabStripHeight() -
435 avatar_insets.bottom(); 428 avatar_insets.bottom();
436 int avatar_y = avatar_bottom - incognito_icon.height(); 429 int avatar_y = avatar_bottom - incognito_icon.height();
437 if (!ui::MaterialDesignController::IsModeMaterial() &&
438 browser_view()->IsTabStripVisible() &&
439 (frame()->IsMaximized() || frame()->IsFullscreen())) {
440 avatar_y = GetTopInset(false) + kContentShadowHeight;
441 }
442 430
443 // Hide the incognito icon in immersive fullscreen when the tab light bar is 431 // Hide the incognito icon in immersive fullscreen when the tab light bar is
444 // visible because the header is too short for the icognito icon to be 432 // visible because the header is too short for the icognito icon to be
445 // recognizable. 433 // recognizable.
446 bool avatar_visible = !UseImmersiveLightbarHeaderStyle(); 434 bool avatar_visible = !UseImmersiveLightbarHeaderStyle();
447 int avatar_height = avatar_visible ? avatar_bottom - avatar_y : 0; 435 int avatar_height = avatar_visible ? avatar_bottom - avatar_y : 0;
Peter Kasting 2016/10/21 21:07:50 Nit: Can now be const int avatar_height = avata
Evan Stade 2016/10/21 22:11:12 Done.
448 436
449 gfx::Rect avatar_bounds(avatar_insets.left(), avatar_y, 437 gfx::Rect avatar_bounds(avatar_insets.left(), avatar_y,
450 incognito_icon.width(), avatar_height); 438 incognito_icon.width(), avatar_height);
451 profile_indicator_icon()->SetBoundsRect(avatar_bounds); 439 profile_indicator_icon()->SetBoundsRect(avatar_bounds);
452 profile_indicator_icon()->SetVisible(avatar_visible); 440 profile_indicator_icon()->SetVisible(avatar_visible);
453 } 441 }
454 442
455 void BrowserNonClientFrameViewMus::LayoutProfileSwitcher() { 443 void BrowserNonClientFrameViewMus::LayoutProfileSwitcher() {
456 #if defined(FRAME_AVATAR_BUTTON) 444 #if defined(FRAME_AVATAR_BUTTON)
457 gfx::Size button_size = profile_switcher_.view()->GetPreferredSize(); 445 gfx::Size button_size = profile_switcher_.view()->GetPreferredSize();
(...skipping 21 matching lines...) Expand all
479 gfx::Canvas* canvas) {} 467 gfx::Canvas* canvas) {}
480 468
481 void BrowserNonClientFrameViewMus::PaintToolbarBackground(gfx::Canvas* canvas) { 469 void BrowserNonClientFrameViewMus::PaintToolbarBackground(gfx::Canvas* canvas) {
482 gfx::Rect toolbar_bounds(browser_view()->GetToolbarBounds()); 470 gfx::Rect toolbar_bounds(browser_view()->GetToolbarBounds());
483 if (toolbar_bounds.IsEmpty()) 471 if (toolbar_bounds.IsEmpty())
484 return; 472 return;
485 gfx::Point toolbar_origin(toolbar_bounds.origin()); 473 gfx::Point toolbar_origin(toolbar_bounds.origin());
486 View::ConvertPointToTarget(browser_view(), this, &toolbar_origin); 474 View::ConvertPointToTarget(browser_view(), this, &toolbar_origin);
487 toolbar_bounds.set_origin(toolbar_origin); 475 toolbar_bounds.set_origin(toolbar_origin);
488 476
489 int x = toolbar_bounds.x();
490 int w = toolbar_bounds.width();
491 int y = toolbar_bounds.y();
492 const ui::ThemeProvider* tp = GetThemeProvider(); 477 const ui::ThemeProvider* tp = GetThemeProvider();
478 // Background.
Peter Kasting 2016/10/21 21:07:50 Nit: See _ash.cc comments for this function
Evan Stade 2016/10/21 22:11:12 Done.
479 if (tp->HasCustomImage(IDR_THEME_TOOLBAR)) {
480 const int bg_y = GetTopInset(false) + GetLayoutInsets(TAB).top();
481 const int x = toolbar_bounds.x();
482 const int y = toolbar_bounds.y();
483 canvas->TileImageInt(*tp->GetImageSkiaNamed(IDR_THEME_TOOLBAR),
484 x + GetThemeBackgroundXInset(), y - bg_y, x, y,
485 toolbar_bounds.width(), toolbar_bounds.height());
486 } else {
487 canvas->FillRect(toolbar_bounds,
488 tp->GetColor(ThemeProperties::COLOR_TOOLBAR));
489 }
493 490
494 if (ui::MaterialDesignController::IsModeMaterial()) { 491 // Top stroke.
495 if (tp->HasCustomImage(IDR_THEME_TOOLBAR)) { 492 gfx::Rect separator_rect = toolbar_bounds;
496 // Paint the main toolbar image. Since this image is also used to draw 493 gfx::ScopedCanvas scoped_canvas(canvas);
497 // the tab background, we must use the tab strip offset to compute the 494 gfx::Rect tabstrip_bounds(GetBoundsForTabStrip(browser_view()->tabstrip()));
498 // image source y position. If you have to debug this code use an image 495 tabstrip_bounds.set_x(GetMirroredXForRect(tabstrip_bounds));
499 // editor to paint a diagonal line through the toolbar image and ensure it 496 canvas->ClipRect(tabstrip_bounds, SkRegion::kDifference_Op);
500 // lines up across the tab and toolbar. 497 separator_rect.set_y(tabstrip_bounds.bottom());
501 gfx::ImageSkia* theme_toolbar = tp->GetImageSkiaNamed(IDR_THEME_TOOLBAR); 498 separator_rect.set_height(0);
502 canvas->TileImageInt(*theme_toolbar, x + GetThemeBackgroundXInset(), 499 BrowserView::Paint1pxHorizontalLine(canvas, GetToolbarTopSeparatorColor(),
503 y - GetTopInset(false), x, y, w, 500 separator_rect, true);
504 theme_toolbar->height());
505 } else {
506 canvas->FillRect(toolbar_bounds,
507 tp->GetColor(ThemeProperties::COLOR_TOOLBAR));
508 }
509 501
510 // Draw the separator line atop the toolbar, on the left and right of the 502 // Toolbar/content separator.
511 // tabstrip. 503 toolbar_bounds.Inset(kClientEdgeThickness, 0);
512 // TODO(tdanderson): Draw the separator line for non-tabbed windows. 504 BrowserView::Paint1pxHorizontalLine(
513 if (browser_view()->IsTabStripVisible()) { 505 canvas, tp->GetColor(ThemeProperties::COLOR_TOOLBAR_BOTTOM_SEPARATOR),
514 gfx::Rect separator_rect(x, y, w, 0); 506 toolbar_bounds,
515 gfx::ScopedCanvas scoped_canvas(canvas); 507 true);
516 gfx::Rect tabstrip_bounds(
517 GetBoundsForTabStrip(browser_view()->tabstrip()));
518 tabstrip_bounds.set_x(GetMirroredXForRect(tabstrip_bounds));
519 canvas->ClipRect(tabstrip_bounds, SkRegion::kDifference_Op);
520 separator_rect.set_y(tabstrip_bounds.bottom());
521 BrowserView::Paint1pxHorizontalLine(canvas, GetToolbarTopSeparatorColor(),
522 separator_rect, true);
523 }
524
525 // Draw the content/toolbar separator.
526 toolbar_bounds.Inset(kClientEdgeThickness, 0);
527 BrowserView::Paint1pxHorizontalLine(
528 canvas, tp->GetColor(ThemeProperties::COLOR_TOOLBAR_BOTTOM_SEPARATOR),
529 toolbar_bounds, true);
530 } else {
531 // NOTE: this ifdef can't be OS_CHROMEOS as we want to see how it looks on
532 // windows as well.
533 #if defined(USE_ASH)
534 int h = toolbar_bounds.height();
535 // Gross hack: We split the toolbar images into two pieces, since sometimes
536 // (popup mode) the toolbar isn't tall enough to show the whole image. The
537 // split happens between the top shadow section and the bottom gradient
538 // section so that we never break the gradient.
539 // NOTE(pkotwicz): If the computation for |bottom_y| is changed, Layout()
540 // must be changed as well.
541 int split_point = kFrameShadowThickness * 2;
542 int bottom_y = y + split_point;
543 int bottom_edge_height = h - split_point;
544
545 canvas->FillRect(gfx::Rect(x, bottom_y, w, bottom_edge_height),
546 tp->GetColor(ThemeProperties::COLOR_TOOLBAR));
547
548 // Paint the main toolbar image. Since this image is also used to draw the
549 // tab background, we must use the tab strip offset to compute the image
550 // source y position. If you have to debug this code use an image editor
551 // to paint a diagonal line through the toolbar image and ensure it lines up
552 // across the tab and toolbar.
553 gfx::ImageSkia* theme_toolbar = tp->GetImageSkiaNamed(IDR_THEME_TOOLBAR);
554 canvas->TileImageInt(*theme_toolbar, x + GetThemeBackgroundXInset(),
555 bottom_y - GetTopInset(false), x, bottom_y, w,
556 theme_toolbar->height());
557
558 // The pre-material design content area line has a shadow that extends a
559 // couple of pixels above the toolbar bounds.
560 const int kContentShadowHeight = 2;
561 gfx::ImageSkia* toolbar_top = tp->GetImageSkiaNamed(IDR_TOOLBAR_SHADE_TOP);
562 canvas->TileImageInt(*toolbar_top, 0, 0, x, y - kContentShadowHeight, w,
563 split_point + kContentShadowHeight + 1);
564
565 // Draw the "lightening" shade line around the edges of the toolbar.
566 gfx::ImageSkia* toolbar_left =
567 tp->GetImageSkiaNamed(IDR_TOOLBAR_SHADE_LEFT);
568 canvas->TileImageInt(*toolbar_left, 0, 0, x + kClientEdgeThickness,
569 y + kClientEdgeThickness + kContentShadowHeight,
570 toolbar_left->width(), theme_toolbar->height());
571 gfx::ImageSkia* toolbar_right =
572 tp->GetImageSkiaNamed(IDR_TOOLBAR_SHADE_RIGHT);
573 canvas->TileImageInt(*toolbar_right, 0, 0,
574 w - toolbar_right->width() - 2 * kClientEdgeThickness,
575 y + kClientEdgeThickness + kContentShadowHeight,
576 toolbar_right->width(), theme_toolbar->height());
577
578 // Draw the content/toolbar separator.
579 canvas->FillRect(
580 gfx::Rect(x + kClientEdgeThickness,
581 toolbar_bounds.bottom() - kClientEdgeThickness,
582 w - (2 * kClientEdgeThickness), kClientEdgeThickness),
583 tp->GetColor(ThemeProperties::COLOR_TOOLBAR_BOTTOM_SEPARATOR));
584 #else
585 // This is the case for running on non-chromeos. Decide how we want this to
586 // look.
587 #endif
588 }
589 } 508 }
590 509
591 void BrowserNonClientFrameViewMus::PaintContentEdge(gfx::Canvas* canvas) { 510 void BrowserNonClientFrameViewMus::PaintContentEdge(gfx::Canvas* canvas) {
592 DCHECK(!UsePackagedAppHeaderStyle() && !UseWebAppHeaderStyle()); 511 DCHECK(!UsePackagedAppHeaderStyle() && !UseWebAppHeaderStyle());
593 const int bottom = frame_values().normal_insets.bottom(); 512 const int bottom = frame_values().normal_insets.bottom();
594 canvas->FillRect( 513 canvas->FillRect(
595 gfx::Rect(0, bottom, width(), kClientEdgeThickness), 514 gfx::Rect(0, bottom, width(), kClientEdgeThickness),
596 GetThemeProvider()->GetColor( 515 GetThemeProvider()->GetColor(
597 ThemeProperties::COLOR_TOOLBAR_BOTTOM_SEPARATOR)); 516 ThemeProperties::COLOR_TOOLBAR_BOTTOM_SEPARATOR));
598 } 517 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698