diff options
author | beng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-05 17:02:31 +0000 |
---|---|---|
committer | beng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-05 17:02:31 +0000 |
commit | e1109c6bb01438970e99d221cab79982ad273440 (patch) | |
tree | 2cec6904338b9d80d2ea324ee61459aca068eef4 /chrome/browser/views | |
parent | 45549f3e41d3688039cc9cfca2363186afbc1f12 (diff) | |
download | chromium_src-e1109c6bb01438970e99d221cab79982ad273440.zip chromium_src-e1109c6bb01438970e99d221cab79982ad273440.tar.gz chromium_src-e1109c6bb01438970e99d221cab79982ad273440.tar.bz2 |
Grab bag of random cleanups, implementation of some more methods, etc. I'm going to become more methodical about this soon, I promise.
B=1031854
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@377 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views')
-rw-r--r-- | chrome/browser/views/frame/aero_glass_frame.cc | 9 | ||||
-rw-r--r-- | chrome/browser/views/frame/aero_glass_frame.h | 3 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_frame.h | 10 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_view2.cc | 80 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_view2.h | 6 | ||||
-rw-r--r-- | chrome/browser/views/frame/opaque_frame.cc | 12 | ||||
-rw-r--r-- | chrome/browser/views/frame/opaque_frame.h | 3 | ||||
-rw-r--r-- | chrome/browser/views/frame/opaque_non_client_view.cc | 13 | ||||
-rw-r--r-- | chrome/browser/views/frame/opaque_non_client_view.h | 4 |
9 files changed, 134 insertions, 6 deletions
diff --git a/chrome/browser/views/frame/aero_glass_frame.cc b/chrome/browser/views/frame/aero_glass_frame.cc index 4154cc4..ea25bcc 100644 --- a/chrome/browser/views/frame/aero_glass_frame.cc +++ b/chrome/browser/views/frame/aero_glass_frame.cc @@ -88,6 +88,15 @@ int AeroGlassFrame::GetMinimizeButtonOffset() const { /////////////////////////////////////////////////////////////////////////////// // AeroGlassFrame, BrowserFrame implementation: +gfx::Rect AeroGlassFrame::GetWindowBoundsForClientBounds( + const gfx::Rect& client_bounds) { + return gfx::Rect(); +} + +void AeroGlassFrame::SizeToContents(const gfx::Rect& contents_bounds) { + // TODO(beng): implement me. +} + gfx::Rect AeroGlassFrame::GetBoundsForTabStrip(TabStrip* tabstrip) const { return GetAeroGlassNonClientView()->GetBoundsForTabStrip(tabstrip); } diff --git a/chrome/browser/views/frame/aero_glass_frame.h b/chrome/browser/views/frame/aero_glass_frame.h index 5480d5d..f2e18a0 100644 --- a/chrome/browser/views/frame/aero_glass_frame.h +++ b/chrome/browser/views/frame/aero_glass_frame.h @@ -63,6 +63,9 @@ class AeroGlassFrame : public BrowserFrame, int GetMinimizeButtonOffset() const; // Overridden from BrowserFrame: + virtual gfx::Rect GetWindowBoundsForClientBounds( + const gfx::Rect& client_bounds); + virtual void SizeToContents(const gfx::Rect& contents_bounds); virtual gfx::Rect GetBoundsForTabStrip(TabStrip* tabstrip) const; virtual ChromeViews::Window* GetWindow(); diff --git a/chrome/browser/views/frame/browser_frame.h b/chrome/browser/views/frame/browser_frame.h index 0431486..a1d2c4d 100644 --- a/chrome/browser/views/frame/browser_frame.h +++ b/chrome/browser/views/frame/browser_frame.h @@ -48,6 +48,16 @@ class TabStrip; // class BrowserFrame { public: + // TODO(beng): We should _not_ have to expose this method here... it's only + // because BrowserView2 needs it to implement BrowserWindow + // because we're doing popup setup in browser.cc when we + // shouldn't be... + virtual gfx::Rect GetWindowBoundsForClientBounds( + const gfx::Rect& client_bounds) = 0; + + // Sizes the frame assuming the contents view's bounds are as specified. + virtual void SizeToContents(const gfx::Rect& contents_bounds) = 0; + // Returns the bounds that should be used to size and position the specified // TabStrip. virtual gfx::Rect GetBoundsForTabStrip(TabStrip* tabstrip) const = 0; diff --git a/chrome/browser/views/frame/browser_view2.cc b/chrome/browser/views/frame/browser_view2.cc index b042fbd..569ed3d 100644 --- a/chrome/browser/views/frame/browser_view2.cc +++ b/chrome/browser/views/frame/browser_view2.cc @@ -46,6 +46,8 @@ static const int kToolbarTabStripVerticalOverlap = 3; static const int kTabShadowSize = 2; static const int kStatusBubbleHeight = 20; static const int kStatusBubbleOffset = 2; +static const int kSeparationLineHeight = 1; +static const SkColor kSeparationLineColor = SkColorSetRGB(178, 178, 178); /////////////////////////////////////////////////////////////////////////////// // BrowserView2, public: @@ -117,7 +119,7 @@ void* BrowserView2::GetPlatformID() { } TabStrip* BrowserView2::GetTabStrip() const { - return NULL; + return tabstrip_; } StatusBubble* BrowserView2::GetStatusBubble() { @@ -145,15 +147,24 @@ void BrowserView2::SelectedTabToolbarSizeChanged(bool is_animating) { } void BrowserView2::UpdateTitleBar() { + frame_->GetWindow()->UpdateWindowTitle(); } void BrowserView2::SetWindowTitle(const std::wstring& title) { } void BrowserView2::Activate() { + frame_->GetWindow()->Activate(); } void BrowserView2::FlashFrame() { + FLASHWINFO fwi; + fwi.cbSize = sizeof(fwi); + fwi.hwnd = frame_->GetWindow()->GetHWND(); + fwi.dwFlags = FLASHW_ALL; + fwi.uCount = 4; + fwi.dwTimeout = 0; + FlashWindowEx(&fwi); } void BrowserView2::ShowTabContents(TabContents* contents) { @@ -173,6 +184,7 @@ void BrowserView2::ContinueDetachConstrainedWindowDrag( } void BrowserView2::SizeToContents(const gfx::Rect& contents_bounds) { + frame_->SizeToContents(contents_bounds); } void BrowserView2::SetAcceleratorTable( @@ -183,16 +195,20 @@ void BrowserView2::ValidateThrobber() { } gfx::Rect BrowserView2::GetNormalBounds() { - return gfx::Rect(); + WINDOWPLACEMENT wp; + wp.length = sizeof(wp); + const bool ret = !!GetWindowPlacement(frame_->GetWindow()->GetHWND(), &wp); + DCHECK(ret); + return gfx::Rect(wp.rcNormalPosition); } bool BrowserView2::IsMaximized() { - return false; + return frame_->GetWindow()->IsMaximized(); } gfx::Rect BrowserView2::GetBoundsForContentBounds( const gfx::Rect content_rect) { - return gfx::Rect(); + return frame_->GetWindowBoundsForClientBounds(content_rect); } void BrowserView2::DetachFromBrowser() { @@ -268,7 +284,7 @@ std::wstring BrowserView2::GetWindowTitle() const { } ChromeViews::View* BrowserView2::GetInitiallyFocusedView() const { - return NULL; + return GetLocationBarView(); } bool BrowserView2::ShouldShowWindowTitle() const { @@ -290,11 +306,36 @@ void BrowserView2::ExecuteWindowsCommand(int command_id) { } } +void BrowserView2::SaveWindowPosition(const CRect& bounds, + bool maximized, + bool always_on_top) { + // TODO(beng): implement me! + //browser_->SaveWindowPosition(gfx::Rect(bounds), maximized); +} + +bool BrowserView2::RestoreWindowPosition(CRect* bounds, + bool* maximized, + bool* always_on_top) { + DCHECK(bounds && maximized && always_on_top); + *always_on_top = false; + /* TODO(beng): implement this method in Browser + browser_->RestoreWindowPosition(bounds, maximized); + + // We return true because we can _always_ locate reasonable bounds using the + // WindowSizer, and we don't want to trigger the Window's built-in "size to + // default" handling because the browser window has no default preferred + // size. + return true; + */ + // For now, return false to just use whatever was given to us by Browser... + return false; +} + void BrowserView2::WindowClosing() { } ChromeViews::View* BrowserView2::GetContentsView() { - return NULL; + return contents_container_; } ChromeViews::ClientView* BrowserView2::CreateClientView( @@ -307,6 +348,32 @@ ChromeViews::ClientView* BrowserView2::CreateClientView( // BrowserView2, ChromeViews::ClientView overrides: bool BrowserView2::CanClose() const { + // You cannot close a frame for which there is an active originating drag + // session. + if (tabstrip_->IsDragSessionActive()) + return false; + + // Give beforeunload handlers the chance to cancel the close before we hide + // the window below. + if (!browser_->ShouldCloseWindow()) + return false; + + if (!browser_->tabstrip_model()->empty()) { + // Tab strip isn't empty. Hide the frame (so it appears to have closed + // immediately) and close all the tabs, allowing the renderers to shut + // down. When the tab strip is empty we'll be called back again. + frame_->GetWindow()->Hide(); + browser_->OnWindowClosing(); + return false; + } + + // Empty TabStripModel, it's now safe to allow the Window to be closed. + /* + // TODO(beng): for some reason, this won't compile. Figure it out. + NotificationService::current()->Notify( + NOTIFY_WINDOW_CLOSED, Source<HWND>(frame_->GetWindow()->GetHWND()), + NotificationService::NoDetails()); + */ return true; } @@ -416,6 +483,7 @@ int BrowserView2::LayoutBookmarkAndInfoBars(int top) { return LayoutBookmarkBar(top); } // Otherwise, Bookmark bar first, Info bar second. + top -= kSeparationLineHeight; top = LayoutBookmarkBar(top); return LayoutInfoBar(top); } diff --git a/chrome/browser/views/frame/browser_view2.h b/chrome/browser/views/frame/browser_view2.h index 206da40..c643d6a 100644 --- a/chrome/browser/views/frame/browser_view2.h +++ b/chrome/browser/views/frame/browser_view2.h @@ -115,6 +115,12 @@ class BrowserView2 : public BrowserWindow, virtual SkBitmap GetWindowIcon(); virtual bool ShouldShowWindowIcon() const; virtual void ExecuteWindowsCommand(int command_id); + virtual void SaveWindowPosition(const CRect& bounds, + bool maximized, + bool always_on_top); + virtual bool RestoreWindowPosition(CRect* bounds, + bool* maximized, + bool* always_on_top); virtual void WindowClosing(); virtual ChromeViews::View* GetContentsView(); virtual ChromeViews::ClientView* CreateClientView( diff --git a/chrome/browser/views/frame/opaque_frame.cc b/chrome/browser/views/frame/opaque_frame.cc index 77260e1..64794c1 100644 --- a/chrome/browser/views/frame/opaque_frame.cc +++ b/chrome/browser/views/frame/opaque_frame.cc @@ -57,6 +57,18 @@ gfx::Rect OpaqueFrame::GetContentsBounds() const { /////////////////////////////////////////////////////////////////////////////// // OpaqueFrame, BrowserFrame implementation: +gfx::Rect OpaqueFrame::GetWindowBoundsForClientBounds( + const gfx::Rect& client_bounds) { + return GetOpaqueNonClientView()->GetWindowBoundsForClientBounds( + client_bounds); +} + +void OpaqueFrame::SizeToContents(const gfx::Rect& contents_bounds) { + gfx::Rect window_bounds = GetOpaqueNonClientView()-> + GetWindowBoundsForClientBounds(contents_bounds); + SetBounds(window_bounds); +} + gfx::Rect OpaqueFrame::GetBoundsForTabStrip(TabStrip* tabstrip) const { return GetOpaqueNonClientView()->GetBoundsForTabStrip(tabstrip); } diff --git a/chrome/browser/views/frame/opaque_frame.h b/chrome/browser/views/frame/opaque_frame.h index 7730038..a8e31b0 100644 --- a/chrome/browser/views/frame/opaque_frame.h +++ b/chrome/browser/views/frame/opaque_frame.h @@ -62,6 +62,9 @@ class OpaqueFrame : public BrowserFrame, gfx::Rect GetContentsBounds() const; // Overridden from BrowserFrame: + virtual gfx::Rect GetWindowBoundsForClientBounds( + const gfx::Rect& client_bounds); + virtual void SizeToContents(const gfx::Rect& contents_bounds); virtual gfx::Rect GetBoundsForTabStrip(TabStrip* tabstrip) const; virtual ChromeViews::Window* GetWindow(); diff --git a/chrome/browser/views/frame/opaque_non_client_view.cc b/chrome/browser/views/frame/opaque_non_client_view.cc index 4ff345c..8144580 100644 --- a/chrome/browser/views/frame/opaque_non_client_view.cc +++ b/chrome/browser/views/frame/opaque_non_client_view.cc @@ -417,6 +417,19 @@ OpaqueNonClientView::OpaqueNonClientView(OpaqueFrame* frame, bool is_otr) OpaqueNonClientView::~OpaqueNonClientView() { } +gfx::Rect OpaqueNonClientView::GetWindowBoundsForClientBounds( + const gfx::Rect& client_bounds) { + int top_height = CalculateNonClientTopHeight(); + // TODO(beng): support popups. + //top_height += browser_view_->GetToolbarHeightForPopup(); + int window_x = std::max(0, client_bounds.x() - kWindowHorizontalBorderSize); + int window_y = std::max(0, client_bounds.y() - top_height); + int window_w = client_bounds.width() + (2 * kWindowHorizontalBorderSize); + int window_h = + client_bounds.height() + top_height + kWindowVerticalBorderSize; + return gfx::Rect(window_x, window_y, window_w, window_h); +} + gfx::Rect OpaqueNonClientView::GetBoundsForTabStrip(TabStrip* tabstrip) { int tabstrip_height = tabstrip->GetPreferredHeight(); int tabstrip_x = frame_->client_view()->GetX() - 4; diff --git a/chrome/browser/views/frame/opaque_non_client_view.h b/chrome/browser/views/frame/opaque_non_client_view.h index 70de386..fbc54a3 100644 --- a/chrome/browser/views/frame/opaque_non_client_view.h +++ b/chrome/browser/views/frame/opaque_non_client_view.h @@ -47,6 +47,10 @@ class OpaqueNonClientView : public ChromeViews::NonClientView, OpaqueNonClientView(OpaqueFrame* frame, bool is_otr); virtual ~OpaqueNonClientView(); + // Retrieve the bounds of the window for the specified contents bounds. + gfx::Rect GetWindowBoundsForClientBounds(const gfx::Rect& client_bounds); + + // Retrieve the bounds that the specified |tabstrip| will be laid out within. gfx::Rect GetBoundsForTabStrip(TabStrip* tabstrip); protected: |