Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6583)

Unified Diff: chrome/browser/ui/webui/active_downloads_ui.cc

Issue 7241007: Support for testing by providing access to DownloadsList. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/webui/active_downloads_ui.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/active_downloads_ui.cc
===================================================================
--- chrome/browser/ui/webui/active_downloads_ui.cc (revision 89670)
+++ chrome/browser/ui/webui/active_downloads_ui.cc (working copy)
@@ -83,56 +83,6 @@
DISALLOW_COPY_AND_ASSIGN(ActiveDownloadsUIHTMLSource);
};
-// The handler for Javascript messages related to the "active_downloads" view.
achuithb 2011/06/23 02:56:38 This code just moved out of the anonymous namespac
-class ActiveDownloadsHandler
- : public WebUIMessageHandler,
- public DownloadManager::Observer,
- public DownloadItem::Observer {
- public:
- ActiveDownloadsHandler();
- virtual ~ActiveDownloadsHandler();
-
- // Initialization after Attach.
- void Init();
-
- // WebUIMessageHandler implementation.
- virtual WebUIMessageHandler* Attach(WebUI* web_ui);
- virtual void RegisterMessages();
-
- // DownloadItem::Observer interface.
- virtual void OnDownloadUpdated(DownloadItem* item);
- virtual void OnDownloadOpened(DownloadItem* item) { }
-
- // DownloadManager::Observer interface.
- virtual void ModelChanged();
-
- // WebUI Callbacks.
- void HandleGetDownloads(const ListValue* args);
- void HandlePauseToggleDownload(const ListValue* args);
- void HandleCancelDownload(const ListValue* args);
- void HandleAllowDownload(const ListValue* args);
- void OpenNewFullWindow(const ListValue* args);
- void PlayMediaFile(const ListValue* args);
-
- private:
- // Downloads helpers.
- DownloadItem* GetDownloadById(const ListValue* args);
- void UpdateDownloadList();
- void SendDownloads();
- void AddDownload(DownloadItem* item);
- bool SelectTab(const GURL& url);
-
- Profile* profile_;
- TabContents* tab_contents_;
- DownloadManager* download_manager_;
-
- typedef std::vector<DownloadItem*> DownloadList;
- DownloadList active_downloads_;
- DownloadList downloads_;
-
- DISALLOW_COPY_AND_ASSIGN(ActiveDownloadsHandler);
-};
-
////////////////////////////////////////////////////////////////////////////////
//
// ActiveDownloadsUIHTMLSource
@@ -189,12 +139,67 @@
SendResponse(request_id, html_bytes);
}
+} // namespace
+
////////////////////////////////////////////////////////////////////////////////
//
// ActiveDownloadsHandler
//
////////////////////////////////////////////////////////////////////////////////
+// The handler for Javascript messages related to the "active_downloads" view.
+class ActiveDownloadsHandler
+ : public WebUIMessageHandler,
+ public DownloadManager::Observer,
+ public DownloadItem::Observer {
+ public:
+ ActiveDownloadsHandler();
+ virtual ~ActiveDownloadsHandler();
+
+ // Initialization after Attach.
+ void Init();
+
+ // WebUIMessageHandler implementation.
+ virtual WebUIMessageHandler* Attach(WebUI* web_ui);
+ virtual void RegisterMessages();
+
+ // DownloadItem::Observer interface.
+ virtual void OnDownloadUpdated(DownloadItem* item);
+ virtual void OnDownloadOpened(DownloadItem* item) { }
+
+ // DownloadManager::Observer interface.
+ virtual void ModelChanged();
+
+ // WebUI Callbacks.
+ void HandleGetDownloads(const ListValue* args);
+ void HandlePauseToggleDownload(const ListValue* args);
+ void HandleCancelDownload(const ListValue* args);
+ void HandleAllowDownload(const ListValue* args);
+ void OpenNewFullWindow(const ListValue* args);
+ void PlayMediaFile(const ListValue* args);
+
+ // For testing.
+ typedef std::vector<DownloadItem*> DownloadList;
+ const DownloadList& downloads() const { return downloads_; }
+
+ private:
+ // Downloads helpers.
+ DownloadItem* GetDownloadById(const ListValue* args);
+ void UpdateDownloadList();
+ void SendDownloads();
+ void AddDownload(DownloadItem* item);
+ bool SelectTab(const GURL& url);
+
+ Profile* profile_;
+ TabContents* tab_contents_;
+ DownloadManager* download_manager_;
+
+ DownloadList active_downloads_;
+ DownloadList downloads_;
+
+ DISALLOW_COPY_AND_ASSIGN(ActiveDownloadsHandler);
+};
+
ActiveDownloadsHandler::ActiveDownloadsHandler()
: profile_(NULL),
tab_contents_(NULL),
@@ -365,8 +370,6 @@
}
}
-} // namespace
-
////////////////////////////////////////////////////////////////////////////////
//
// ActiveDownloadsUI
@@ -375,10 +378,10 @@
ActiveDownloadsUI::ActiveDownloadsUI(TabContents* contents)
- : HtmlDialogUI(contents) {
- ActiveDownloadsHandler* handler = new ActiveDownloadsHandler();
- AddMessageHandler(handler->Attach(this));
- handler->Init();
+ : HtmlDialogUI(contents),
+ handler_(new ActiveDownloadsHandler()) {
+ AddMessageHandler(handler_->Attach(this));
+ handler_->Init();
ActiveDownloadsUIHTMLSource* html_source = new ActiveDownloadsUIHTMLSource();
// Set up the chrome://active-downloads/ source.
@@ -433,3 +436,6 @@
return NULL;
}
+const ActiveDownloadsUI::DownloadList& ActiveDownloadsUI::GetDownloads() const {
+ return handler_->downloads();
+}
« no previous file with comments | « chrome/browser/ui/webui/active_downloads_ui.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698