Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / views / frame / browser_non_client_frame_view_ash.h
index e103236..b1abdb6 100644 (file)
@@ -5,15 +5,19 @@
 #ifndef CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_NON_CLIENT_FRAME_VIEW_ASH_H_
 #define CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_NON_CLIENT_FRAME_VIEW_ASH_H_
 
+#include "ash/shell_observer.h"
 #include "base/gtest_prod_util.h"
 #include "base/memory/scoped_ptr.h"
+#include "chrome/browser/command_observer.h"
 #include "chrome/browser/ui/views/frame/browser_non_client_frame_view.h"
 #include "chrome/browser/ui/views/tab_icon_view_model.h"
+#include "ui/views/controls/button/button.h"
 
 class TabIconView;
 
 namespace ash {
 class FrameBorderHitTestController;
+class FrameCaptionButton;
 class FrameCaptionButtonContainerView;
 class HeaderPainter;
 }
@@ -22,46 +26,57 @@ class ImageButton;
 class ToggleImageButton;
 }
 
-class BrowserNonClientFrameViewAsh
-    : public BrowserNonClientFrameView,
-      public chrome::TabIconViewModel {
+class BrowserNonClientFrameViewAsh : public BrowserNonClientFrameView,
+                                     public ash::ShellObserver,
+                                     public chrome::TabIconViewModel,
+                                     public CommandObserver,
+                                     public views::ButtonListener {
  public:
   static const char kViewClassName[];
 
   BrowserNonClientFrameViewAsh(BrowserFrame* frame, BrowserView* browser_view);
-  virtual ~BrowserNonClientFrameViewAsh();
+  ~BrowserNonClientFrameViewAsh() override;
 
   void Init();
 
-  // BrowserNonClientFrameView overrides:
-  virtual gfx::Rect GetBoundsForTabStrip(views::View* tabstrip) const OVERRIDE;
-  virtual int GetTopInset() const OVERRIDE;
-  virtual int GetThemeBackgroundXInset() const OVERRIDE;
-  virtual void UpdateThrobber(bool running) OVERRIDE;
-
-  // views::NonClientFrameView overrides:
-  virtual gfx::Rect GetBoundsForClientView() const OVERRIDE;
-  virtual gfx::Rect GetWindowBoundsForClientBounds(
-      const gfx::Rect& client_bounds) const OVERRIDE;
-  virtual int NonClientHitTest(const gfx::Point& point) OVERRIDE;
-  virtual void GetWindowMask(const gfx::Size& size,
-                             gfx::Path* window_mask) OVERRIDE;
-  virtual void ResetWindowControls() OVERRIDE;
-  virtual void UpdateWindowIcon() OVERRIDE;
-  virtual void UpdateWindowTitle() OVERRIDE;
-
-  // views::View overrides:
-  virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
-  virtual void Layout() OVERRIDE;
-  virtual const char* GetClassName() const OVERRIDE;
-  virtual bool HitTestRect(const gfx::Rect& rect) const OVERRIDE;
-  virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
-  virtual gfx::Size GetMinimumSize() OVERRIDE;
-  virtual void OnThemeChanged() OVERRIDE;
-
-  // Overridden from chrome::TabIconViewModel:
-  virtual bool ShouldTabIconViewAnimate() const OVERRIDE;
-  virtual gfx::ImageSkia GetFaviconForTabIconView() OVERRIDE;
+  // BrowserNonClientFrameView:
+  gfx::Rect GetBoundsForTabStrip(views::View* tabstrip) const override;
+  int GetTopInset() const override;
+  int GetThemeBackgroundXInset() const override;
+  void UpdateThrobber(bool running) override;
+
+  // views::NonClientFrameView:
+  gfx::Rect GetBoundsForClientView() const override;
+  gfx::Rect GetWindowBoundsForClientBounds(
+      const gfx::Rect& client_bounds) const override;
+  int NonClientHitTest(const gfx::Point& point) override;
+  void GetWindowMask(const gfx::Size& size, gfx::Path* window_mask) override;
+  void ResetWindowControls() override;
+  void UpdateWindowIcon() override;
+  void UpdateWindowTitle() override;
+  void SizeConstraintsChanged() override;
+
+  // views::View:
+  void OnPaint(gfx::Canvas* canvas) override;
+  void Layout() override;
+  const char* GetClassName() const override;
+  void GetAccessibleState(ui::AXViewState* state) override;
+  gfx::Size GetMinimumSize() const override;
+  void ChildPreferredSizeChanged(views::View* child) override;
+
+  // ash::ShellObserver:
+  void OnMaximizeModeStarted() override;
+  void OnMaximizeModeEnded() override;
+
+  // chrome::TabIconViewModel:
+  bool ShouldTabIconViewAnimate() const override;
+  gfx::ImageSkia GetFaviconForTabIconView() override;
+
+  // CommandObserver:
+  void EnabledStateChangedForCommand(int id, bool enabled) override;
+
+  // views::ButtonListener:
+  void ButtonPressed(views::Button* sender, const ui::Event& event) override;
 
  private:
   FRIEND_TEST_ALL_PREFIXES(BrowserNonClientFrameViewAshTest, WindowHeader);
@@ -69,6 +84,12 @@ class BrowserNonClientFrameViewAsh
                            NonImmersiveFullscreen);
   FRIEND_TEST_ALL_PREFIXES(BrowserNonClientFrameViewAshTest,
                            ImmersiveFullscreen);
+  FRIEND_TEST_ALL_PREFIXES(BrowserNonClientFrameViewAshTest,
+                           ToggleMaximizeModeRelayout);
+
+  // views::NonClientFrameView:
+  bool DoesIntersectRect(const views::View* target,
+                         const gfx::Rect& rect) const override;
 
   // Distance between the left edge of the NonClientFrameView and the tab strip.
   int GetTabStripLeftInset() const;
@@ -77,16 +98,24 @@ class BrowserNonClientFrameViewAsh
   // strip.
   int GetTabStripRightInset() const;
 
-  // Returns true if we should use a short header, such as for popup windows.
-  bool UseShortHeader() const;
-
   // Returns true if we should use a super short header with light bars instead
   // of regular tabs. This header is used in immersive fullscreen when the
   // top-of-window views are not revealed.
   bool UseImmersiveLightbarHeaderStyle() const;
 
-  // Layout the incognito icon.
+  // Returns true if the header should be painted so that it looks the same as
+  // the header used for packaged apps. Packaged apps use a different color
+  // scheme than browser windows.
+  bool UsePackagedAppHeaderStyle() const;
+
+  // Returns true if the header should be painted with a WebApp header style.
+  // The WebApp header style has a back button and title along with the usual
+  // accoutrements.
+  bool UseWebAppHeaderStyle() const;
+
+  // Layout the avatar button.
   void LayoutAvatar();
+  void LayoutNewStyleAvatar();
 
   // Returns true if there is anything to paint. Some fullscreen windows do not
   // need their frames painted.
@@ -98,22 +127,19 @@ class BrowserNonClientFrameViewAsh
 
   void PaintToolbarBackground(gfx::Canvas* canvas);
 
-  // Windows without a toolbar need to draw their own line under the header,
-  // above the content area.
+  // Draws the line under the header for windows without a toolbar and not using
+  // the packaged app header style.
   void PaintContentEdge(gfx::Canvas* canvas);
 
-  // Returns the id of the header frame image based on the browser type,
-  // activation state and incognito mode.
-  int GetThemeFrameImageId() const;
-
-  // Returns the id of the header frame overlay image based on the activation
-  // state and incognito mode.
-  // Returns 0 if no overlay image should be used.
-  int GetThemeFrameOverlayImageId() const;
+  // Update the state of the back button.
+  void UpdateBackButtonState(bool enabled);
 
   // View which contains the window controls.
   ash::FrameCaptionButtonContainerView* caption_button_container_;
 
+  // The back button for web app style header.
+  ash::FrameCaptionButton* web_app_back_button_;
+
   // For popups, the window icon.
   TabIconView* window_icon_;