summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-03 17:47:41 +0000
committertc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-03 17:47:41 +0000
commit06f926ef567e9a6d4b29e00e1c8457bd7182bc99 (patch)
treea0604884f155b5d9829ce3fda1e9aa51d46bfa2f
parentc50d0d442ccba35b3455b69e4114955d7e265e56 (diff)
downloadchromium_src-06f926ef567e9a6d4b29e00e1c8457bd7182bc99.zip
chromium_src-06f926ef567e9a6d4b29e00e1c8457bd7182bc99.tar.gz
chromium_src-06f926ef567e9a6d4b29e00e1c8457bd7182bc99.tar.bz2
Move SupportsWindowFeature from BrowserView to Browser so
we can share the code on all platforms. I still left a SupportsWindowFeature method in BrowserView that handles fullscreen mode which is (for now) a Windows specific feature. Review URL: http://codereview.chromium.org/27372 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10804 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/browser.cc15
-rw-r--r--chrome/browser/browser.h14
-rw-r--r--chrome/browser/views/frame/browser_view.cc35
-rw-r--r--chrome/browser/views/frame/browser_view.h15
4 files changed, 40 insertions, 39 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
index 28d2a15..a087bad 100644
--- a/chrome/browser/browser.cc
+++ b/chrome/browser/browser.cc
@@ -978,6 +978,21 @@ void Browser::ShowDownloadsTab() {
ShowSingleDOMUITab(DownloadsUI::GetBaseURL());
}
+bool Browser::SupportsWindowFeature(WindowFeature feature) const {
+ unsigned int features = FEATURE_INFOBAR | FEATURE_DOWNLOADSHELF;
+ if (type() == TYPE_NORMAL)
+ features |= FEATURE_BOOKMARKBAR;
+ if (!window_->IsFullscreen()) {
+ if (type() == TYPE_NORMAL)
+ features |= FEATURE_TABSTRIP | FEATURE_TOOLBAR;
+ else
+ features |= FEATURE_TITLEBAR;
+ if ((type() & Browser::TYPE_APP) == 0)
+ features |= FEATURE_LOCATIONBAR;
+ }
+ return !!(features & feature);
+}
+
void Browser::OpenClearBrowsingDataDialog() {
UserMetrics::RecordAction(L"ClearBrowsingData_ShowDlg", profile_);
window_->ShowClearBrowsingDataDialog();
diff --git a/chrome/browser/browser.h b/chrome/browser/browser.h
index 3fa7973..df519a1 100644
--- a/chrome/browser/browser.h
+++ b/chrome/browser/browser.h
@@ -57,6 +57,17 @@ class Browser : public TabStripModelDelegate,
TYPE_APP_POPUP = TYPE_APP | TYPE_POPUP,
};
+ // Possible elements of the Browser window.
+ enum WindowFeature {
+ FEATURE_TITLEBAR = 1,
+ FEATURE_TABSTRIP = 2,
+ FEATURE_TOOLBAR = 4,
+ FEATURE_LOCATIONBAR = 8,
+ FEATURE_BOOKMARKBAR = 16,
+ FEATURE_INFOBAR = 32,
+ FEATURE_DOWNLOADSHELF = 64
+ };
+
// Constructors, Creation, Showing //////////////////////////////////////////
// Creates a new browser of the given |type| and for the given |profile|. The
@@ -256,6 +267,9 @@ class Browser : public TabStripModelDelegate,
// Show various bits of UI.
void ShowDownloadsTab();
+ // Returns true if the Browser supports the specified feature.
+ bool SupportsWindowFeature(WindowFeature feature) const;
+
// TODO(port): port these, and re-merge the two function declaration lists.
#if defined(OS_WIN)
// Page-related commands.
diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc
index de73484..fc0bca3 100644
--- a/chrome/browser/views/frame/browser_view.cc
+++ b/chrome/browser/views/frame/browser_view.cc
@@ -323,12 +323,12 @@ int BrowserView::GetTabStripHeight() const {
}
bool BrowserView::IsToolbarVisible() const {
- return SupportsWindowFeature(FEATURE_TOOLBAR) ||
- SupportsWindowFeature(FEATURE_LOCATIONBAR);
+ return browser_->SupportsWindowFeature(Browser::FEATURE_TOOLBAR) ||
+ browser_->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR);
}
bool BrowserView::IsTabStripVisible() const {
- return SupportsWindowFeature(FEATURE_TABSTRIP);
+ return browser_->SupportsWindowFeature(Browser::FEATURE_TABSTRIP);
}
bool BrowserView::IsOffTheRecord() const {
@@ -706,7 +706,7 @@ void BrowserView::DestroyBrowser() {
}
bool BrowserView::IsBookmarkBarVisible() const {
- return SupportsWindowFeature(FEATURE_BOOKMARKBAR) &&
+ return browser_->SupportsWindowFeature(Browser::FEATURE_BOOKMARKBAR) &&
active_bookmark_bar_ &&
(active_bookmark_bar_->GetPreferredSize().height() != 0);
}
@@ -972,7 +972,7 @@ views::View* BrowserView::GetInitiallyFocusedView() {
}
bool BrowserView::ShouldShowWindowTitle() const {
- return SupportsWindowFeature(FEATURE_TITLEBAR);
+ return browser_->SupportsWindowFeature(Browser::FEATURE_TITLEBAR);
}
SkBitmap BrowserView::GetWindowIcon() {
@@ -982,7 +982,7 @@ SkBitmap BrowserView::GetWindowIcon() {
}
bool BrowserView::ShouldShowWindowIcon() const {
- return SupportsWindowFeature(FEATURE_TITLEBAR);
+ return browser_->SupportsWindowFeature(Browser::FEATURE_TITLEBAR);
}
bool BrowserView::ExecuteWindowsCommand(int command_id) {
@@ -1289,21 +1289,6 @@ void BrowserView::InitSystemMenu() {
}
}
-bool BrowserView::SupportsWindowFeature(WindowFeature feature) const {
- unsigned int features = FEATURE_INFOBAR | FEATURE_DOWNLOADSHELF;
- if (IsBrowserTypeNormal())
- features |= FEATURE_BOOKMARKBAR;
- if (!fullscreen_) {
- if (IsBrowserTypeNormal())
- features |= FEATURE_TABSTRIP | FEATURE_TOOLBAR;
- else
- features |= FEATURE_TITLEBAR;
- if ((browser_->type() & Browser::TYPE_APP) == 0)
- features |= FEATURE_LOCATIONBAR;
- }
- return !!(features & feature);
-}
-
bool BrowserView::ShouldForwardToTabStrip(
const views::DropTargetEvent& event) {
if (!tabstrip_->IsVisible())
@@ -1395,7 +1380,7 @@ int BrowserView::LayoutBookmarkBar(int top) {
}
int BrowserView::LayoutInfoBar(int top) {
- bool visible = SupportsWindowFeature(FEATURE_INFOBAR);
+ bool visible = browser_->SupportsWindowFeature(Browser::FEATURE_INFOBAR);
int height = visible ? infobar_container_->GetPreferredSize().height() : 0;
infobar_container_->SetVisible(visible);
infobar_container_->SetBounds(0, top, width(), height);
@@ -1409,7 +1394,8 @@ void BrowserView::LayoutTabContents(int top, int bottom) {
int BrowserView::LayoutDownloadShelf() {
int bottom = height();
if (active_download_shelf_) {
- bool visible = SupportsWindowFeature(FEATURE_DOWNLOADSHELF);
+ bool visible = browser_->SupportsWindowFeature(
+ Browser::FEATURE_DOWNLOADSHELF);
int height =
visible ? active_download_shelf_->GetPreferredSize().height() : 0;
active_download_shelf_->SetVisible(visible);
@@ -1433,7 +1419,8 @@ void BrowserView::LayoutStatusBubble(int top) {
bool BrowserView::MaybeShowBookmarkBar(TabContents* contents) {
views::View* new_bookmark_bar_view = NULL;
- if (SupportsWindowFeature(FEATURE_BOOKMARKBAR) && contents) {
+ if (browser_->SupportsWindowFeature(Browser::FEATURE_BOOKMARKBAR)
+ && contents) {
if (!bookmark_bar_view_.get()) {
bookmark_bar_view_.reset(new BookmarkBarView(contents->profile(),
browser_.get()));
diff --git a/chrome/browser/views/frame/browser_view.h b/chrome/browser/views/frame/browser_view.h
index 06dc8da..af9a75f 100644
--- a/chrome/browser/views/frame/browser_view.h
+++ b/chrome/browser/views/frame/browser_view.h
@@ -157,17 +157,6 @@ class BrowserView : public BrowserWindow,
// to add or delete entries.
void PrepareToRunSystemMenu(HMENU menu);
- // Possible elements of the Browser window.
- enum WindowFeature {
- FEATURE_TITLEBAR = 1,
- FEATURE_TABSTRIP = 2,
- FEATURE_TOOLBAR = 4,
- FEATURE_LOCATIONBAR = 8,
- FEATURE_BOOKMARKBAR = 16,
- FEATURE_INFOBAR = 32,
- FEATURE_DOWNLOADSHELF = 64
- };
-
// Returns true if the Browser object associated with this BrowserView is a
// normal-type window (i.e. a browser window, not an app or popup).
bool IsBrowserTypeNormal() const {
@@ -301,10 +290,6 @@ class BrowserView : public BrowserWindow,
// Creates the system menu.
void InitSystemMenu();
- // Returns true if the Browser object associated with this BrowserView
- // supports the specified feature.
- bool SupportsWindowFeature(WindowFeature feature) const;
-
// Returns true if the event should be forwarded to the TabStrip. This
// returns true if y coordinate is less than the bottom of the tab strip, and
// is not over another child view.