Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / views / frame / browser_non_client_frame_view_ash.cc
index 47421a1..19d9161 100644 (file)
@@ -9,15 +9,16 @@
 #include "ash/frame/default_header_painter.h"
 #include "ash/frame/frame_border_hit_test_controller.h"
 #include "ash/frame/header_painter_util.h"
+#include "ash/shell.h"
 #include "base/command_line.h"
 #include "chrome/browser/themes/theme_properties.h"
 #include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/views/avatar_label.h"
-#include "chrome/browser/ui/views/avatar_menu_button.h"
 #include "chrome/browser/ui/views/frame/browser_frame.h"
 #include "chrome/browser/ui/views/frame/browser_header_painter_ash.h"
 #include "chrome/browser/ui/views/frame/browser_view.h"
 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h"
+#include "chrome/browser/ui/views/profiles/avatar_label.h"
+#include "chrome/browser/ui/views/profiles/avatar_menu_button.h"
 #include "chrome/browser/ui/views/tab_icon_view.h"
 #include "chrome/browser/ui/views/tabs/tab_strip.h"
 #include "chrome/common/chrome_switches.h"
@@ -83,14 +84,18 @@ BrowserNonClientFrameViewAsh::BrowserNonClientFrameViewAsh(
       window_icon_(NULL),
       frame_border_hit_test_controller_(
           new ash::FrameBorderHitTestController(frame)) {
+  ash::Shell::GetInstance()->AddShellObserver(this);
 }
 
 BrowserNonClientFrameViewAsh::~BrowserNonClientFrameViewAsh() {
+  ash::Shell::GetInstance()->RemoveShellObserver(this);
 }
 
 void BrowserNonClientFrameViewAsh::Init() {
   caption_button_container_ = new ash::FrameCaptionButtonContainerView(frame(),
       ash::FrameCaptionButtonContainerView::MINIMIZE_ALLOWED);
+  caption_button_container_->UpdateSizeButtonVisibility(
+      ash::Shell::GetInstance()->IsMaximizeModeWindowManagerEnabled());
   AddChildView(caption_button_container_);
 
   // Initializing the TabIconView is expensive, so only do it if we need to.
@@ -119,7 +124,7 @@ void BrowserNonClientFrameViewAsh::Init() {
 }
 
 ///////////////////////////////////////////////////////////////////////////////
-// BrowserNonClientFrameView overrides:
+// BrowserNonClientFrameView:
 
 gfx::Rect BrowserNonClientFrameViewAsh::GetBoundsForTabStrip(
     views::View* tabstrip) const {
@@ -172,7 +177,7 @@ void BrowserNonClientFrameViewAsh::UpdateThrobber(bool running) {
 }
 
 ///////////////////////////////////////////////////////////////////////////////
-// views::NonClientFrameView overrides:
+// views::NonClientFrameView:
 
 gfx::Rect BrowserNonClientFrameViewAsh::GetBoundsForClientView() const {
   // The ClientView must be flush with the top edge of the widget so that the
@@ -241,7 +246,7 @@ void BrowserNonClientFrameViewAsh::UpdateWindowTitle() {
 }
 
 ///////////////////////////////////////////////////////////////////////////////
-// views::View overrides:
+// views::View:
 
 void BrowserNonClientFrameViewAsh::OnPaint(gfx::Canvas* canvas) {
   if (!ShouldPaint())
@@ -337,7 +342,24 @@ gfx::Size BrowserNonClientFrameViewAsh::GetMinimumSize() {
 }
 
 ///////////////////////////////////////////////////////////////////////////////
-// chrome::TabIconViewModel overrides:
+// ash::ShellObserver:
+
+void BrowserNonClientFrameViewAsh::OnMaximizeModeStarted() {
+  caption_button_container_->UpdateSizeButtonVisibility(true);
+  InvalidateLayout();
+  frame()->client_view()->InvalidateLayout();
+  frame()->GetRootView()->Layout();
+}
+
+void BrowserNonClientFrameViewAsh::OnMaximizeModeEnded() {
+  caption_button_container_->UpdateSizeButtonVisibility(false);
+  InvalidateLayout();
+  frame()->client_view()->InvalidateLayout();
+  frame()->GetRootView()->Layout();
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// chrome::TabIconViewModel:
 
 bool BrowserNonClientFrameViewAsh::ShouldTabIconViewAnimate() const {
   // This function is queried during the creation of the window as the
@@ -432,9 +454,9 @@ bool BrowserNonClientFrameViewAsh::ShouldPaint() const {
 void BrowserNonClientFrameViewAsh::PaintImmersiveLightbarStyleHeader(
     gfx::Canvas* canvas) {
   // The light bar header is not themed because theming it does not look good.
-  gfx::ImageSkia* frame_image = GetThemeProvider()->GetImageSkiaNamed(
-      IDR_AURA_BROWSER_WINDOW_HEADER_BASE_MAXIMIZED);
-  canvas->TileImageInt(*frame_image, 0, 0, width(), frame_image->height());
+  canvas->FillRect(
+      gfx::Rect(width(), header_painter_->GetHeaderHeightForPainting()),
+      SK_ColorBLACK);
 }
 
 void BrowserNonClientFrameViewAsh::PaintToolbarBackground(gfx::Canvas* canvas) {