#include <algorithm>
#include <string>
-#include "base/command_line.h"
#include "base/compiler_specific.h"
#include "base/prefs/pref_service.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/ui/views/tab_icon_view.h"
#include "chrome/browser/ui/views/tabs/tab_strip.h"
#include "chrome/browser/ui/views/toolbar/toolbar_view.h"
-#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/profile_management_switches.h"
#include "content/public/browser/notification_service.h"
content::NotificationService::AllSources());
}
- platform_observer_.reset(
- OpaqueBrowserFrameViewPlatformSpecific::Create(this, layout_));
+ platform_observer_.reset(OpaqueBrowserFrameViewPlatformSpecific::Create(
+ this, layout_, browser_view->browser()->profile()));
}
OpaqueBrowserFrameView::~OpaqueBrowserFrameView() {
// OpaqueBrowserFrameView, OpaqueBrowserFrameViewLayoutDelegate implementation:
bool OpaqueBrowserFrameView::ShouldShowWindowIcon() const {
-#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
- // If using the system title bar, we do not want to show a second title bar
- // inside the client area.
- if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseSystemTitleBar))
- return false;
-#endif
-
views::WidgetDelegate* delegate = frame()->widget_delegate();
return ShouldShowWindowTitleBar() && delegate &&
delegate->ShouldShowWindowIcon();
}
bool OpaqueBrowserFrameView::ShouldShowWindowTitle() const {
-#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
- // If using the system title bar, we do not want to show a second title bar
- // inside the client area.
- if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseSystemTitleBar))
- return false;
-#endif
-
// |delegate| may be NULL if called from callback of InputMethodChanged while
// a window is being destroyed.
// See more discussion at http://crosbug.com/8958
}
bool OpaqueBrowserFrameView::ShouldShowCaptionButtons() const {
-#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
- // Do not show caption buttons if the system title bar is being used.
- if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseSystemTitleBar))
- return false;
-#endif
-
if (!OpaqueBrowserFrameViewLayout::ShouldAddDefaultCaptionButtons())
return false;
return ShouldShowWindowTitleBar();
}
bool OpaqueBrowserFrameView::ShouldShowWindowTitleBar() const {
+#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
+ // Do not show the custom title bar if the system title bar option is enabled.
+ if (!frame()->UseCustomFrame())
+ return false;
+#endif
+
+ // Do not show caption buttons if the window manager is forcefully providing a
+ // title bar (e.g., in Ubuntu Unity, if the window is maximized).
if (!views::ViewsDelegate::views_delegate)
return true;
return !views::ViewsDelegate::views_delegate->WindowManagerProvidesTitleBar(
SkColor OpaqueBrowserFrameView::GetFrameColor() const {
bool is_incognito = browser_view()->IsOffTheRecord();
- if (browser_view()->IsBrowserTypeNormal()) {
- if (ShouldPaintAsActive()) {
- return GetThemeProvider()->GetColor(is_incognito ?
- ThemeProperties::COLOR_FRAME_INCOGNITO :
- ThemeProperties::COLOR_FRAME);
- }
- return GetThemeProvider()->GetColor(is_incognito ?
- ThemeProperties::COLOR_FRAME_INCOGNITO_INACTIVE :
- ThemeProperties::COLOR_FRAME_INACTIVE);
- }
- // Never theme app and popup windows.
+ ThemeProperties::OverwritableByUserThemeProperty color_id;
if (ShouldPaintAsActive()) {
- return ThemeProperties::GetDefaultColor(is_incognito ?
- ThemeProperties::COLOR_FRAME_INCOGNITO : ThemeProperties::COLOR_FRAME);
+ color_id = is_incognito ?
+ ThemeProperties::COLOR_FRAME_INCOGNITO :
+ ThemeProperties::COLOR_FRAME;
+ } else {
+ color_id = is_incognito ?
+ ThemeProperties::COLOR_FRAME_INCOGNITO_INACTIVE :
+ ThemeProperties::COLOR_FRAME_INACTIVE;
+ }
+
+ if (browser_view()->IsBrowserTypeNormal() ||
+ platform_observer_->IsUsingNativeTheme()) {
+ return GetThemeProvider()->GetColor(color_id);
}
- return ThemeProperties::GetDefaultColor(is_incognito ?
- ThemeProperties::COLOR_FRAME_INCOGNITO_INACTIVE :
- ThemeProperties::COLOR_FRAME_INACTIVE);
+
+ // Never theme app and popup windows unless the |platform_observer_|
+ // requested an override.
+ return ThemeProperties::GetDefaultColor(color_id);
}
gfx::ImageSkia* OpaqueBrowserFrameView::GetFrameImage() const {
}
return GetThemeProvider()->GetImageSkiaNamed(resource_id);
}
- // Never theme app and popup windows.
- ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
if (ShouldPaintAsActive()) {
resource_id = is_incognito ?
IDR_THEME_FRAME_INCOGNITO : IDR_FRAME;
resource_id = is_incognito ?
IDR_THEME_FRAME_INCOGNITO_INACTIVE : IDR_THEME_FRAME_INACTIVE;
}
+
+ if (platform_observer_->IsUsingNativeTheme()) {
+ // We want to use theme images provided by the platform theme when enabled,
+ // even if we are an app or popup window.
+ return GetThemeProvider()->GetImageSkiaNamed(resource_id);
+ }
+
+ // Otherwise, never theme app and popup windows.
+ ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
return rb.GetImageSkiaNamed(resource_id);
}