summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views
diff options
context:
space:
mode:
authorbeng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-01 17:05:27 +0000
committerbeng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-01 17:05:27 +0000
commita533eb4a0e924b8c0cab7a3964c127ce0d5f8185 (patch)
tree86c1755b210da306c6f0f938741e4c0c63039586 /chrome/browser/views
parentcb4996397f1857ada4419fd166abf4567aa3556e (diff)
downloadchromium_src-a533eb4a0e924b8c0cab7a3964c127ce0d5f8185.zip
chromium_src-a533eb4a0e924b8c0cab7a3964c127ce0d5f8185.tar.gz
chromium_src-a533eb4a0e924b8c0cab7a3964c127ce0d5f8185.tar.bz2
Adds the BrowserView to the XPFrame/VistaFrame, and moves the BrowserToolbarView and StatusBubble into it.
Also restructures the creation of the Frame. This is significant! The Browser now constructs a frame via a new static BrowserWindow::CreateBrowserWindow method (see browser_window_factory.cc). Recall the diagram in the architectural overview doc - the BrowserView object is the one that implements the interface that the Browser object uses to communicate with the UI. The Browser object communicates to the BrowserView directly through this interface, but not directly to the frame. What actually happens right now in CreateBrowserWindow is that an XP/VistaFrame is constructed, but this is _not_ the object returned to the Browser, rather when the XP/VistaFrame is init'ed, it constructs a BrowserView that also implements BrowserWindow. This is the object that's returned to the Browser. Since both BrowserView and XP/VistaFrame implement BrowserWindow, I am now able to gradually migrate functionality from the frames to BrowserView. During this process BrowserWindow functions not handled yet by BrowserView will be forwarded to the appropriate frame. Modifies the Accessibility UI tests to account for this extra level of indirection (should only be temporary while I'm moving things around). This does actually pass the UI tests. See the whiteboard in my office for a diagram. This is a bit confusing right now since there's so much going on. Sadly the only way to get where we need to go incrementally is to make a mess on the way. B=1031854 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@245 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views')
-rw-r--r--chrome/browser/views/frame/browser_view.cc120
-rw-r--r--chrome/browser/views/frame/browser_view.h38
-rw-r--r--chrome/browser/views/frame/browser_window_factory.cc52
-rw-r--r--chrome/browser/views/toolbar_view.cc5
-rw-r--r--chrome/browser/views/toolbar_view.h1
5 files changed, 173 insertions, 43 deletions
diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc
index cdbd9c9..c6d73f2 100644
--- a/chrome/browser/views/frame/browser_view.cc
+++ b/chrome/browser/views/frame/browser_view.cc
@@ -29,171 +29,203 @@
#include "chrome/browser/views/frame/browser_view.h"
+#include "chrome/browser/browser.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/tab_contents.h"
#include "chrome/browser/tabs/tab_strip.h"
+#include "chrome/browser/view_ids.h"
#include "chrome/browser/views/bookmark_bar_view.h"
#include "chrome/browser/views/go_button.h"
#include "chrome/browser/views/location_bar_view.h"
#include "chrome/browser/views/status_bubble.h"
#include "chrome/browser/views/toolbar_star_toggle.h"
+#include "chrome/browser/views/toolbar_view.h"
+#include "chrome/common/l10n_util.h"
+#include "generated_resources.h"
+
+// Status Bubble metrics.
+static const int kStatusBubbleHeight = 20;
+static const int kStatusBubbleOffset = 2;
///////////////////////////////////////////////////////////////////////////////
// BrowserView, public:
-BrowserView::BrowserView(ChromeViews::Window* window,
+BrowserView::BrowserView(BrowserWindow* frame,
+ Browser* browser,
+ ChromeViews::Window* window,
ChromeViews::View* contents_view)
- : ClientView(window, contents_view) {
+ : frame_(frame),
+ browser_(browser),
+ initialized_(false)
+/* ,
+ ClientView(window, contents_view) */ {
}
BrowserView::~BrowserView() {
}
+void BrowserView::LayoutStatusBubble(int status_bubble_y) {
+ status_bubble_->SetBounds(kStatusBubbleOffset,
+ status_bubble_y - kStatusBubbleHeight +
+ kStatusBubbleOffset,
+ GetWidth() / 3,
+ kStatusBubbleHeight);
+}
+
///////////////////////////////////////////////////////////////////////////////
// BrowserView, BrowserWindow implementation:
void BrowserView::Init() {
+ SetAccessibleName(l10n_util::GetString(IDS_PRODUCT_NAME));
+ toolbar_ = new BrowserToolbarView(browser_->controller(), browser_);
+ AddChildView(toolbar_);
+ toolbar_->SetID(VIEW_ID_TOOLBAR);
+ toolbar_->Init(browser_->profile());
+ toolbar_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_TOOLBAR));
+
+ status_bubble_.reset(new StatusBubble(GetViewContainer()));
}
void BrowserView::Show(int command, bool adjust_to_fit) {
-
+ frame_->Show(command, adjust_to_fit);
}
void BrowserView::BrowserDidPaint(HRGN region) {
-
+ frame_->BrowserDidPaint(region);
}
void BrowserView::Close() {
-
+ frame_->Close();
}
void* BrowserView::GetPlatformID() {
- return NULL;
+ return frame_->GetPlatformID();
}
TabStrip* BrowserView::GetTabStrip() const {
- return NULL;
+ return frame_->GetTabStrip();
}
StatusBubble* BrowserView::GetStatusBubble() {
- return NULL;
+ return status_bubble_.get();
}
ChromeViews::RootView* BrowserView::GetRootView() {
- return NULL;
+ return frame_->GetRootView();
}
void BrowserView::ShelfVisibilityChanged() {
-
+ frame_->ShelfVisibilityChanged();
}
void BrowserView::SelectedTabToolbarSizeChanged(bool is_animating) {
-
+ frame_->SelectedTabToolbarSizeChanged(is_animating);
}
void BrowserView::UpdateTitleBar() {
-
+ frame_->UpdateTitleBar();
}
void BrowserView::SetWindowTitle(const std::wstring& title) {
-
+ frame_->SetWindowTitle(title);
}
void BrowserView::Activate() {
-
+ frame_->Activate();
}
void BrowserView::FlashFrame() {
-
+ frame_->FlashFrame();
}
void BrowserView::ShowTabContents(TabContents* contents) {
-
+ frame_->ShowTabContents(contents);
}
void BrowserView::ContinueDetachConstrainedWindowDrag(
const gfx::Point& mouse_pt,
int frame_component) {
-
+ frame_->ContinueDetachConstrainedWindowDrag(mouse_pt, frame_component);
}
void BrowserView::SizeToContents(const gfx::Rect& contents_bounds) {
-
+ frame_->SizeToContents(contents_bounds);
}
void BrowserView::SetAcceleratorTable(
std::map<ChromeViews::Accelerator, int>* accelerator_table) {
-
+ frame_->SetAcceleratorTable(accelerator_table);
}
void BrowserView::ValidateThrobber() {
-
+ frame_->ValidateThrobber();
}
gfx::Rect BrowserView::GetNormalBounds() {
- return gfx::Rect();
+ return frame_->GetNormalBounds();
}
bool BrowserView::IsMaximized() {
- return false;
+ return frame_->IsMaximized();
}
gfx::Rect BrowserView::GetBoundsForContentBounds(const gfx::Rect content_rect) {
- return gfx::Rect();
-}
-
-void BrowserView::SetBounds(const gfx::Rect& bounds) {
-
+ return frame_->GetBoundsForContentBounds(content_rect);
}
void BrowserView::DetachFromBrowser() {
-
+ frame_->DetachFromBrowser();
}
void BrowserView::InfoBubbleShowing() {
-
+ frame_->InfoBubbleShowing();
}
void BrowserView::InfoBubbleClosing() {
-
+ frame_->InfoBubbleClosing();
}
ToolbarStarToggle* BrowserView::GetStarButton() const {
- return NULL;
+ return toolbar_->star_button();
}
LocationBarView* BrowserView::GetLocationBarView() const {
- return NULL;
+ return toolbar_->GetLocationBarView();
}
GoButton* BrowserView::GetGoButton() const {
- return NULL;
+ return toolbar_->GetGoButton();
}
BookmarkBarView* BrowserView::GetBookmarkBarView() {
+ return frame_->GetBookmarkBarView();
+}
+
+BrowserView* BrowserView::GetBrowserView() const {
return NULL;
}
void BrowserView::Update(TabContents* contents, bool should_restore_state) {
-
+ toolbar_->Update(contents, should_restore_state);
}
void BrowserView::ProfileChanged(Profile* profile) {
-
+ toolbar_->SetProfile(profile);
}
void BrowserView::FocusToolbar() {
-
+ toolbar_->RequestFocus();
}
void BrowserView::DestroyBrowser() {
-
+ frame_->DestroyBrowser();
}
///////////////////////////////////////////////////////////////////////////////
// BrowserView, ChromeViews::ClientView overrides:
+/*
bool BrowserView::CanClose() const {
return true;
}
@@ -201,17 +233,27 @@ bool BrowserView::CanClose() const {
int BrowserView::NonClientHitTest(const gfx::Point& point) {
return HTCLIENT;
}
+*/
///////////////////////////////////////////////////////////////////////////////
// BrowserView, ChromeViews::View overrides:
void BrowserView::Layout() {
+ toolbar_->SetBounds(0, 0, GetWidth(), GetHeight());
+}
+void BrowserView::DidChangeBounds(const CRect& previous,
+ const CRect& current) {
+ Layout();
}
void BrowserView::ViewHierarchyChanged(bool is_add,
ChromeViews::View* parent,
ChromeViews::View* child) {
-
-
+ if (is_add && child == this && GetViewContainer() && !initialized_) {
+ Init();
+ // Make sure not to call Init() twice if we get inserted into a different
+ // ViewContainer.
+ initialized_ = true;
+ }
}
diff --git a/chrome/browser/views/frame/browser_view.h b/chrome/browser/views/frame/browser_view.h
index 7f59388..5920ed7 100644
--- a/chrome/browser/views/frame/browser_view.h
+++ b/chrome/browser/views/frame/browser_view.h
@@ -36,6 +36,9 @@
// NOTE: For more information about the objects and files in this directory,
// view: https://sites.google.com/a/google.com/the-chrome-project/developers/design-documents/browser-window
+class Browser;
+class BrowserToolbarView;
+
///////////////////////////////////////////////////////////////////////////////
// BrowserView
//
@@ -43,11 +46,19 @@
// including the TabStrip, toolbars, download shelves, the content area etc.
//
class BrowserView : public BrowserWindow,
- public ChromeViews::ClientView {
+/* public ChromeViews::ClientView */
+ public ChromeViews::View {
public:
- BrowserView(ChromeViews::Window* window, ChromeViews::View* contents_view);
+ BrowserView(BrowserWindow* frame,
+ Browser* browser,
+ ChromeViews::Window* window,
+ ChromeViews::View* contents_view);
virtual ~BrowserView();
+ // TODO(beng): remove this once all layout is done inside this object.
+ // Layout the Status bubble relative to position.
+ void LayoutStatusBubble(int status_bubble_y);
+
// Overridden from BrowserWindow:
virtual void Init();
virtual void Show(int command, bool adjust_to_fit);
@@ -74,7 +85,6 @@ class BrowserView : public BrowserWindow,
virtual gfx::Rect GetNormalBounds();
virtual bool IsMaximized();
virtual gfx::Rect GetBoundsForContentBounds(const gfx::Rect content_rect);
- virtual void SetBounds(const gfx::Rect& bounds);
virtual void DetachFromBrowser();
virtual void InfoBubbleShowing();
virtual void InfoBubbleClosing();
@@ -82,23 +92,43 @@ class BrowserView : public BrowserWindow,
virtual LocationBarView* GetLocationBarView() const;
virtual GoButton* GetGoButton() const;
virtual BookmarkBarView* GetBookmarkBarView();
+ virtual BrowserView* GetBrowserView() const;
virtual void Update(TabContents* contents, bool should_restore_state);
virtual void ProfileChanged(Profile* profile);
virtual void FocusToolbar();
virtual void DestroyBrowser();
+ /*
// Overridden from ChromeViews::ClientView:
virtual bool CanClose() const;
virtual int NonClientHitTest(const gfx::Point& point);
+ */
- protected:
// Overridden from ChromeViews::View:
virtual void Layout();
+ virtual void DidChangeBounds(const CRect& previous, const CRect& current);
virtual void ViewHierarchyChanged(bool is_add,
ChromeViews::View* parent,
ChromeViews::View* child);
private:
+ // The Browser object we are associated with.
+ // TODO(beng): (Cleanup) this should become a scoped_ptr.
+ Browser* browser_;
+
+ // The Toolbar containing the navigation buttons, menus and the address bar.
+ BrowserToolbarView* toolbar_;
+
+ // The Status information bubble that appears at the bottom of the window.
+ scoped_ptr<StatusBubble> status_bubble_;
+
+ // Temporary pointer to containing BrowserWindow.
+ // TODO(beng): convert this to a BrowserFrame*.
+ BrowserWindow* frame_;
+
+ // True if we have already been initialized.
+ bool initialized_;
+
DISALLOW_EVIL_CONSTRUCTORS(BrowserView);
};
diff --git a/chrome/browser/views/frame/browser_window_factory.cc b/chrome/browser/views/frame/browser_window_factory.cc
new file mode 100644
index 0000000..0742245
--- /dev/null
+++ b/chrome/browser/views/frame/browser_window_factory.cc
@@ -0,0 +1,52 @@
+// Copyright 2008, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#include "chrome/browser/browser.h"
+#include "chrome/browser/browser_window.h"
+#include "chrome/browser/frame_util.h"
+#include "chrome/browser/views/frame/browser_view.h"
+
+///////////////////////////////////////////////////////////////////////////////
+// BrowserWindow, public:
+
+// static
+BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser,
+ const gfx::Rect& bounds,
+ int show_command) {
+ // TODO(beng): fix this hack.
+ // To get us off the ground and allow us to incrementally migrate
+ // BrowserWindow functionality from XP/VistaFrame to BrowserView,
+ // all objects need to implement the BrowserWindow interface.
+ // However BrowserView is the one that Browser has a ref to, and
+ // calls that BrowserView can't perform directly are passed on to
+ // its frame. Eventually this will be better, I promise.
+ BrowserWindow* window = FrameUtil::CreateBrowserWindow(bounds, browser);
+ return window->GetBrowserView();
+}
+
diff --git a/chrome/browser/views/toolbar_view.cc b/chrome/browser/views/toolbar_view.cc
index cc99296..056cbfe 100644
--- a/chrome/browser/views/toolbar_view.cc
+++ b/chrome/browser/views/toolbar_view.cc
@@ -343,6 +343,11 @@ void BrowserToolbarView::Layout() {
page_menu_->GetY(), sz.cx, go_->GetHeight());
}
+void BrowserToolbarView::DidChangeBounds(const CRect& previous,
+ const CRect& current) {
+ Layout();
+}
+
void BrowserToolbarView::DidGainFocus() {
// Find first accessible child (-1 for start search at parent).
int first_acc_child = GetNextAccessibleViewIndex(-1, false);
diff --git a/chrome/browser/views/toolbar_view.h b/chrome/browser/views/toolbar_view.h
index 29d9f19..6869a59 100644
--- a/chrome/browser/views/toolbar_view.h
+++ b/chrome/browser/views/toolbar_view.h
@@ -72,6 +72,7 @@ class BrowserToolbarView : public ChromeViews::View,
// ChromeViews::View
virtual void Layout();
+ virtual void DidChangeBounds(const CRect& previous, const CRect& current);
virtual void DidGainFocus();
virtual void WillLoseFocus();
virtual bool OnKeyPressed(const ChromeViews::KeyEvent& e);