| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/opaque_browser_frame_view.h" | 5 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 | 603 |
| 604 // Fill with the frame color first so we have a constant background for | 604 // Fill with the frame color first so we have a constant background for |
| 605 // areas not covered by the theme image. | 605 // areas not covered by the theme image. |
| 606 SkBitmap* theme_frame = GetFrameBitmap(); | 606 SkBitmap* theme_frame = GetFrameBitmap(); |
| 607 int top_area_height = theme_frame->height(); | 607 int top_area_height = theme_frame->height(); |
| 608 if (browser_view_->IsTabStripVisible()) { | 608 if (browser_view_->IsTabStripVisible()) { |
| 609 top_area_height = std::max(top_area_height, | 609 top_area_height = std::max(top_area_height, |
| 610 GetBoundsForTabStrip(browser_view_->tabstrip()).bottom()); | 610 GetBoundsForTabStrip(browser_view_->tabstrip()).bottom()); |
| 611 } | 611 } |
| 612 SkColor frame_color = GetFrameColor(); | 612 SkColor frame_color = GetFrameColor(); |
| 613 canvas->FillRectInt(frame_color, 0, 0, width(), top_area_height); | 613 canvas->FillRect(frame_color, gfx::Rect(0, 0, width(), top_area_height)); |
| 614 | 614 |
| 615 // Now fill down the sides. | 615 // Now fill down the sides. |
| 616 canvas->FillRectInt(frame_color, 0, top_area_height, left_edge->width(), | 616 canvas->FillRect(frame_color, |
| 617 height() - top_area_height); | 617 gfx::Rect(0, top_area_height, left_edge->width(), |
| 618 canvas->FillRectInt(frame_color, width() - right_edge->width(), | 618 height() - top_area_height)); |
| 619 top_area_height, right_edge->width(), | 619 canvas->FillRect(frame_color, |
| 620 height() - top_area_height); | 620 gfx::Rect(width() - right_edge->width(), |
| 621 top_area_height, right_edge->width(), |
| 622 height() - top_area_height)); |
| 621 // Now fill the bottom area. | 623 // Now fill the bottom area. |
| 622 canvas->FillRectInt(frame_color, left_edge->width(), | 624 canvas->FillRect(frame_color, |
| 623 height() - bottom_edge->height(), | 625 gfx::Rect(left_edge->width(), |
| 624 width() - left_edge->width() - right_edge->width(), | 626 height() - bottom_edge->height(), |
| 625 bottom_edge->height()); | 627 width() - left_edge->width() - right_edge->width(), |
| 628 bottom_edge->height())); |
| 626 | 629 |
| 627 // Draw the theme frame. | 630 // Draw the theme frame. |
| 628 canvas->TileImageInt(*theme_frame, 0, 0, width(), theme_frame->height()); | 631 canvas->TileImageInt(*theme_frame, 0, 0, width(), theme_frame->height()); |
| 629 | 632 |
| 630 // Draw the theme frame overlay. | 633 // Draw the theme frame overlay. |
| 631 if (tp->HasCustomImage(IDR_THEME_FRAME_OVERLAY) && | 634 if (tp->HasCustomImage(IDR_THEME_FRAME_OVERLAY) && |
| 632 browser_view_->IsBrowserTypeNormal() && | 635 browser_view_->IsBrowserTypeNormal() && |
| 633 !browser_view_->IsOffTheRecord()) { | 636 !browser_view_->IsOffTheRecord()) { |
| 634 canvas->DrawBitmapInt(*tp->GetBitmapNamed(ShouldPaintAsActive() ? | 637 canvas->DrawBitmapInt(*tp->GetBitmapNamed(ShouldPaintAsActive() ? |
| 635 IDR_THEME_FRAME_OVERLAY : IDR_THEME_FRAME_OVERLAY_INACTIVE), 0, 0); | 638 IDR_THEME_FRAME_OVERLAY : IDR_THEME_FRAME_OVERLAY_INACTIVE), 0, 0); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 684 | 687 |
| 685 // We will be painting from top_offset to top_offset + theme_frame_height. If | 688 // We will be painting from top_offset to top_offset + theme_frame_height. If |
| 686 // this is less than GetBoundsForTabStrip.bottom, we need to paint the frame | 689 // this is less than GetBoundsForTabStrip.bottom, we need to paint the frame |
| 687 // color. | 690 // color. |
| 688 SkBitmap* theme_frame = GetFrameBitmap(); | 691 SkBitmap* theme_frame = GetFrameBitmap(); |
| 689 int theme_frame_bottom = top_offset + theme_frame->height(); | 692 int theme_frame_bottom = top_offset + theme_frame->height(); |
| 690 int top_area_height = | 693 int top_area_height = |
| 691 GetBoundsForTabStrip(browser_view_->tabstrip()).bottom(); | 694 GetBoundsForTabStrip(browser_view_->tabstrip()).bottom(); |
| 692 if (top_area_height > theme_frame_bottom) { | 695 if (top_area_height > theme_frame_bottom) { |
| 693 SkColor frame_color = GetFrameColor(); | 696 SkColor frame_color = GetFrameColor(); |
| 694 canvas->FillRectInt(frame_color, 0, 0, width(), top_area_height); | 697 canvas->FillRect(frame_color, gfx::Rect(0, 0, width(), top_area_height)); |
| 695 } | 698 } |
| 696 | 699 |
| 697 // Draw the theme frame. It must be aligned with the tabstrip as if we were | 700 // Draw the theme frame. It must be aligned with the tabstrip as if we were |
| 698 // in restored mode. Note that the top of the tabstrip is | 701 // in restored mode. Note that the top of the tabstrip is |
| 699 // kTabstripTopShadowThickness px off the top of the screen. | 702 // kTabstripTopShadowThickness px off the top of the screen. |
| 700 int theme_background_y = -(GetHorizontalTabStripVerticalOffset(true) + | 703 int theme_background_y = -(GetHorizontalTabStripVerticalOffset(true) + |
| 701 kTabstripTopShadowThickness); | 704 kTabstripTopShadowThickness); |
| 702 int left_offset = 0, right_offset = 0; | 705 int left_offset = 0, right_offset = 0; |
| 703 | 706 |
| 704 if (left || right) { | 707 if (left || right) { |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 780 SkBitmap* toolbar_left = tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER); | 783 SkBitmap* toolbar_left = tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER); |
| 781 int bottom_edge_height = std::min(toolbar_left->height(), h) - split_point; | 784 int bottom_edge_height = std::min(toolbar_left->height(), h) - split_point; |
| 782 | 785 |
| 783 // Split our canvas out so we can mask out the corners of the toolbar | 786 // Split our canvas out so we can mask out the corners of the toolbar |
| 784 // without masking out the frame. | 787 // without masking out the frame. |
| 785 canvas->SaveLayerAlpha( | 788 canvas->SaveLayerAlpha( |
| 786 255, gfx::Rect(x - kClientEdgeThickness, y, w + kClientEdgeThickness * 3, | 789 255, gfx::Rect(x - kClientEdgeThickness, y, w + kClientEdgeThickness * 3, |
| 787 h)); | 790 h)); |
| 788 canvas->GetSkCanvas()->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode); | 791 canvas->GetSkCanvas()->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode); |
| 789 | 792 |
| 790 SkColor theme_toolbar_color = | 793 SkColor theme_toolbar_color = tp->GetColor(ThemeService::COLOR_TOOLBAR); |
| 791 tp->GetColor(ThemeService::COLOR_TOOLBAR); | 794 canvas->FillRect(theme_toolbar_color, |
| 792 canvas->FillRectInt(theme_toolbar_color, x, bottom_y, w, bottom_edge_height); | 795 gfx::Rect(x, bottom_y, w, bottom_edge_height)); |
| 793 | 796 |
| 794 // Tile the toolbar image starting at the frame edge on the left and where the | 797 // Tile the toolbar image starting at the frame edge on the left and where the |
| 795 // horizontal tabstrip is (or would be) on the top. | 798 // horizontal tabstrip is (or would be) on the top. |
| 796 SkBitmap* theme_toolbar = tp->GetBitmapNamed(IDR_THEME_TOOLBAR); | 799 SkBitmap* theme_toolbar = tp->GetBitmapNamed(IDR_THEME_TOOLBAR); |
| 797 canvas->TileImageInt(*theme_toolbar, x, | 800 canvas->TileImageInt(*theme_toolbar, x, |
| 798 bottom_y - GetHorizontalTabStripVerticalOffset(false), x, | 801 bottom_y - GetHorizontalTabStripVerticalOffset(false), x, |
| 799 bottom_y, w, theme_toolbar->height()); | 802 bottom_y, w, theme_toolbar->height()); |
| 800 | 803 |
| 801 // Draw rounded corners for the tab. | 804 // Draw rounded corners for the tab. |
| 802 SkBitmap* toolbar_left_mask = | 805 SkBitmap* toolbar_left_mask = |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 847 | 850 |
| 848 SkBitmap* toolbar_right = tp->GetBitmapNamed(IDR_CONTENT_TOP_RIGHT_CORNER); | 851 SkBitmap* toolbar_right = tp->GetBitmapNamed(IDR_CONTENT_TOP_RIGHT_CORNER); |
| 849 canvas->DrawBitmapInt(*toolbar_right, 0, 0, toolbar_right->width(), | 852 canvas->DrawBitmapInt(*toolbar_right, 0, 0, toolbar_right->width(), |
| 850 split_point, right_x, y, toolbar_right->width(), split_point, false); | 853 split_point, right_x, y, toolbar_right->width(), split_point, false); |
| 851 canvas->DrawBitmapInt(*toolbar_right, 0, | 854 canvas->DrawBitmapInt(*toolbar_right, 0, |
| 852 toolbar_right->height() - bottom_edge_height, toolbar_right->width(), | 855 toolbar_right->height() - bottom_edge_height, toolbar_right->width(), |
| 853 bottom_edge_height, right_x, bottom_y, toolbar_right->width(), | 856 bottom_edge_height, right_x, bottom_y, toolbar_right->width(), |
| 854 bottom_edge_height, false); | 857 bottom_edge_height, false); |
| 855 | 858 |
| 856 // Draw the content/toolbar separator. | 859 // Draw the content/toolbar separator. |
| 857 canvas->FillRectInt(ResourceBundle::toolbar_separator_color, | 860 canvas->FillRect(ResourceBundle::toolbar_separator_color, |
| 858 x + kClientEdgeThickness, toolbar_bounds.bottom() - kClientEdgeThickness, | 861 gfx::Rect(x + kClientEdgeThickness, |
| 859 w - (2 * kClientEdgeThickness), kClientEdgeThickness); | 862 toolbar_bounds.bottom() - kClientEdgeThickness, |
| 863 w - (2 * kClientEdgeThickness), |
| 864 kClientEdgeThickness)); |
| 860 } | 865 } |
| 861 | 866 |
| 862 void OpaqueBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) { | 867 void OpaqueBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) { |
| 863 ui::ThemeProvider* tp = GetThemeProvider(); | 868 ui::ThemeProvider* tp = GetThemeProvider(); |
| 864 int client_area_top = frame_->client_view()->y(); | 869 int client_area_top = frame_->client_view()->y(); |
| 865 int image_top = client_area_top; | 870 int image_top = client_area_top; |
| 866 | 871 |
| 867 gfx::Rect client_area_bounds = CalculateClientAreaBounds(width(), height()); | 872 gfx::Rect client_area_bounds = CalculateClientAreaBounds(width(), height()); |
| 868 SkColor toolbar_color = tp->GetColor(ThemeService::COLOR_TOOLBAR); | 873 SkColor toolbar_color = tp->GetColor(ThemeService::COLOR_TOOLBAR); |
| 869 | 874 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 888 canvas->DrawBitmapInt(*top_left, 0, 0, top_left->width(), height, | 893 canvas->DrawBitmapInt(*top_left, 0, 0, top_left->width(), height, |
| 889 client_area_bounds.x() - top_left->width(), top_edge_y, | 894 client_area_bounds.x() - top_left->width(), top_edge_y, |
| 890 top_left->width(), height, false); | 895 top_left->width(), height, false); |
| 891 canvas->TileImageInt(*top_center, 0, 0, client_area_bounds.x(), top_edge_y, | 896 canvas->TileImageInt(*top_center, 0, 0, client_area_bounds.x(), top_edge_y, |
| 892 client_area_bounds.width(), std::min(height, top_center->height())); | 897 client_area_bounds.width(), std::min(height, top_center->height())); |
| 893 canvas->DrawBitmapInt(*top_right, 0, 0, top_right->width(), height, | 898 canvas->DrawBitmapInt(*top_right, 0, 0, top_right->width(), height, |
| 894 client_area_bounds.right(), top_edge_y, | 899 client_area_bounds.right(), top_edge_y, |
| 895 top_right->width(), height, false); | 900 top_right->width(), height, false); |
| 896 | 901 |
| 897 // Draw the toolbar color across the top edge. | 902 // Draw the toolbar color across the top edge. |
| 898 canvas->FillRectInt(toolbar_color, | 903 canvas->FillRect( |
| 899 client_area_bounds.x() - kClientEdgeThickness, | 904 toolbar_color, |
| 900 client_area_top - kClientEdgeThickness, | 905 gfx::Rect(client_area_bounds.x() - kClientEdgeThickness, |
| 901 client_area_bounds.width() + (2 * kClientEdgeThickness), | 906 client_area_top - kClientEdgeThickness, |
| 902 kClientEdgeThickness); | 907 client_area_bounds.width() + (2 * kClientEdgeThickness), |
| 908 kClientEdgeThickness)); |
| 903 } | 909 } |
| 904 | 910 |
| 905 int client_area_bottom = | 911 int client_area_bottom = |
| 906 std::max(client_area_top, height() - NonClientBorderThickness()); | 912 std::max(client_area_top, height() - NonClientBorderThickness()); |
| 907 int image_height = client_area_bottom - image_top; | 913 int image_height = client_area_bottom - image_top; |
| 908 | 914 |
| 909 // Draw the client edge images. | 915 // Draw the client edge images. |
| 910 // Draw the client edge images. | 916 // Draw the client edge images. |
| 911 SkBitmap* right = tp->GetBitmapNamed(IDR_CONTENT_RIGHT_SIDE); | 917 SkBitmap* right = tp->GetBitmapNamed(IDR_CONTENT_RIGHT_SIDE); |
| 912 canvas->TileImageInt(*right, client_area_bounds.right(), image_top, | 918 canvas->TileImageInt(*right, client_area_bounds.right(), image_top, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 923 canvas->DrawBitmapInt(*bottom_left, | 929 canvas->DrawBitmapInt(*bottom_left, |
| 924 client_area_bounds.x() - bottom_left->width(), client_area_bottom); | 930 client_area_bounds.x() - bottom_left->width(), client_area_bottom); |
| 925 SkBitmap* left = tp->GetBitmapNamed(IDR_CONTENT_LEFT_SIDE); | 931 SkBitmap* left = tp->GetBitmapNamed(IDR_CONTENT_LEFT_SIDE); |
| 926 canvas->TileImageInt(*left, client_area_bounds.x() - left->width(), | 932 canvas->TileImageInt(*left, client_area_bounds.x() - left->width(), |
| 927 image_top, left->width(), image_height); | 933 image_top, left->width(), image_height); |
| 928 | 934 |
| 929 // Draw the toolbar color so that the client edges show the right color even | 935 // Draw the toolbar color so that the client edges show the right color even |
| 930 // where not covered by the toolbar image. NOTE: We do this after drawing the | 936 // where not covered by the toolbar image. NOTE: We do this after drawing the |
| 931 // images because the images are meant to alpha-blend atop the frame whereas | 937 // images because the images are meant to alpha-blend atop the frame whereas |
| 932 // these rects are meant to be fully opaque, without anything overlaid. | 938 // these rects are meant to be fully opaque, without anything overlaid. |
| 933 canvas->FillRectInt(toolbar_color, | 939 canvas->FillRect( |
| 934 client_area_bounds.x() - kClientEdgeThickness, client_area_top, | 940 toolbar_color, |
| 935 kClientEdgeThickness, | 941 gfx::Rect(client_area_bounds.x() - kClientEdgeThickness, |
| 936 client_area_bottom + kClientEdgeThickness - client_area_top); | 942 client_area_top, |
| 937 canvas->FillRectInt(toolbar_color, client_area_bounds.x(), client_area_bottom, | 943 kClientEdgeThickness, |
| 938 client_area_bounds.width(), kClientEdgeThickness); | 944 client_area_bottom + kClientEdgeThickness - client_area_top)); |
| 939 canvas->FillRectInt(toolbar_color, client_area_bounds.right(), | 945 canvas->FillRect(toolbar_color, |
| 940 client_area_top, kClientEdgeThickness, | 946 gfx::Rect(client_area_bounds.x(), client_area_bottom, |
| 941 client_area_bottom + kClientEdgeThickness - client_area_top); | 947 client_area_bounds.width(), kClientEdgeThickness)); |
| 948 canvas->FillRect( |
| 949 toolbar_color, |
| 950 gfx::Rect(client_area_bounds.right(), |
| 951 client_area_top, |
| 952 kClientEdgeThickness, |
| 953 client_area_bottom + kClientEdgeThickness - client_area_top)); |
| 942 } | 954 } |
| 943 | 955 |
| 944 SkBitmap* OpaqueBrowserFrameView::GetFrameBitmap() const { | 956 SkBitmap* OpaqueBrowserFrameView::GetFrameBitmap() const { |
| 945 bool is_incognito = browser_view_->IsOffTheRecord(); | 957 bool is_incognito = browser_view_->IsOffTheRecord(); |
| 946 int resource_id; | 958 int resource_id; |
| 947 if (browser_view_->IsBrowserTypeNormal()) { | 959 if (browser_view_->IsBrowserTypeNormal()) { |
| 948 if (ShouldPaintAsActive()) { | 960 if (ShouldPaintAsActive()) { |
| 949 resource_id = is_incognito ? | 961 resource_id = is_incognito ? |
| 950 IDR_THEME_FRAME_INCOGNITO : IDR_THEME_FRAME; | 962 IDR_THEME_FRAME_INCOGNITO : IDR_THEME_FRAME; |
| 951 } else { | 963 } else { |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1141 ProfileInfoCache& cache = | 1153 ProfileInfoCache& cache = |
| 1142 g_browser_process->profile_manager()->GetProfileInfoCache(); | 1154 g_browser_process->profile_manager()->GetProfileInfoCache(); |
| 1143 Profile* profile = browser_view_->browser()->profile(); | 1155 Profile* profile = browser_view_->browser()->profile(); |
| 1144 size_t index = cache.GetIndexOfProfileWithPath(profile->GetPath()); | 1156 size_t index = cache.GetIndexOfProfileWithPath(profile->GetPath()); |
| 1145 if (index != std::string::npos) { | 1157 if (index != std::string::npos) { |
| 1146 avatar_button_->SetIcon(cache.GetAvatarIconOfProfileAtIndex(index)); | 1158 avatar_button_->SetIcon(cache.GetAvatarIconOfProfileAtIndex(index)); |
| 1147 avatar_button_->SetText(cache.GetNameOfProfileAtIndex(index)); | 1159 avatar_button_->SetText(cache.GetNameOfProfileAtIndex(index)); |
| 1148 } | 1160 } |
| 1149 } | 1161 } |
| 1150 } | 1162 } |
| OLD | NEW |