Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / views / frame / opaque_browser_frame_view.cc
index 4959ec3..04f1327 100644 (file)
@@ -7,7 +7,6 @@
 #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"
@@ -24,7 +23,6 @@
 #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"
@@ -159,8 +157,8 @@ OpaqueBrowserFrameView::OpaqueBrowserFrameView(BrowserFrame* frame,
                    content::NotificationService::AllSources());
   }
 
-  platform_observer_.reset(
-      OpaqueBrowserFrameViewPlatformSpecific::Create(this, layout_));
+  platform_observer_.reset(OpaqueBrowserFrameViewPlatformSpecific::Create(
+      this, layout_, browser_view->browser()->profile()));
 }
 
 OpaqueBrowserFrameView::~OpaqueBrowserFrameView() {
@@ -431,26 +429,12 @@ void OpaqueBrowserFrameView::Observe(
 // 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
@@ -483,12 +467,6 @@ gfx::Size OpaqueBrowserFrameView::GetBrowserViewMinimumSize() const {
 }
 
 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();
@@ -614,6 +592,14 @@ gfx::Rect OpaqueBrowserFrameView::IconBounds() const {
 }
 
 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(
@@ -868,24 +854,25 @@ void OpaqueBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) {
 
 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 {
@@ -901,8 +888,6 @@ 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;
@@ -910,6 +895,15 @@ gfx::ImageSkia* OpaqueBrowserFrameView::GetFrameImage() const {
     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);
 }