summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorbeng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-05 17:02:31 +0000
committerbeng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-05 17:02:31 +0000
commite1109c6bb01438970e99d221cab79982ad273440 (patch)
tree2cec6904338b9d80d2ea324ee61459aca068eef4 /chrome
parent45549f3e41d3688039cc9cfca2363186afbc1f12 (diff)
downloadchromium_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')
-rw-r--r--chrome/browser/browser.cc1
-rw-r--r--chrome/browser/browser.h1
-rw-r--r--chrome/browser/browser_window.h5
-rw-r--r--chrome/browser/tabs/tab_strip.cc3
-rw-r--r--chrome/browser/views/frame/aero_glass_frame.cc9
-rw-r--r--chrome/browser/views/frame/aero_glass_frame.h3
-rw-r--r--chrome/browser/views/frame/browser_frame.h10
-rw-r--r--chrome/browser/views/frame/browser_view2.cc80
-rw-r--r--chrome/browser/views/frame/browser_view2.h6
-rw-r--r--chrome/browser/views/frame/opaque_frame.cc12
-rw-r--r--chrome/browser/views/frame/opaque_frame.h3
-rw-r--r--chrome/browser/views/frame/opaque_non_client_view.cc13
-rw-r--r--chrome/browser/views/frame/opaque_non_client_view.h4
13 files changed, 144 insertions, 6 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
index 47299ce..b3de4f6 100644
--- a/chrome/browser/browser.cc
+++ b/chrome/browser/browser.cc
@@ -1639,6 +1639,7 @@ void Browser::BuildPopupWindow(TabContents* source,
browser->AddNewContents(source, new_contents,
NEW_FOREGROUND_TAB, gfx::Rect(), true);
+ // TODO(beng): (1031854) Move most of this to the frames!!
// For newly opened popup windows, the incoming width/height
// numbers are for the content area, but x/y are for the actual
// window position. Thus we can't just call MoveContents().
diff --git a/chrome/browser/browser.h b/chrome/browser/browser.h
index a172df8..bc7be72 100644
--- a/chrome/browser/browser.h
+++ b/chrome/browser/browser.h
@@ -386,6 +386,7 @@ class Browser : public TabStripModelDelegate,
friend class XPFrame;
friend class VistaFrame;
friend class SimpleFrame;
+ friend class BrowserView2;
// Tracks invalidates to the UI, see the declaration in the .cc file.
struct UIUpdate;
diff --git a/chrome/browser/browser_window.h b/chrome/browser/browser_window.h
index 10a173c..4e011f6 100644
--- a/chrome/browser/browser_window.h
+++ b/chrome/browser/browser_window.h
@@ -67,6 +67,7 @@ class BrowserWindow {
// default screen.
virtual void Show(int command, bool adjust_to_fit) = 0;
+ // TODO(beng): REMOVE
// Invoked by the browser when painting occurred. This is called as a
// result of calling Browser::Paint()
// TODO(ACW) We really need a cross platform region class to replace
@@ -82,6 +83,7 @@ class BrowserWindow {
// returns an HWND.
virtual void* GetPlatformID() = 0;
+ // TODO(beng): REMOVE (obtain via BrowserFrame).
// Return the TabStrip associated with the frame.
virtual TabStrip* GetTabStrip() const = 0;
@@ -148,13 +150,16 @@ class BrowserWindow {
// If necessary, the appropriate painting is scheduled.
virtual void ValidateThrobber() { }
+ // TODO(beng): RENAME (GetRestoredBounds)
// Returns the nonmaximized bounds of the frame (even if the frame is
// currently maximized or minimized) in terms of the screen coordinates.
virtual gfx::Rect GetNormalBounds() = 0;
+ // TODO(beng): REMOVE?
// Returns true if the frame is maximized (aka zoomed).
virtual bool IsMaximized() = 0;
+ // TODO(beng): REMOVE - this work should be done entirely in the frames.
// Returns the bounds required to accomodate for some contents located at the
// provided rectangle. The result is in whatever coordinate system used for
// |content_rect|.
diff --git a/chrome/browser/tabs/tab_strip.cc b/chrome/browser/tabs/tab_strip.cc
index 0c85bec..c498f0b 100644
--- a/chrome/browser/tabs/tab_strip.cc
+++ b/chrome/browser/tabs/tab_strip.cc
@@ -464,6 +464,9 @@ TabStrip::TabStrip(TabStripModel* model)
}
TabStrip::~TabStrip() {
+ // TODO(beng): (1031854) Restore this line once XPFrame/VistaFrame are dead.
+ //model_->RemoveObserver(this);
+
// Stop any existing Loading Animation timer.
MessageLoop::current()->timer_manager()->StopTimer(
loading_animation_timer_.get());
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: