summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbeng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-01 00:26:18 +0000
committerbeng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-01 00:26:18 +0000
commitda5ff696c0007cdb6ded17a9d4fecf6d4294993e (patch)
tree278bc8929945622ea13b26a1d9939d460721b949
parent1ca6df9ae9d23bffa27bb1f5fd19a79a6621939a (diff)
downloadchromium_src-da5ff696c0007cdb6ded17a9d4fecf6d4294993e.zip
chromium_src-da5ff696c0007cdb6ded17a9d4fecf6d4294993e.tar.gz
chromium_src-da5ff696c0007cdb6ded17a9d4fecf6d4294993e.tar.bz2
Move the BookmarkBarView into the frames.
Yes this causes duplicate code, but only for a brief while until I can bring up BrowserView at which point this code will move from the frames to that object. "It gets worse before it gets better". B=1031854 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@213 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/browser.cc17
-rw-r--r--chrome/browser/browser.h7
-rw-r--r--chrome/browser/browser_window.h4
-rw-r--r--chrome/browser/vista_frame.cc31
-rw-r--r--chrome/browser/vista_frame.h11
-rw-r--r--chrome/browser/xp_frame.cc33
-rw-r--r--chrome/browser/xp_frame.h12
7 files changed, 69 insertions, 46 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
index cec09dd..4b4ddb2 100644
--- a/chrome/browser/browser.cc
+++ b/chrome/browser/browser.cc
@@ -303,10 +303,6 @@ Browser::~Browser() {
RemoveObserver(this, NOTIFY_BOOKMARK_BAR_VISIBILITY_PREF_CHANGED,
NotificationService::AllSources());
- ChromeViews::View* p;
- if (bookmark_bar_view_.get() && (p = bookmark_bar_view_->GetParent()))
- p->RemoveChildView(bookmark_bar_view_.get());
-
// Stop hung plugin monitoring.
ticker_.Stop();
ticker_.UnregisterTickHandler(&hung_window_detector_);
@@ -915,19 +911,6 @@ bool Browser::ShouldDisplayURLField() {
return !IsApplication();
}
-BookmarkBarView* Browser::GetBookmarkBarView() {
- TabContents* current_tab = GetSelectedTabContents();
- if (!current_tab || !current_tab->profile())
- return NULL;
-
- if (!bookmark_bar_view_.get())
- bookmark_bar_view_.reset(new BookmarkBarView(current_tab->profile(), this));
- else
- bookmark_bar_view_->SetProfile(current_tab->profile());
- bookmark_bar_view_->SetPageNavigator(current_tab);
- return bookmark_bar_view_.get();
-}
-
void Browser::SaveWindowPlacementToDatabase() {
// We don't want to be the ones who cause lazy initialization of the session
// service. This function gets called during initial window showing, and we
diff --git a/chrome/browser/browser.h b/chrome/browser/browser.h
index 80a9824..ba4133e 100644
--- a/chrome/browser/browser.h
+++ b/chrome/browser/browser.h
@@ -47,7 +47,6 @@
#include "chrome/common/notification_service.h"
#include "chrome/common/pref_member.h"
-class BookmarkBarView;
class BrowserWindow;
class GoButton;
class LocationBarView;
@@ -335,9 +334,6 @@ class Browser : public TabStripModelDelegate,
// point and for the provided hwnd.
void RunSimpleFrameMenu(const CPoint& pt, HWND hwnd);
- // Returns the bookmark bar view, creating if NULL.
- BookmarkBarView* GetBookmarkBarView();
-
// Show some native UI given a URL. If a tab with the same URL is already
// visible in this browser, it becomes selected. Otherwise a new tab is
// created.
@@ -600,9 +596,6 @@ class Browser : public TabStripModelDelegate,
// This browser type.
BrowserType::Type type_;
- // The bookmark bar. This is lazily created.
- scoped_ptr<BookmarkBarView> bookmark_bar_view_;
-
// Lists all UI updates that are pending. We don't update things like the
// URL or tab title right away to avoid flickering and extra painting.
// See ScheduleUIUpdate and ProcessPendingUIUpdates.
diff --git a/chrome/browser/browser_window.h b/chrome/browser/browser_window.h
index 4e06efd..713618a 100644
--- a/chrome/browser/browser_window.h
+++ b/chrome/browser/browser_window.h
@@ -36,6 +36,7 @@
#include "base/gfx/rect.h"
#include "chrome/views/accelerator.h"
+class BookmarkBarView;
class BrowserList;
namespace ChromeViews {
class RootView;
@@ -187,6 +188,9 @@ class BrowserWindow {
// Returns the go button.
virtual GoButton* GetGoButton() const = 0;
+ // Returns the Bookmark Bar view.
+ virtual BookmarkBarView* GetBookmarkBarView() = 0;
+
// Updates the toolbar with the state for the specified |contents|.
virtual void Update(TabContents* contents, bool should_restore_state) = 0;
diff --git a/chrome/browser/vista_frame.cc b/chrome/browser/vista_frame.cc
index a1ddfc6..1ac4d0e 100644
--- a/chrome/browser/vista_frame.cc
+++ b/chrome/browser/vista_frame.cc
@@ -144,6 +144,7 @@ VistaFrame::VistaFrame(Browser* browser)
root_view_(this, true),
tabstrip_(NULL),
toolbar_(NULL),
+ active_bookmark_bar_(NULL),
tab_contents_container_(NULL),
custom_window_enabled_(false),
saved_window_placement_(false),
@@ -318,7 +319,7 @@ void VistaFrame::Layout() {
CSize bookmark_bar_size;
CSize info_bar_size;
- if (bookmark_bar_view_)
+ if (bookmark_bar_view_.get())
bookmark_bar_view_->GetPreferredSize(&bookmark_bar_size);
if (info_bar_view_)
@@ -327,9 +328,9 @@ void VistaFrame::Layout() {
// If we're showing a bookmarks bar in the new tab page style and we
// have an infobar showing, we need to flip them.
if (info_bar_view_ &&
- bookmark_bar_view_ &&
- static_cast<BookmarkBarView*>(bookmark_bar_view_)->IsNewTabPage() &&
- !static_cast<BookmarkBarView*>(bookmark_bar_view_)->IsAlwaysShown()) {
+ bookmark_bar_view_.get() &&
+ bookmark_bar_view_->IsNewTabPage() &&
+ !bookmark_bar_view_->IsAlwaysShown()) {
info_bar_view_->SetBounds(browser_x,
browser_y,
browser_w,
@@ -345,7 +346,7 @@ void VistaFrame::Layout() {
browser_h -= bookmark_bar_size.cy - kSeparationLineHeight;
browser_y += bookmark_bar_size.cy;
} else {
- if (bookmark_bar_view_) {
+ if (bookmark_bar_view_.get()) {
// We want our bookmarks bar to be responsible for drawing its own
// separator, so we let it overlap ours.
browser_y -= kSeparationLineHeight;
@@ -629,6 +630,22 @@ GoButton* VistaFrame::GetGoButton() const {
return toolbar_->GetGoButton();
}
+BookmarkBarView* VistaFrame::GetBookmarkBarView() {
+ TabContents* current_tab = browser_->GetSelectedTabContents();
+ if (!current_tab || !current_tab->profile())
+ return NULL;
+
+ if (!bookmark_bar_view_.get()) {
+ bookmark_bar_view_.reset(new BookmarkBarView(current_tab->profile(),
+ browser_));
+ bookmark_bar_view_->SetParentOwned(false);
+ } else {
+ bookmark_bar_view_->SetProfile(current_tab->profile());
+ }
+ bookmark_bar_view_->SetPageNavigator(current_tab);
+ return bookmark_bar_view_.get();
+}
+
void VistaFrame::Update(TabContents* contents, bool should_restore_state) {
toolbar_->Update(contents, should_restore_state);
}
@@ -1591,9 +1608,9 @@ void VistaFrame::ShelfVisibilityChangedImpl(TabContents* current_tab) {
ChromeViews::View* new_bookmark_bar_view = NULL;
if (SupportsBookmarkBar() && current_tab)
- new_bookmark_bar_view = browser_->GetBookmarkBarView();
+ new_bookmark_bar_view = GetBookmarkBarView();
changed |= UpdateChildViewAndLayout(new_bookmark_bar_view,
- &bookmark_bar_view_);
+ &active_bookmark_bar_);
// Only do a layout if the current contents is non-null. We assume that if the
// contents is NULL, we're either being destroyed, or ShowTabContents is going
diff --git a/chrome/browser/vista_frame.h b/chrome/browser/vista_frame.h
index a545d37..cb9fdff 100644
--- a/chrome/browser/vista_frame.h
+++ b/chrome/browser/vista_frame.h
@@ -49,6 +49,7 @@
#define VISTA_FRAME_CLASSNAME L"Chrome_VistaFrame"
+class BookmarkBarView;
class Browser;
class BrowserToolbarView;
class TabContentsContainerView;
@@ -206,6 +207,7 @@ class VistaFrame : public BrowserWindow,
virtual ToolbarStarToggle* GetStarButton() const;
virtual LocationBarView* GetLocationBarView() const;
virtual GoButton* GetGoButton() const;
+ virtual BookmarkBarView* GetBookmarkBarView();
virtual void Update(TabContents* contents, bool should_restore_state);
virtual void ProfileChanged(Profile* profile);
virtual void FocusToolbar();
@@ -371,6 +373,12 @@ class VistaFrame : public BrowserWindow,
// The Toolbar containing the navigation buttons, menus and the address bar.
BrowserToolbarView* toolbar_;
+ // The bookmark bar. This is lazily created.
+ scoped_ptr<BookmarkBarView> bookmark_bar_view_;
+
+ // The visible bookmark bar. NULL if none is visible.
+ ChromeViews::View* active_bookmark_bar_;
+
// Browser contents
TabContentsContainerView* tab_contents_container_;
@@ -392,9 +400,6 @@ class VistaFrame : public BrowserWindow,
// A view positioned at the bottom of the frame.
ChromeViews::View* shelf_view_;
- // View positioned beneath the tab strip.
- ChromeViews::View* bookmark_bar_view_;
-
// A view positioned beneath the bookmark bar view.
// Implementation mirrors shelf_view_
ChromeViews::View* info_bar_view_;
diff --git a/chrome/browser/xp_frame.cc b/chrome/browser/xp_frame.cc
index 72f8478..8ccd5b9 100644
--- a/chrome/browser/xp_frame.cc
+++ b/chrome/browser/xp_frame.cc
@@ -344,6 +344,7 @@ XPFrame::XPFrame(Browser* browser)
frame_view_(NULL),
tabstrip_(NULL),
toolbar_(NULL),
+ active_bookmark_bar_(NULL),
tab_contents_container_(NULL),
min_button_(NULL),
max_button_(NULL),
@@ -568,7 +569,7 @@ int XPFrame::GetContentsYOrigin() {
if (info_bar_view_)
min_y = std::min(min_y, info_bar_view_->GetY());
- if (bookmark_bar_view_)
+ if (bookmark_bar_view_.get())
min_y = std::min(min_y, bookmark_bar_view_->GetY());
return min_y;
@@ -750,7 +751,7 @@ void XPFrame::Layout() {
CSize bookmark_bar_size;
CSize info_bar_size;
- if (bookmark_bar_view_) {
+ if (bookmark_bar_view_.get()) {
bookmark_bar_view_->GetPreferredSize(&bookmark_bar_size);
bookmark_bar_height = bookmark_bar_size.cy;
}
@@ -761,9 +762,9 @@ void XPFrame::Layout() {
// If we're showing a bookmarks bar in the new tab page style and we
// have an infobar showing, we need to flip them.
if (info_bar_view_ &&
- bookmark_bar_view_ &&
- static_cast<BookmarkBarView*>(bookmark_bar_view_)->IsNewTabPage() &&
- !static_cast<BookmarkBarView*>(bookmark_bar_view_)->IsAlwaysShown()) {
+ bookmark_bar_view_.get() &&
+ bookmark_bar_view_->IsNewTabPage() &&
+ !bookmark_bar_view_->IsAlwaysShown()) {
info_bar_view_->SetBounds(left_margin,
last_y,
client_rect.Width() - left_margin - right_margin,
@@ -781,7 +782,7 @@ void XPFrame::Layout() {
browser_h -= (bookmark_bar_size.cy - kSeparationLineHeight);
last_y += bookmark_bar_size.cy;
} else {
- if (bookmark_bar_view_) {
+ if (bookmark_bar_view_.get()) {
// We want our bookmarks bar to be responsible for drawing its own
// separator, so we let it overlap ours.
last_y -= kSeparationLineHeight;
@@ -1861,6 +1862,22 @@ GoButton* XPFrame::GetGoButton() const {
return toolbar_->GetGoButton();
}
+BookmarkBarView* XPFrame::GetBookmarkBarView() {
+ TabContents* current_tab = browser_->GetSelectedTabContents();
+ if (!current_tab || !current_tab->profile())
+ return NULL;
+
+ if (!bookmark_bar_view_.get()) {
+ bookmark_bar_view_.reset(new BookmarkBarView(current_tab->profile(),
+ browser_));
+ bookmark_bar_view_->SetParentOwned(false);
+ } else {
+ bookmark_bar_view_->SetProfile(current_tab->profile());
+ }
+ bookmark_bar_view_->SetPageNavigator(current_tab);
+ return bookmark_bar_view_.get();
+}
+
void XPFrame::Update(TabContents* contents, bool should_restore_state) {
toolbar_->Update(contents, should_restore_state);
}
@@ -2467,9 +2484,9 @@ void XPFrame::ShelfVisibilityChangedImpl(TabContents* current_tab) {
ChromeViews::View* new_bookmark_bar_view = NULL;
if (SupportsBookmarkBar() && current_tab)
- new_bookmark_bar_view = browser_->GetBookmarkBarView();
+ new_bookmark_bar_view = GetBookmarkBarView();
changed |= UpdateChildViewAndLayout(new_bookmark_bar_view,
- &bookmark_bar_view_);
+ &active_bookmark_bar_);
// Only do a layout if the current contents is non-null. We assume that if the
// contents is NULL, we're either being destroyed, or ShowTabContents is going
diff --git a/chrome/browser/xp_frame.h b/chrome/browser/xp_frame.h
index f500fad..b5f96ff 100644
--- a/chrome/browser/xp_frame.h
+++ b/chrome/browser/xp_frame.h
@@ -49,7 +49,7 @@
#define XP_FRAME_CLASSNAME L"Chrome_XPFrame"
-class ChromeViews::RootView;
+class BookmarkBarView;
class Browser;
class BrowserToolbarView;
class TabContentsContainerView;
@@ -113,6 +113,7 @@ class XPFrame : public BrowserWindow,
virtual ToolbarStarToggle* GetStarButton() const;
virtual LocationBarView* GetLocationBarView() const;
virtual GoButton* GetGoButton() const;
+ virtual BookmarkBarView* GetBookmarkBarView();
virtual void Update(TabContents* contents, bool should_restore_state);
virtual void ProfileChanged(Profile* profile);
virtual void FocusToolbar();
@@ -485,9 +486,6 @@ class XPFrame : public BrowserWindow,
// A view positioned at the bottom of the frame.
ChromeViews::View* shelf_view_;
- // View positioned beneath the tab strip.
- ChromeViews::View* bookmark_bar_view_;
-
// A view positioned beneath the bookmark bar.
// Implementation mirrors shelf_view_
ChromeViews::View* info_bar_view_;
@@ -498,6 +496,12 @@ class XPFrame : public BrowserWindow,
// The Toolbar containing the navigation buttons, menus and the address bar.
BrowserToolbarView* toolbar_;
+ // The bookmark bar. This is lazily created.
+ scoped_ptr<BookmarkBarView> bookmark_bar_view_;
+
+ // The visible bookmark bar. NULL if none is visible.
+ ChromeViews::View* active_bookmark_bar_;
+
// The optional container for the off the record icon.
ChromeViews::ImageView* off_the_record_image_;