summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-08 03:37:50 +0000
committerrafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-08 03:37:50 +0000
commit33d396b083d7096f7c44ea76fd4a6765dec75d87 (patch)
tree4f32d32750c5207438c7cd1a2d1ae48944c7c2ab
parent8d80d2d63503442e05c243a2d8bcf61de751434c (diff)
downloadchromium_src-33d396b083d7096f7c44ea76fd4a6765dec75d87.zip
chromium_src-33d396b083d7096f7c44ea76fd4a6765dec75d87.tar.gz
chromium_src-33d396b083d7096f7c44ea76fd4a6765dec75d87.tar.bz2
Add tab menu item to show/hide toolbar for app tabs
Also, never show bookmarks bar on app tabs. BUG=45540 Review URL: http://codereview.chromium.org/2854038 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51825 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/gtk/bookmark_bar_gtk.cc5
-rw-r--r--chrome/browser/gtk/bookmark_bar_gtk.h3
-rw-r--r--chrome/browser/gtk/browser_toolbar_gtk.cc11
-rw-r--r--chrome/browser/gtk/browser_toolbar_gtk.h6
-rw-r--r--chrome/browser/gtk/browser_window_gtk.cc24
-rw-r--r--chrome/browser/gtk/browser_window_gtk.h2
-rw-r--r--chrome/browser/gtk/tabs/tab_gtk.cc4
-rw-r--r--chrome/browser/gtk/tabs/tab_gtk.h6
-rw-r--r--chrome/browser/gtk/tabs/tab_strip_gtk.cc11
-rw-r--r--chrome/browser/gtk/tabs/tab_strip_gtk.h2
10 files changed, 65 insertions, 9 deletions
diff --git a/chrome/browser/gtk/bookmark_bar_gtk.cc b/chrome/browser/gtk/bookmark_bar_gtk.cc
index 57cc618..16bf8a4 100644
--- a/chrome/browser/gtk/bookmark_bar_gtk.cc
+++ b/chrome/browser/gtk/bookmark_bar_gtk.cc
@@ -400,6 +400,11 @@ bool BookmarkBarGtk::OnNewTabPage() {
browser_->GetSelectedTabContents()->ShouldShowBookmarkBar());
}
+bool BookmarkBarGtk::OnAppsPage() const {
+ return (browser_ && browser_->GetSelectedTabContents() &&
+ browser_->GetSelectedTabContents()->is_app());
+}
+
void BookmarkBarGtk::Loaded(BookmarkModel* model) {
// If |instructions_| has been nulled, we are in the middle of browser
// shutdown. Do nothing.
diff --git a/chrome/browser/gtk/bookmark_bar_gtk.h b/chrome/browser/gtk/bookmark_bar_gtk.h
index b00d61a..a70b361 100644
--- a/chrome/browser/gtk/bookmark_bar_gtk.h
+++ b/chrome/browser/gtk/bookmark_bar_gtk.h
@@ -77,6 +77,9 @@ class BookmarkBarGtk : public AnimationDelegate,
// rendering).
bool OnNewTabPage();
+ // True if we're on an extension apps page.
+ bool OnAppsPage() const;
+
// Change the visibility of the bookmarks bar. (Starts out hidden, per GTK's
// default behaviour). There are three visiblity states:
//
diff --git a/chrome/browser/gtk/browser_toolbar_gtk.cc b/chrome/browser/gtk/browser_toolbar_gtk.cc
index a7ac323..e746d6f 100644
--- a/chrome/browser/gtk/browser_toolbar_gtk.cc
+++ b/chrome/browser/gtk/browser_toolbar_gtk.cc
@@ -94,7 +94,8 @@ BrowserToolbarGtk::BrowserToolbarGtk(Browser* browser, BrowserWindowGtk* window)
window_(window),
profile_(NULL),
menu_bar_helper_(this),
- upgrade_reminder_animation_(this) {
+ upgrade_reminder_animation_(this),
+ collapsed_(false) {
browser_->command_updater()->AddCommandObserver(IDC_BACK, this);
browser_->command_updater()->AddCommandObserver(IDC_FORWARD, this);
browser_->command_updater()->AddCommandObserver(IDC_HOME, this);
@@ -288,6 +289,14 @@ LocationBar* BrowserToolbarGtk::GetLocationBar() const {
return location_bar_.get();
}
+void BrowserToolbarGtk::set_collapsed(bool val) {
+ collapsed_ = val;
+ if (collapsed_)
+ Hide();
+ else
+ Show();
+}
+
void BrowserToolbarGtk::UpdateForBookmarkBarVisibility(
bool show_bottom_padding) {
gtk_alignment_set_padding(GTK_ALIGNMENT(alignment_),
diff --git a/chrome/browser/gtk/browser_toolbar_gtk.h b/chrome/browser/gtk/browser_toolbar_gtk.h
index f58b582..6a89f4c 100644
--- a/chrome/browser/gtk/browser_toolbar_gtk.h
+++ b/chrome/browser/gtk/browser_toolbar_gtk.h
@@ -81,6 +81,9 @@ class BrowserToolbarGtk : public CommandUpdater::CommandObserver,
LocationBarViewGtk* GetLocationBarView() { return location_bar_.get(); }
+ bool collapsed() const { return collapsed_; }
+ void set_collapsed(bool val);
+
// We have to show padding on the bottom of the toolbar when the bookmark
// is in floating mode. Otherwise the bookmark bar will paint it for us.
void UpdateForBookmarkBarVisibility(bool show_bottom_padding);
@@ -265,6 +268,9 @@ class BrowserToolbarGtk : public CommandUpdater::CommandObserver,
ThrobAnimation upgrade_reminder_animation_;
+ // When collapsed, the toolbar is just a tiny strip, no controls are visible.
+ bool collapsed_;
+
DISALLOW_COPY_AND_ASSIGN(BrowserToolbarGtk);
};
diff --git a/chrome/browser/gtk/browser_window_gtk.cc b/chrome/browser/gtk/browser_window_gtk.cc
index b39b007..ca2e9c8 100644
--- a/chrome/browser/gtk/browser_window_gtk.cc
+++ b/chrome/browser/gtk/browser_window_gtk.cc
@@ -860,8 +860,7 @@ void BrowserWindowGtk::RotatePaneFocus(bool forwards) {
}
bool BrowserWindowGtk::IsBookmarkBarVisible() const {
- return browser_->SupportsWindowFeature(Browser::FEATURE_BOOKMARKBAR) &&
- bookmark_bar_.get() &&
+ return IsBookmarkBarSupported() && bookmark_bar_.get() &&
browser_->profile()->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar);
}
@@ -1106,6 +1105,10 @@ void BrowserWindowGtk::Paste() {
DoCutCopyPaste(this, &RenderViewHost::Paste, "paste-clipboard");
}
+void BrowserWindowGtk::SetToolbarCollapsedMode(bool val) {
+ toolbar_->set_collapsed(val);
+}
+
void BrowserWindowGtk::ConfirmBrowserCloseWithPendingDownloads() {
new DownloadInProgressDialogGtk(browser());
}
@@ -1207,12 +1210,16 @@ void BrowserWindowGtk::ActiveWindowChanged(GdkWindow* active_window) {
void BrowserWindowGtk::MaybeShowBookmarkBar(TabContents* contents,
bool animate) {
- if (!IsBookmarkBarSupported())
+ if (!IsBookmarkBarSupported()) {
+ // Because the bookmark bar is never shown in app tab windows, we must
+ // explicitly hide to handle the case of switching tabs.
+ bookmark_bar_->Hide(false); //animate
return;
+ }
bool show_bar = false;
- if (IsBookmarkBarSupported() && contents) {
+ if (contents) {
bookmark_bar_->SetProfile(contents->profile());
bookmark_bar_->SetPageNavigator(contents);
show_bar = true;
@@ -2024,11 +2031,16 @@ bool BrowserWindowGtk::IsTabStripSupported() const {
}
bool BrowserWindowGtk::IsToolbarSupported() const {
- return browser_->SupportsWindowFeature(Browser::FEATURE_TOOLBAR) ||
- browser_->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR);
+ return !toolbar_->collapsed() &&
+ (browser_->SupportsWindowFeature(Browser::FEATURE_TOOLBAR) ||
+ browser_->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR));
}
bool BrowserWindowGtk::IsBookmarkBarSupported() const {
+ // We never show the bookmark bar on app tab pages.
+ if (bookmark_bar_.get() && bookmark_bar_->OnAppsPage())
+ return false;
+
return browser_->SupportsWindowFeature(Browser::FEATURE_BOOKMARKBAR);
}
diff --git a/chrome/browser/gtk/browser_window_gtk.h b/chrome/browser/gtk/browser_window_gtk.h
index b62c16e..08b815f 100644
--- a/chrome/browser/gtk/browser_window_gtk.h
+++ b/chrome/browser/gtk/browser_window_gtk.h
@@ -123,7 +123,7 @@ class BrowserWindowGtk : public BrowserWindow,
virtual void Copy();
virtual void Paste();
virtual void ToggleTabStripMode() {}
- virtual void SetToolbarCollapsedMode(bool val) {}
+ virtual void SetToolbarCollapsedMode(bool val);
// Overridden from NotificationObserver:
virtual void Observe(NotificationType type,
diff --git a/chrome/browser/gtk/tabs/tab_gtk.cc b/chrome/browser/gtk/tabs/tab_gtk.cc
index 7383a5e..33a8b75 100644
--- a/chrome/browser/gtk/tabs/tab_gtk.cc
+++ b/chrome/browser/gtk/tabs/tab_gtk.cc
@@ -38,7 +38,9 @@ class TabGtk::ContextMenuController : public menus::SimpleMenuModel::Delegate {
public:
explicit ContextMenuController(TabGtk* tab)
: tab_(tab),
- model_(this, tab->delegate()->IsTabPinned(tab), false, true) {
+ model_(this, tab->delegate()->IsTabPinned(tab),
+ tab->delegate()->IsAppTab(tab),
+ tab->delegate()->IsToolbarVisible(tab)) {
menu_.reset(new MenuGtk(NULL, &model_));
}
diff --git a/chrome/browser/gtk/tabs/tab_gtk.h b/chrome/browser/gtk/tabs/tab_gtk.h
index 6630780..7f0e3fc 100644
--- a/chrome/browser/gtk/tabs/tab_gtk.h
+++ b/chrome/browser/gtk/tabs/tab_gtk.h
@@ -32,9 +32,15 @@ class TabGtk : public TabRendererGtk,
// Returns true if the specified Tab is pinned.
virtual bool IsTabPinned(const TabGtk* tab) const = 0;
+ // Returns true if the specified Tab contains an app.
+ virtual bool IsAppTab(const TabGtk* tab) const = 0;
+
// Returns true if the specified Tab is detached.
virtual bool IsTabDetached(const TabGtk* tab) const = 0;
+ // Returns true if the toolbar is visible for |tab|.
+ virtual bool IsToolbarVisible(const TabGtk* tab) const = 0;
+
// Selects the specified Tab.
virtual void SelectTab(TabGtk* tab) = 0;
diff --git a/chrome/browser/gtk/tabs/tab_strip_gtk.cc b/chrome/browser/gtk/tabs/tab_strip_gtk.cc
index 82b2bd8..affdeae 100644
--- a/chrome/browser/gtk/tabs/tab_strip_gtk.cc
+++ b/chrome/browser/gtk/tabs/tab_strip_gtk.cc
@@ -1084,6 +1084,10 @@ bool TabStripGtk::IsTabDetached(const TabGtk* tab) const {
return false;
}
+bool TabStripGtk::IsToolbarVisible(const TabGtk* tab) const {
+ return model_->IsToolbarVisible(GetIndexOfTab(tab));
+}
+
void TabStripGtk::GetCurrentTabWidths(double* unselected_width,
double* selected_width) const {
*unselected_width = current_unselected_width_;
@@ -1097,6 +1101,13 @@ bool TabStripGtk::IsTabPinned(const TabGtk* tab) const {
return model_->IsTabPinned(GetIndexOfTab(tab));
}
+bool TabStripGtk::IsAppTab(const TabGtk* tab) const {
+ if (tab->closing())
+ return false;
+
+ return model_->IsAppTab(GetIndexOfTab(tab));
+}
+
void TabStripGtk::SelectTab(TabGtk* tab) {
int index = GetIndexOfTab(tab);
if (model_->ContainsIndex(index))
diff --git a/chrome/browser/gtk/tabs/tab_strip_gtk.h b/chrome/browser/gtk/tabs/tab_strip_gtk.h
index 7fe8c60..b0c3f3c 100644
--- a/chrome/browser/gtk/tabs/tab_strip_gtk.h
+++ b/chrome/browser/gtk/tabs/tab_strip_gtk.h
@@ -121,7 +121,9 @@ class TabStripGtk : public TabStripModelObserver,
// TabGtk::TabDelegate implementation:
virtual bool IsTabSelected(const TabGtk* tab) const;
virtual bool IsTabPinned(const TabGtk* tab) const;
+ virtual bool IsAppTab(const TabGtk* tab) const;
virtual bool IsTabDetached(const TabGtk* tab) const;
+ virtual bool IsToolbarVisible(const TabGtk* tab) const;
virtual void SelectTab(TabGtk* tab);
virtual void CloseTab(TabGtk* tab);
virtual bool IsCommandEnabledForTab(