summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/cocoa/download_shelf_controller.mm3
-rw-r--r--chrome/browser/cocoa/download_shelf_mac.h4
-rw-r--r--chrome/browser/cocoa/download_shelf_mac.mm2
-rw-r--r--chrome/browser/download/download_shelf.cc11
-rw-r--r--chrome/browser/download/download_shelf.h19
-rw-r--r--chrome/browser/gtk/download_shelf_gtk.cc4
-rw-r--r--chrome/browser/gtk/download_shelf_gtk.h4
-rw-r--r--chrome/browser/views/download_shelf_view.cc4
-rw-r--r--chrome/browser/views/download_shelf_view.h4
9 files changed, 21 insertions, 34 deletions
diff --git a/chrome/browser/cocoa/download_shelf_controller.mm b/chrome/browser/cocoa/download_shelf_controller.mm
index a8ebd5c..d6bbf83 100644
--- a/chrome/browser/cocoa/download_shelf_controller.mm
+++ b/chrome/browser/cocoa/download_shelf_controller.mm
@@ -7,6 +7,7 @@
#include "app/l10n_util.h"
#include "base/mac_util.h"
#include "base/sys_string_conversions.h"
+#include "chrome/browser/browser.h"
#import "chrome/browser/cocoa/browser_window_controller.h"
#include "chrome/browser/cocoa/browser_window_cocoa.h"
#include "chrome/browser/cocoa/download_item_controller.h"
@@ -84,7 +85,7 @@ const int kDownloadItemPadding = 10;
- (BOOL)textView:(NSTextView *)aTextView
clickedOnLink:(id)link
atIndex:(NSUInteger)charIndex {
- bridge_->ShowAllDownloads();
+ bridge_->browser()->ShowDownloadsTab();
return YES;
}
diff --git a/chrome/browser/cocoa/download_shelf_mac.h b/chrome/browser/cocoa/download_shelf_mac.h
index 61736c1..5b45e37 100644
--- a/chrome/browser/cocoa/download_shelf_mac.h
+++ b/chrome/browser/cocoa/download_shelf_mac.h
@@ -33,8 +33,12 @@ class DownloadShelfMac : public DownloadShelf {
virtual bool IsClosing() const;
virtual void Show();
virtual void Close();
+ virtual Browser* browser() const { return browser_; }
private:
+ // The browser that owns this shelf.
+ Browser* browser_;
+
DownloadShelfController* shelf_controller_; // weak, owns us
};
diff --git a/chrome/browser/cocoa/download_shelf_mac.mm b/chrome/browser/cocoa/download_shelf_mac.mm
index f18377e..0323ff1 100644
--- a/chrome/browser/cocoa/download_shelf_mac.mm
+++ b/chrome/browser/cocoa/download_shelf_mac.mm
@@ -10,7 +10,7 @@
DownloadShelfMac::DownloadShelfMac(Browser* browser,
DownloadShelfController* controller)
- : DownloadShelf(browser),
+ : browser_(browser),
shelf_controller_(controller) {
Show();
}
diff --git a/chrome/browser/download/download_shelf.cc b/chrome/browser/download/download_shelf.cc
index 1db9173..d3d6ade 100644
--- a/chrome/browser/download/download_shelf.cc
+++ b/chrome/browser/download/download_shelf.cc
@@ -15,17 +15,6 @@
#include "chrome/common/url_constants.h"
#include "grit/generated_resources.h"
-
-// DownloadShelf ---------------------------------------------------------------
-
-void DownloadShelf::ShowAllDownloads() {
- Profile* profile = browser_->profile();
- if (profile)
- UserMetrics::RecordAction(L"ShowDownloads", profile);
- browser_->OpenURL(GURL(chrome::kChromeUIDownloadsURL), GURL(),
- NEW_FOREGROUND_TAB, PageTransition::AUTO_BOOKMARK);
-}
-
// DownloadShelfContextMenu ----------------------------------------------------
DownloadShelfContextMenu::DownloadShelfContextMenu(
diff --git a/chrome/browser/download/download_shelf.h b/chrome/browser/download/download_shelf.h
index c0d3c09..61cae0e 100644
--- a/chrome/browser/download/download_shelf.h
+++ b/chrome/browser/download/download_shelf.h
@@ -14,24 +14,15 @@ class BaseDownloadItemModel;
class Browser;
class DownloadItem;
-// DownloadShelf is an interface for platform-specific download shelves to
-// implement. It also contains some shared logic. This class should not be
-// instantiated directly, but rather created via a call to Create().
-// It is a view object.
+// DownloadShelf is an interface for platform-specific download shelf views.
class DownloadShelf {
public:
- explicit DownloadShelf(Browser* browser)
- : browser_(browser) { DCHECK(browser_); }
-
virtual ~DownloadShelf() { }
// A new download has started, so add it to our shelf. This object will
// take ownership of |download_model|. Also make the shelf visible.
virtual void AddDownload(BaseDownloadItemModel* download_model) = 0;
- // Invoked when the user clicks the 'show all downloads' link button.
- void ShowAllDownloads();
-
// The browser view needs to know when we are going away to properly return
// the resize corner size to WebKit so that we don't draw on top of it.
// This returns the showing state of our animation which is set to true at
@@ -47,13 +38,7 @@ class DownloadShelf {
// Closes the shelf.
virtual void Close() = 0;
- Browser* browser() { return browser_; }
-
- protected:
- Browser* browser_;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(DownloadShelf);
+ virtual Browser* browser() const = 0;
};
// Logic for the download shelf context menu. Platform specific subclasses are
diff --git a/chrome/browser/gtk/download_shelf_gtk.cc b/chrome/browser/gtk/download_shelf_gtk.cc
index cfeb22e..d95cb46 100644
--- a/chrome/browser/gtk/download_shelf_gtk.cc
+++ b/chrome/browser/gtk/download_shelf_gtk.cc
@@ -49,7 +49,7 @@ const int kShelfAnimationDurationMs = 120;
} // namespace
DownloadShelfGtk::DownloadShelfGtk(Browser* browser, GtkWidget* parent)
- : DownloadShelf(browser),
+ : browser_(browser),
is_showing_(false),
theme_provider_(GtkThemeProvider::GetFrom(browser->profile())) {
// Logically, the shelf is a vbox that contains two children: a one pixel
@@ -213,6 +213,6 @@ void DownloadShelfGtk::OnButtonClick(GtkWidget* button,
shelf->Close();
} else {
// The link button was clicked.
- shelf->ShowAllDownloads();
+ shelf->browser_->ShowDownloadsTab();
}
}
diff --git a/chrome/browser/gtk/download_shelf_gtk.h b/chrome/browser/gtk/download_shelf_gtk.h
index ae7923b..80d7b85 100644
--- a/chrome/browser/gtk/download_shelf_gtk.h
+++ b/chrome/browser/gtk/download_shelf_gtk.h
@@ -36,6 +36,7 @@ class DownloadShelfGtk : public DownloadShelf,
virtual bool IsClosing() const;
virtual void Show();
virtual void Close();
+ virtual Browser* browser() const { return browser_; }
// Overridden from NotificationObserver:
virtual void Observe(NotificationType type,
@@ -57,6 +58,9 @@ class DownloadShelfGtk : public DownloadShelf,
static void OnButtonClick(GtkWidget* button, DownloadShelfGtk* toolbar);
+ // The browser that owns this download shelf.
+ Browser* browser_;
+
// The top level widget of the shelf.
scoped_ptr<SlideAnimatorGtk> slide_widget_;
diff --git a/chrome/browser/views/download_shelf_view.cc b/chrome/browser/views/download_shelf_view.cc
index 723f60c..dcd7c01 100644
--- a/chrome/browser/views/download_shelf_view.cc
+++ b/chrome/browser/views/download_shelf_view.cc
@@ -72,7 +72,7 @@ int CenterPosition(int size, int target_size) {
} // namespace
DownloadShelfView::DownloadShelfView(Browser* browser, BrowserView* parent)
- : DownloadShelf(browser), parent_(parent) {
+ : browser_(browser), parent_(parent) {
parent->AddChildView(this);
Init();
}
@@ -285,7 +285,7 @@ bool DownloadShelfView::CanFitFirstDownloadItem() {
}
void DownloadShelfView::LinkActivated(views::Link* source, int event_flags) {
- ShowAllDownloads();
+ browser_->ShowDownloadsTab();
}
void DownloadShelfView::ButtonPressed(views::Button* button) {
diff --git a/chrome/browser/views/download_shelf_view.h b/chrome/browser/views/download_shelf_view.h
index 8b72aab..3cf6cea 100644
--- a/chrome/browser/views/download_shelf_view.h
+++ b/chrome/browser/views/download_shelf_view.h
@@ -61,6 +61,7 @@ class DownloadShelfView : public DownloadShelf,
virtual bool IsClosing() const;
virtual void Show();
virtual void Close();
+ virtual Browser* browser() const { return browser_; }
// Removes a specified download view. The supplied view is deleted after
// it's removed.
@@ -80,6 +81,9 @@ class DownloadShelfView : public DownloadShelf,
// Returns true if the shelf is wide enough to show the first download item.
bool CanFitFirstDownloadItem();
+ // The browser for this shelf.
+ Browser* browser_;
+
// The animation for adding new items to the shelf.
scoped_ptr<SlideAnimation> new_item_animation_;