| 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/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
| 12 #include "base/profiler/scoped_tracker.h" | 12 #include "base/profiler/scoped_tracker.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "chrome/browser/profiles/profiles_state.h" | 14 #include "chrome/browser/profiles/profiles_state.h" |
| 15 #include "chrome/browser/signin/signin_header_helper.h" | 15 #include "chrome/browser/signin/signin_header_helper.h" |
| 16 #include "chrome/browser/themes/theme_properties.h" | 16 #include "chrome/browser/themes/theme_properties.h" |
| 17 #include "chrome/browser/ui/views/frame/browser_frame.h" | 17 #include "chrome/browser/ui/views/frame/browser_frame.h" |
| 18 #include "chrome/browser/ui/views/frame/browser_view.h" | 18 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 19 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.h" | 19 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.h" |
| 20 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view_platform_speci
fic.h" | 20 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view_platform_speci
fic.h" |
| 21 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h" | 21 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h" |
| 22 #include "chrome/browser/ui/views/profiles/new_avatar_button.h" | 22 #include "chrome/browser/ui/views/profiles/new_avatar_button.h" |
| 23 #include "chrome/browser/ui/views/tab_icon_view.h" | 23 #include "chrome/browser/ui/views/tab_icon_view.h" |
| 24 #include "chrome/browser/ui/views/tabs/tab_strip.h" | 24 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
| 25 #include "chrome/browser/ui/views/theme_image_mapper.h" | |
| 26 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" | 25 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" |
| 27 #include "chrome/grit/generated_resources.h" | 26 #include "chrome/grit/generated_resources.h" |
| 28 #include "components/signin/core/common/profile_management_switches.h" | 27 #include "components/signin/core/common/profile_management_switches.h" |
| 29 #include "content/public/browser/notification_service.h" | 28 #include "content/public/browser/notification_service.h" |
| 30 #include "content/public/browser/web_contents.h" | 29 #include "content/public/browser/web_contents.h" |
| 31 #include "grit/theme_resources.h" | 30 #include "grit/theme_resources.h" |
| 32 #include "ui/accessibility/ax_view_state.h" | 31 #include "ui/accessibility/ax_view_state.h" |
| 33 #include "ui/base/hit_test.h" | 32 #include "ui/base/hit_test.h" |
| 34 #include "ui/base/l10n/l10n_util.h" | 33 #include "ui/base/l10n/l10n_util.h" |
| 35 #include "ui/base/resource/resource_bundle.h" | 34 #include "ui/base/resource/resource_bundle.h" |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 * So we'd need to sample the background color at the right location and | 472 * So we'd need to sample the background color at the right location and |
| 474 * synthesize a good shadow color. */ | 473 * synthesize a good shadow color. */ |
| 475 | 474 |
| 476 if (browser_view()->IsToolbarVisible()) | 475 if (browser_view()->IsToolbarVisible()) |
| 477 PaintToolbarBackground(canvas); | 476 PaintToolbarBackground(canvas); |
| 478 if (!layout_->IsTitleBarCondensed()) | 477 if (!layout_->IsTitleBarCondensed()) |
| 479 PaintRestoredClientEdge(canvas); | 478 PaintRestoredClientEdge(canvas); |
| 480 } | 479 } |
| 481 | 480 |
| 482 // BrowserNonClientFrameView: | 481 // BrowserNonClientFrameView: |
| 482 bool OpaqueBrowserFrameView::ShouldPaintAsThemed() const { |
| 483 // Theme app and popup windows if |platform_observer_| wants it. |
| 484 return browser_view()->IsBrowserTypeNormal() || |
| 485 platform_observer_->IsUsingSystemTheme(); |
| 486 } |
| 487 |
| 483 void OpaqueBrowserFrameView::UpdateNewStyleAvatar() { | 488 void OpaqueBrowserFrameView::UpdateNewStyleAvatar() { |
| 484 UpdateNewStyleAvatarInfo(this, NewAvatarButton::THEMED_BUTTON); | 489 UpdateNewStyleAvatarInfo(this, NewAvatarButton::THEMED_BUTTON); |
| 485 } | 490 } |
| 486 | 491 |
| 487 /////////////////////////////////////////////////////////////////////////////// | 492 /////////////////////////////////////////////////////////////////////////////// |
| 488 // OpaqueBrowserFrameView, private: | 493 // OpaqueBrowserFrameView, private: |
| 489 | 494 |
| 490 // views::NonClientFrameView: | 495 // views::NonClientFrameView: |
| 491 bool OpaqueBrowserFrameView::DoesIntersectRect(const views::View* target, | 496 bool OpaqueBrowserFrameView::DoesIntersectRect(const views::View* target, |
| 492 const gfx::Rect& rect) const { | 497 const gfx::Rect& rect) const { |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 831 client_area_bottom + kClientEdgeThickness - client_area_top), | 836 client_area_bottom + kClientEdgeThickness - client_area_top), |
| 832 toolbar_color); | 837 toolbar_color); |
| 833 canvas->FillRect(gfx::Rect(client_area_bounds.x(), client_area_bottom, | 838 canvas->FillRect(gfx::Rect(client_area_bounds.x(), client_area_bottom, |
| 834 client_area_bounds.width(), kClientEdgeThickness), | 839 client_area_bounds.width(), kClientEdgeThickness), |
| 835 toolbar_color); | 840 toolbar_color); |
| 836 canvas->FillRect(gfx::Rect(client_area_bounds.right(), client_area_top, | 841 canvas->FillRect(gfx::Rect(client_area_bounds.right(), client_area_top, |
| 837 kClientEdgeThickness, | 842 kClientEdgeThickness, |
| 838 client_area_bottom + kClientEdgeThickness - client_area_top), | 843 client_area_bottom + kClientEdgeThickness - client_area_top), |
| 839 toolbar_color); | 844 toolbar_color); |
| 840 } | 845 } |
| 841 | |
| 842 SkColor OpaqueBrowserFrameView::GetFrameColor() const { | |
| 843 bool is_incognito = browser_view()->IsOffTheRecord(); | |
| 844 ThemeProperties::OverwritableByUserThemeProperty color_id; | |
| 845 if (ShouldPaintAsActive()) { | |
| 846 color_id = is_incognito ? | |
| 847 ThemeProperties::COLOR_FRAME_INCOGNITO : | |
| 848 ThemeProperties::COLOR_FRAME; | |
| 849 } else { | |
| 850 color_id = is_incognito ? | |
| 851 ThemeProperties::COLOR_FRAME_INCOGNITO_INACTIVE : | |
| 852 ThemeProperties::COLOR_FRAME_INACTIVE; | |
| 853 } | |
| 854 | |
| 855 if (browser_view()->IsBrowserTypeNormal() || | |
| 856 platform_observer_->IsUsingSystemTheme()) { | |
| 857 return GetThemeProvider()->GetColor(color_id); | |
| 858 } | |
| 859 | |
| 860 // Never theme app and popup windows unless the |platform_observer_| | |
| 861 // requested an override. | |
| 862 return ThemeProperties::GetDefaultColor(color_id); | |
| 863 } | |
| 864 | |
| 865 gfx::ImageSkia* OpaqueBrowserFrameView::GetFrameImage() const { | |
| 866 bool is_incognito = browser_view()->IsOffTheRecord(); | |
| 867 int resource_id; | |
| 868 if (browser_view()->IsBrowserTypeNormal()) { | |
| 869 if (ShouldPaintAsActive()) { | |
| 870 resource_id = is_incognito ? | |
| 871 IDR_THEME_FRAME_INCOGNITO : IDR_THEME_FRAME; | |
| 872 } else { | |
| 873 resource_id = is_incognito ? | |
| 874 IDR_THEME_FRAME_INCOGNITO_INACTIVE : IDR_THEME_FRAME_INACTIVE; | |
| 875 } | |
| 876 return GetThemeProvider()->GetImageSkiaNamed(resource_id); | |
| 877 } | |
| 878 if (ShouldPaintAsActive()) { | |
| 879 resource_id = is_incognito ? | |
| 880 IDR_THEME_FRAME_INCOGNITO : IDR_FRAME; | |
| 881 } else { | |
| 882 resource_id = is_incognito ? | |
| 883 IDR_THEME_FRAME_INCOGNITO_INACTIVE : IDR_THEME_FRAME_INACTIVE; | |
| 884 } | |
| 885 | |
| 886 if (platform_observer_->IsUsingSystemTheme()) { | |
| 887 // We want to use theme images provided by the system theme when enabled, | |
| 888 // even if we are an app or popup window. | |
| 889 return GetThemeProvider()->GetImageSkiaNamed(resource_id); | |
| 890 } | |
| 891 | |
| 892 // Otherwise, never theme app and popup windows. | |
| 893 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | |
| 894 return rb.GetImageSkiaNamed(chrome::MapThemeImage( | |
| 895 chrome::GetHostDesktopTypeForNativeWindow( | |
| 896 browser_view()->GetNativeWindow()), | |
| 897 resource_id)); | |
| 898 } | |
| 899 | |
| 900 gfx::ImageSkia* OpaqueBrowserFrameView::GetFrameOverlayImage() const { | |
| 901 ui::ThemeProvider* tp = GetThemeProvider(); | |
| 902 if (tp->HasCustomImage(IDR_THEME_FRAME_OVERLAY) && | |
| 903 browser_view()->IsBrowserTypeNormal() && | |
| 904 !browser_view()->IsOffTheRecord()) { | |
| 905 return tp->GetImageSkiaNamed(ShouldPaintAsActive() ? | |
| 906 IDR_THEME_FRAME_OVERLAY : IDR_THEME_FRAME_OVERLAY_INACTIVE); | |
| 907 } | |
| 908 return nullptr; | |
| 909 } | |
| 910 | |
| 911 int OpaqueBrowserFrameView::GetTopAreaHeight() const { | |
| 912 gfx::ImageSkia* frame_image = GetFrameImage(); | |
| 913 int top_area_height = frame_image->height(); | |
| 914 if (browser_view()->IsTabStripVisible()) { | |
| 915 top_area_height = std::max(top_area_height, | |
| 916 GetBoundsForTabStrip(browser_view()->tabstrip()).bottom()); | |
| 917 } | |
| 918 return top_area_height; | |
| 919 } | |
| OLD | NEW |