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 "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" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
13 #include "chrome/browser/prefs/pref_service.h" | 13 #include "chrome/browser/prefs/pref_service.h" |
14 #include "chrome/browser/themes/theme_service.h" | 14 #include "chrome/browser/themes/theme_service.h" |
| 15 #include "chrome/browser/ui/browser.h" |
| 16 #include "chrome/browser/ui/search/search.h" |
| 17 #include "chrome/browser/ui/search/search_model.h" |
15 #include "chrome/browser/ui/views/avatar_menu_button.h" | 18 #include "chrome/browser/ui/views/avatar_menu_button.h" |
16 #include "chrome/browser/ui/views/frame/browser_frame.h" | 19 #include "chrome/browser/ui/views/frame/browser_frame.h" |
17 #include "chrome/browser/ui/views/frame/browser_view.h" | 20 #include "chrome/browser/ui/views/frame/browser_view.h" |
18 #include "chrome/browser/ui/views/tabs/tab_strip.h" | 21 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
19 #include "chrome/browser/ui/views/toolbar_view.h" | 22 #include "chrome/browser/ui/views/toolbar_view.h" |
20 #include "chrome/common/chrome_notification_types.h" | 23 #include "chrome/common/chrome_notification_types.h" |
21 #include "chrome/common/chrome_switches.h" | 24 #include "chrome/common/chrome_switches.h" |
22 #include "chrome/common/pref_names.h" | 25 #include "chrome/common/pref_names.h" |
23 #include "content/public/browser/notification_service.h" | 26 #include "content/public/browser/notification_service.h" |
24 #include "content/public/browser/web_contents.h" | 27 #include "content/public/browser/web_contents.h" |
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
640 IDR_CONTENT_TOP_LEFT_CORNER); | 643 IDR_CONTENT_TOP_LEFT_CORNER); |
641 int bottom_edge_height = std::min(toolbar_left->height(), h) - split_point; | 644 int bottom_edge_height = std::min(toolbar_left->height(), h) - split_point; |
642 | 645 |
643 // Split our canvas out so we can mask out the corners of the toolbar | 646 // Split our canvas out so we can mask out the corners of the toolbar |
644 // without masking out the frame. | 647 // without masking out the frame. |
645 canvas->SaveLayerAlpha( | 648 canvas->SaveLayerAlpha( |
646 255, gfx::Rect(x - kClientEdgeThickness, y, w + kClientEdgeThickness * 3, | 649 255, gfx::Rect(x - kClientEdgeThickness, y, w + kClientEdgeThickness * 3, |
647 h)); | 650 h)); |
648 canvas->sk_canvas()->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode); | 651 canvas->sk_canvas()->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode); |
649 | 652 |
| 653 // TODO(kuan): migrate background animation from cros to win by calling |
| 654 // GetToolbarBackgound* with the correct mode, refer to |
| 655 // BrowserNonClientFrameViewAsh. |
| 656 SkColor background_color = browser_view()->GetToolbarBackgroundColor( |
| 657 browser_view()->browser()->search_model()->mode().mode); |
| 658 gfx::ImageSkia* theme_toolbar = browser_view()->GetToolbarBackgroundImage( |
| 659 browser_view()->browser()->search_model()->mode().mode); |
| 660 |
| 661 // Paint the bottom rect. |
650 canvas->FillRect(gfx::Rect(x, bottom_y, w, bottom_edge_height), | 662 canvas->FillRect(gfx::Rect(x, bottom_y, w, bottom_edge_height), |
651 tp->GetColor(ThemeService::COLOR_TOOLBAR)); | 663 background_color); |
652 | 664 |
653 // Tile the toolbar image starting at the frame edge on the left and where the | 665 // Tile the toolbar image starting at the frame edge on the left and where the |
654 // horizontal tabstrip is (or would be) on the top. | 666 // horizontal tabstrip is (or would be) on the top. |
655 gfx::ImageSkia* theme_toolbar = tp->GetImageSkiaNamed(IDR_THEME_TOOLBAR); | |
656 canvas->TileImageInt(*theme_toolbar, x, | 667 canvas->TileImageInt(*theme_toolbar, x, |
657 bottom_y - GetHorizontalTabStripVerticalOffset(false), x, | 668 bottom_y - GetHorizontalTabStripVerticalOffset(false), x, |
658 bottom_y, w, theme_toolbar->height()); | 669 bottom_y, w, theme_toolbar->height()); |
659 | 670 |
660 // Draw rounded corners for the tab. | 671 // Draw rounded corners for the tab. |
661 gfx::ImageSkia* toolbar_left_mask = | 672 gfx::ImageSkia* toolbar_left_mask = |
662 tp->GetImageSkiaNamed(IDR_CONTENT_TOP_LEFT_CORNER_MASK); | 673 tp->GetImageSkiaNamed(IDR_CONTENT_TOP_LEFT_CORNER_MASK); |
663 gfx::ImageSkia* toolbar_right_mask = | 674 gfx::ImageSkia* toolbar_right_mask = |
664 tp->GetImageSkiaNamed(IDR_CONTENT_TOP_RIGHT_CORNER_MASK); | 675 tp->GetImageSkiaNamed(IDR_CONTENT_TOP_RIGHT_CORNER_MASK); |
665 | 676 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
706 | 717 |
707 gfx::ImageSkia* toolbar_right = tp->GetImageSkiaNamed( | 718 gfx::ImageSkia* toolbar_right = tp->GetImageSkiaNamed( |
708 IDR_CONTENT_TOP_RIGHT_CORNER); | 719 IDR_CONTENT_TOP_RIGHT_CORNER); |
709 canvas->DrawImageInt(*toolbar_right, 0, 0, toolbar_right->width(), | 720 canvas->DrawImageInt(*toolbar_right, 0, 0, toolbar_right->width(), |
710 split_point, right_x, y, toolbar_right->width(), split_point, false); | 721 split_point, right_x, y, toolbar_right->width(), split_point, false); |
711 canvas->DrawImageInt(*toolbar_right, 0, | 722 canvas->DrawImageInt(*toolbar_right, 0, |
712 toolbar_right->height() - bottom_edge_height, toolbar_right->width(), | 723 toolbar_right->height() - bottom_edge_height, toolbar_right->width(), |
713 bottom_edge_height, right_x, bottom_y, toolbar_right->width(), | 724 bottom_edge_height, right_x, bottom_y, toolbar_right->width(), |
714 bottom_edge_height, false); | 725 bottom_edge_height, false); |
715 | 726 |
716 // Draw the content/toolbar separator. | 727 // Only draw the content/toolbar separator if Instant Extended API is disabled |
717 canvas->FillRect(gfx::Rect(x + kClientEdgeThickness, | 728 // or mode is DEFAULT. |
718 toolbar_bounds.bottom() - kClientEdgeThickness, | 729 Browser* browser = browser_view()->browser(); |
719 w - (2 * kClientEdgeThickness), | 730 bool extended_instant_enabled = chrome::search::IsInstantExtendedAPIEnabled( |
720 kClientEdgeThickness), | 731 browser->profile()); |
721 ThemeService::GetDefaultColor(ThemeService::COLOR_TOOLBAR_SEPARATOR)); | 732 if (!extended_instant_enabled || |
| 733 browser->search_model()->mode().is_default()) { |
| 734 canvas->FillRect( |
| 735 gfx::Rect(x + kClientEdgeThickness, |
| 736 toolbar_bounds.bottom() - kClientEdgeThickness, |
| 737 w - (2 * kClientEdgeThickness), |
| 738 kClientEdgeThickness), |
| 739 ThemeService::GetDefaultColor(extended_instant_enabled ? |
| 740 ThemeService::COLOR_SEARCH_SEPARATOR_LINE : |
| 741 ThemeService::COLOR_TOOLBAR_SEPARATOR)); |
| 742 } |
722 } | 743 } |
723 | 744 |
724 void OpaqueBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) { | 745 void OpaqueBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) { |
725 ui::ThemeProvider* tp = GetThemeProvider(); | 746 ui::ThemeProvider* tp = GetThemeProvider(); |
726 int client_area_top = frame()->client_view()->y(); | 747 int client_area_top = frame()->client_view()->y(); |
727 int image_top = client_area_top; | 748 int image_top = client_area_top; |
728 | 749 |
729 gfx::Rect client_area_bounds = CalculateClientAreaBounds(width(), height()); | 750 gfx::Rect client_area_bounds = CalculateClientAreaBounds(width(), height()); |
730 SkColor toolbar_color = tp->GetColor(ThemeService::COLOR_TOOLBAR); | 751 SkColor toolbar_color = browser_view()->GetToolbarBackgroundColor( |
| 752 browser_view()->browser()->search_model()->mode().mode); |
731 | 753 |
732 if (browser_view()->IsToolbarVisible()) { | 754 if (browser_view()->IsToolbarVisible()) { |
733 // The client edge images always start below the toolbar corner images. The | 755 // The client edge images always start below the toolbar corner images. The |
734 // client edge filled rects start there or at the bottom of the toolbar, | 756 // client edge filled rects start there or at the bottom of the toolbar, |
735 // whichever is shorter. | 757 // whichever is shorter. |
736 gfx::Rect toolbar_bounds(browser_view()->GetToolbarBounds()); | 758 gfx::Rect toolbar_bounds(browser_view()->GetToolbarBounds()); |
737 image_top += toolbar_bounds.y() + | 759 image_top += toolbar_bounds.y() + |
738 tp->GetImageSkiaNamed(IDR_CONTENT_TOP_LEFT_CORNER)->height(); | 760 tp->GetImageSkiaNamed(IDR_CONTENT_TOP_LEFT_CORNER)->height(); |
739 client_area_top = std::min(image_top, | 761 client_area_top = std::min(image_top, |
740 client_area_top + toolbar_bounds.bottom() - kClientEdgeThickness); | 762 client_area_top + toolbar_bounds.bottom() - kClientEdgeThickness); |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
961 | 983 |
962 gfx::Rect OpaqueBrowserFrameView::CalculateClientAreaBounds(int width, | 984 gfx::Rect OpaqueBrowserFrameView::CalculateClientAreaBounds(int width, |
963 int height) const { | 985 int height) const { |
964 int top_height = NonClientTopBorderHeight(false); | 986 int top_height = NonClientTopBorderHeight(false); |
965 int border_thickness = NonClientBorderThickness(); | 987 int border_thickness = NonClientBorderThickness(); |
966 return gfx::Rect(border_thickness, top_height, | 988 return gfx::Rect(border_thickness, top_height, |
967 std::max(0, width - (2 * border_thickness)), | 989 std::max(0, width - (2 * border_thickness)), |
968 std::max(0, height - GetReservedHeight() - | 990 std::max(0, height - GetReservedHeight() - |
969 top_height - border_thickness)); | 991 top_height - border_thickness)); |
970 } | 992 } |
OLD | NEW |