diff options
Diffstat (limited to 'chrome/browser/ui')
-rw-r--r-- | chrome/browser/ui/views/constrained_window_win.cc | 2 | ||||
-rw-r--r-- | chrome/browser/ui/views/frame/browser_frame_win.cc | 63 | ||||
-rw-r--r-- | chrome/browser/ui/views/frame/browser_frame_win.h | 80 | ||||
-rw-r--r-- | chrome/browser/ui/views/frame/browser_view.cc | 24 | ||||
-rw-r--r-- | chrome/browser/ui/views/frame/browser_view.h | 9 |
5 files changed, 83 insertions, 95 deletions
diff --git a/chrome/browser/ui/views/constrained_window_win.cc b/chrome/browser/ui/views/constrained_window_win.cc index e078fc3..fe30134 100644 --- a/chrome/browser/ui/views/constrained_window_win.cc +++ b/chrome/browser/ui/views/constrained_window_win.cc @@ -366,7 +366,7 @@ void ConstrainedWindowFrameView::OnThemeChanged() { void ConstrainedWindowFrameView::ButtonPressed( views::Button* sender, const views::Event& event) { if (sender == close_button_) - container_->ExecuteSystemMenuCommand(SC_CLOSE); + container_->Close(); } //////////////////////////////////////////////////////////////////////////////// diff --git a/chrome/browser/ui/views/frame/browser_frame_win.cc b/chrome/browser/ui/views/frame/browser_frame_win.cc index 54b6e41..d60b767 100644 --- a/chrome/browser/ui/views/frame/browser_frame_win.cc +++ b/chrome/browser/ui/views/frame/browser_frame_win.cc @@ -30,6 +30,8 @@ static const int kTabDragWindowAlpha = 200; // We need to offset the DWMFrame into the toolbar so that the blackness // doesn't show up on our rounded corners. static const int kDWMFrameTopOffset = 3; +// If not -1, windows are shown with this state. +static int explicit_show_state = -1; // static (Factory method.) BrowserFrame* BrowserFrame::Create(BrowserView* browser_view, @@ -39,35 +41,34 @@ BrowserFrame* BrowserFrame::Create(BrowserView* browser_view, return frame; } -// static -const gfx::Font& BrowserFrame::GetTitleFont() { - static gfx::Font* title_font = - new gfx::Font(views::WindowWin::GetWindowTitleFont()); - return *title_font; -} - /////////////////////////////////////////////////////////////////////////////// -// BrowserFrame, public: +// BrowserFrameWin, public: BrowserFrameWin::BrowserFrameWin(BrowserView* browser_view, Profile* profile) : WindowWin(browser_view), browser_view_(browser_view), - root_view_(NULL), - frame_initialized_(false), - profile_(profile) { + root_view_(NULL) { browser_view_->set_frame(this); non_client_view()->SetFrameView(CreateFrameViewForWindow()); // Don't focus anything on creation, selecting a tab will set the focus. set_focus_on_creation(false); } +BrowserFrameWin::~BrowserFrameWin() { +} + void BrowserFrameWin::InitBrowserFrame() { WindowWin::Init(NULL, gfx::Rect()); } -BrowserFrameWin::~BrowserFrameWin() { +// static +void BrowserFrameWin::SetShowState(int state) { + explicit_show_state = state; } +//////////////////////////////////////////////////////////////////////////////// +// BrowserFrameWin, BrowserFrame implementation: + views::Window* BrowserFrameWin::GetWindow() { return this; } @@ -134,7 +135,18 @@ void BrowserFrameWin::TabStripDisplayModeChanged() { } /////////////////////////////////////////////////////////////////////////////// -// BrowserFrame, views::WindowWin overrides: +// BrowserFrameWin, views::WindowWin overrides: + +int BrowserFrameWin::GetShowState() const { + if (explicit_show_state != -1) + return explicit_show_state; + + STARTUPINFO si = {0}; + si.cb = sizeof(si); + si.dwFlags = STARTF_USESHOWWINDOW; + GetStartupInfo(&si); + return si.wShowWindow; +} gfx::Insets BrowserFrameWin::GetClientAreaInsets() const { // Use the default client insets for an opaque frame or a glass popup/app @@ -176,8 +188,8 @@ void BrowserFrameWin::OnInitMenuPopup(HMENU menu, UINT position, browser_view_->PrepareToRunSystemMenu(menu); } -LRESULT BrowserFrameWin::OnMouseActivate(HWND window, UINT hittest_code, - UINT message) { +LRESULT BrowserFrameWin::OnMouseActivate(UINT message, WPARAM w_param, + LPARAM l_param) { return browser_view_->ActivateAppModalDialog() ? MA_NOACTIVATEANDEAT : MA_ACTIVATE; } @@ -230,7 +242,7 @@ void BrowserFrameWin::OnWindowPosChanged(WINDOWPOS* window_pos) { } ThemeProvider* BrowserFrameWin::GetThemeProvider() const { - return profile_->GetThemeProvider(); + return browser_view_->browser()->profile()->GetThemeProvider(); } void BrowserFrameWin::OnScreenReaderDetected() { @@ -239,11 +251,7 @@ void BrowserFrameWin::OnScreenReaderDetected() { } /////////////////////////////////////////////////////////////////////////////// -// BrowserFrame, views::CustomFrameWindow overrides: - -int BrowserFrameWin::GetShowState() const { - return browser_view_->GetShowState(); -} +// BrowserFrameWin, views::Window overrides: void BrowserFrameWin::Activate() { // When running under remote desktop, if the remote desktop client is not @@ -279,7 +287,7 @@ views::RootView* BrowserFrameWin::CreateRootView() { } /////////////////////////////////////////////////////////////////////////////// -// BrowserFrame, private: +// BrowserFrameWin, private: void BrowserFrameWin::UpdateDWMFrame() { // Nothing to do yet, or we're not showing a DWM frame. @@ -310,3 +318,14 @@ void BrowserFrameWin::UpdateDWMFrame() { } DwmExtendFrameIntoClientArea(GetNativeView(), &margins); } + +//////////////////////////////////////////////////////////////////////////////// +// BrowserFrame, public: + +// static +const gfx::Font& BrowserFrame::GetTitleFont() { + static gfx::Font* title_font = + new gfx::Font(views::WindowWin::GetWindowTitleFont()); + return *title_font; +} + diff --git a/chrome/browser/ui/views/frame/browser_frame_win.h b/chrome/browser/ui/views/frame/browser_frame_win.h index 0d5e29b..e2fbaa1 100644 --- a/chrome/browser/ui/views/frame/browser_frame_win.h +++ b/chrome/browser/ui/views/frame/browser_frame_win.h @@ -36,43 +36,49 @@ class BrowserFrameWin : public BrowserFrame, public views::WindowWin { BrowserView* browser_view() const { return browser_view_; } - // BrowserFrame implementation. - virtual views::Window* GetWindow(); - virtual int GetMinimizeButtonOffset() const; - virtual gfx::Rect GetBoundsForTabStrip(views::View* tabstrip) const; - virtual int GetHorizontalTabStripVerticalOffset(bool restored) const; - virtual void UpdateThrobber(bool running); - virtual ui::ThemeProvider* GetThemeProviderForFrame() const; - virtual bool AlwaysUseNativeFrame() const; - virtual views::View* GetFrameView() const; - virtual void TabStripDisplayModeChanged(); + // Explicitly sets how windows are shown. Use a value of -1 to give the + // default behavior. This is used during testing and not generally useful + // otherwise. + static void SetShowState(int state); + + // Overridden from BrowserFrame: + virtual views::Window* GetWindow() OVERRIDE; + virtual int GetMinimizeButtonOffset() const OVERRIDE; + virtual gfx::Rect GetBoundsForTabStrip(views::View* tabstrip) const OVERRIDE; + virtual int GetHorizontalTabStripVerticalOffset(bool restored) const OVERRIDE; + virtual void UpdateThrobber(bool running) OVERRIDE; + virtual ui::ThemeProvider* GetThemeProviderForFrame() const OVERRIDE; + virtual bool AlwaysUseNativeFrame() const OVERRIDE; + virtual views::View* GetFrameView() const OVERRIDE; + virtual void TabStripDisplayModeChanged() OVERRIDE; protected: // Overridden from views::WindowWin: - virtual gfx::Insets GetClientAreaInsets() const; - virtual bool GetAccelerator(int cmd_id, ui::Accelerator* accelerator); - virtual void OnEndSession(BOOL ending, UINT logoff); - virtual void OnEnterSizeMove(); - virtual void OnExitSizeMove(); - virtual void OnInitMenuPopup(HMENU menu, UINT position, BOOL is_system_menu); - virtual LRESULT OnMouseActivate(HWND window, - UINT hittest_code, - UINT message); - virtual void OnMove(const CPoint& point); - virtual void OnMoving(UINT param, LPRECT new_bounds); - virtual LRESULT OnNCActivate(BOOL active); - virtual LRESULT OnNCHitTest(const CPoint& pt); - virtual void OnWindowPosChanged(WINDOWPOS* window_pos); - virtual ui::ThemeProvider* GetThemeProvider() const; - virtual void OnScreenReaderDetected(); + virtual int GetShowState() const OVERRIDE; + virtual gfx::Insets GetClientAreaInsets() const OVERRIDE; + virtual bool GetAccelerator(int cmd_id, ui::Accelerator* accelerator) + OVERRIDE; + virtual void OnEndSession(BOOL ending, UINT logoff) OVERRIDE; + virtual void OnEnterSizeMove() OVERRIDE; + virtual void OnExitSizeMove() OVERRIDE; + virtual void OnInitMenuPopup(HMENU menu, UINT position, BOOL is_system_menu) + OVERRIDE; + virtual LRESULT OnMouseActivate(UINT message, WPARAM w_param, LPARAM l_param) + OVERRIDE; + virtual void OnMove(const CPoint& point) OVERRIDE; + virtual void OnMoving(UINT param, LPRECT new_bounds) OVERRIDE; + virtual LRESULT OnNCActivate(BOOL active) OVERRIDE; + virtual LRESULT OnNCHitTest(const CPoint& pt) OVERRIDE; + virtual void OnWindowPosChanged(WINDOWPOS* window_pos) OVERRIDE; + virtual ui::ThemeProvider* GetThemeProvider() const OVERRIDE; + virtual void OnScreenReaderDetected() OVERRIDE; // Overridden from views::Window: - virtual int GetShowState() const; - virtual void Activate(); - virtual bool IsAppWindow() const { return true; } - virtual views::NonClientFrameView* CreateFrameViewForWindow(); - virtual void UpdateFrameAfterFrameChange(); - virtual views::RootView* CreateRootView(); + virtual void Activate() OVERRIDE; + virtual bool IsAppWindow() const OVERRIDE { return true; } + virtual views::NonClientFrameView* CreateFrameViewForWindow() OVERRIDE; + virtual void UpdateFrameAfterFrameChange() OVERRIDE; + virtual views::RootView* CreateRootView() OVERRIDE; private: // Updates the DWM with the frame bounds. @@ -84,15 +90,11 @@ class BrowserFrameWin : public BrowserFrame, public views::WindowWin { // A pointer to our NonClientFrameView as a BrowserNonClientFrameView. BrowserNonClientFrameView* browser_frame_view_; - // An unowning reference to the root view associated with the window. We save - // a copy as a BrowserRootView to avoid evil casting later, when we need to - // call functions that only exist on BrowserRootView (versus RootView). + // A weak reference to the root view associated with the window. We save a + // copy as a BrowserRootView to avoid evil casting later, when we need to call + // functions that only exist on BrowserRootView (versus RootView). BrowserRootView* root_view_; - bool frame_initialized_; - - Profile* profile_; - DISALLOW_COPY_AND_ASSIGN(BrowserFrameWin); }; diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc index 1b54898..bdbe180 100644 --- a/chrome/browser/ui/views/frame/browser_view.cc +++ b/chrome/browser/ui/views/frame/browser_view.cc @@ -118,9 +118,6 @@ static const int kLoadingAnimationFrameTimeMs = 30; // The amount of space we expect the window border to take up. static const int kWindowBorderWidth = 5; -// If not -1, windows are shown with this state. -static int explicit_show_state = -1; - // How round the 'new tab' style bookmarks bar is. static const int kNewtabBarRoundness = 5; // ------------ @@ -421,11 +418,6 @@ class DownloadInProgressConfirmDialogDelegate : public views::DialogDelegate, /////////////////////////////////////////////////////////////////////////////// // BrowserView, public: -// static -void BrowserView::SetShowState(int state) { - explicit_show_state = state; -} - BrowserView::BrowserView(Browser* browser) : views::ClientView(NULL, NULL), last_focused_view_storage_id_( @@ -506,22 +498,6 @@ BrowserView* BrowserView::GetBrowserViewForNativeWindow( return NULL; } -int BrowserView::GetShowState() const { - if (explicit_show_state != -1) - return explicit_show_state; - -#if defined(OS_WIN) - STARTUPINFO si = {0}; - si.cb = sizeof(si); - si.dwFlags = STARTF_USESHOWWINDOW; - GetStartupInfo(&si); - return si.wShowWindow; -#else - NOTIMPLEMENTED(); - return 0; -#endif -} - void BrowserView::WindowMoved() { // Cancel any tabstrip animations, some of them may be invalidated by the // window being repositioned. diff --git a/chrome/browser/ui/views/frame/browser_view.h b/chrome/browser/ui/views/frame/browser_view.h index f2eaa27..911febc 100644 --- a/chrome/browser/ui/views/frame/browser_view.h +++ b/chrome/browser/ui/views/frame/browser_view.h @@ -88,11 +88,6 @@ class BrowserView : public BrowserBubbleHost, // The browser view's class name. static const char kViewClassName[]; - // Explicitly sets how windows are shown. Use a value of -1 to give the - // default behavior. This is used during testing and not generally useful - // otherwise. - static void SetShowState(int state); - explicit BrowserView(Browser* browser); virtual ~BrowserView(); @@ -107,10 +102,6 @@ class BrowserView : public BrowserBubbleHost, // Returns a Browser instance of this view. Browser* browser() const { return browser_.get(); } - // Returns the show flag that should be used to show the frame containing - // this view. - int GetShowState() const; - // Called by the frame to notify the BrowserView that it was moved, and that // any dependent popup windows should be repositioned. void WindowMoved(); |