- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / views / frame / browser_frame_win.h
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_FRAME_WIN_H_
6 #define CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_FRAME_WIN_H_
7
8 #include "base/basictypes.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "chrome/browser/ui/views/frame/browser_frame.h"
11 #include "chrome/browser/ui/views/frame/minimize_button_metrics_win.h"
12 #include "chrome/browser/ui/views/frame/native_browser_frame.h"
13 #include "ui/views/controls/button/image_button.h"
14 #include "ui/views/widget/native_widget_win.h"
15
16 class BrowserView;
17 class BrowserWindowPropertyManager;
18
19 namespace views {
20 class NativeMenuWin;
21 }
22
23 ////////////////////////////////////////////////////////////////////////////////
24 // BrowserFrameWin
25 //
26 //  BrowserFrameWin is a NativeWidgetWin subclass that provides the window frame
27 //  for the Chrome browser window.
28 //
29 class BrowserFrameWin : public views::NativeWidgetWin,
30                         public NativeBrowserFrame,
31                         public views::ButtonListener {
32  public:
33   BrowserFrameWin(BrowserFrame* browser_frame, BrowserView* browser_view);
34   virtual ~BrowserFrameWin();
35
36   BrowserView* browser_view() const { return browser_view_; }
37
38   // Explicitly sets how windows are shown. Use a value of -1 to give the
39   // default behavior. This is used during testing and not generally useful
40   // otherwise.
41   static void SetShowState(int state);
42
43  protected:
44   // Overridden from views::NativeWidgetWin:
45   virtual int GetInitialShowState() const OVERRIDE;
46   virtual bool GetClientAreaInsets(gfx::Insets* insets) const OVERRIDE;
47   virtual void HandleCreate() OVERRIDE;
48   virtual void HandleFrameChanged() OVERRIDE;
49   virtual bool PreHandleMSG(UINT message,
50                             WPARAM w_param,
51                             LPARAM l_param,
52                             LRESULT* result) OVERRIDE;
53   virtual void PostHandleMSG(UINT message,
54                              WPARAM w_param,
55                              LPARAM l_param) OVERRIDE;
56   virtual bool ShouldUseNativeFrame() const OVERRIDE;
57   virtual void Show() OVERRIDE;
58   virtual void ShowMaximizedWithBounds(
59       const gfx::Rect& restored_bounds) OVERRIDE;
60   virtual void ShowWithWindowState(ui::WindowShowState show_state) OVERRIDE;
61   virtual void Close() OVERRIDE;
62   virtual void FrameTypeChanged() OVERRIDE;
63   virtual void SetFullscreen(bool fullscreen) OVERRIDE;
64   virtual void Activate() OVERRIDE;
65
66   // Overridden from NativeBrowserFrame:
67   virtual views::NativeWidget* AsNativeWidget() OVERRIDE;
68   virtual const views::NativeWidget* AsNativeWidget() const OVERRIDE;
69   virtual bool UsesNativeSystemMenu() const OVERRIDE;
70   virtual int GetMinimizeButtonOffset() const OVERRIDE;
71   virtual void TabStripDisplayModeChanged() OVERRIDE;
72
73   // Overriden from views::ImageButton override:
74   virtual void ButtonPressed(views::Button* sender,
75                              const ui::Event& event) OVERRIDE;
76
77  private:
78   // Updates the DWM with the frame bounds.
79   void UpdateDWMFrame();
80
81   // Handles metro navigation and search requests.
82   void HandleMetroNavSearchRequest(WPARAM w_param, LPARAM l_param);
83
84   // Returns information about the currently displayed tab in metro mode.
85   void GetMetroCurrentTabInfo(WPARAM w_param);
86
87   // Ensures that the window frame follows the Windows 8 metro app guidelines,
88   // i.e. no system menu, etc.
89   void AdjustFrameForImmersiveMode();
90
91   // Called when the frame is closed. Only applies to Windows 8 metro mode.
92   void CloseImmersiveFrame();
93
94   views::NativeMenuWin* GetSystemMenu();
95
96   // The BrowserView is our ClientView. This is a pointer to it.
97   BrowserView* browser_view_;
98
99   BrowserFrame* browser_frame_;
100
101   // The wrapped system menu itself.
102   scoped_ptr<views::NativeMenuWin> system_menu_;
103
104   MinimizeButtonMetrics minimize_button_metrics_;
105
106   scoped_ptr<BrowserWindowPropertyManager> browser_window_property_manager_;
107
108   DISALLOW_COPY_AND_ASSIGN(BrowserFrameWin);
109 };
110
111 // Helper function to create the incognito/normal browser window switcher.
112 views::Button* MakeWindowSwitcherButton(views::ButtonListener* listener,
113                                         bool is_off_the_record);
114
115 #endif  // CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_FRAME_WIN_H_