OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/webui/active_downloads_ui.h" | 5 #include "chrome/browser/ui/webui/active_downloads_ui.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
107 virtual void ModelChanged(); | 107 virtual void ModelChanged(); |
108 | 108 |
109 // WebUI Callbacks. | 109 // WebUI Callbacks. |
110 void HandleGetDownloads(const ListValue* args); | 110 void HandleGetDownloads(const ListValue* args); |
111 void HandlePauseToggleDownload(const ListValue* args); | 111 void HandlePauseToggleDownload(const ListValue* args); |
112 void HandleCancelDownload(const ListValue* args); | 112 void HandleCancelDownload(const ListValue* args); |
113 void HandleAllowDownload(const ListValue* args); | 113 void HandleAllowDownload(const ListValue* args); |
114 void OpenNewFullWindow(const ListValue* args); | 114 void OpenNewFullWindow(const ListValue* args); |
115 void PlayMediaFile(const ListValue* args); | 115 void PlayMediaFile(const ListValue* args); |
116 | 116 |
117 // For testing. | |
118 typedef std::vector<DownloadItem*> DownloadList; | |
119 const DownloadList& downloads() const { return downloads_; } | |
120 | |
117 private: | 121 private: |
118 // Downloads helpers. | 122 // Downloads helpers. |
119 DownloadItem* GetDownloadById(const ListValue* args); | 123 DownloadItem* GetDownloadById(const ListValue* args); |
120 void UpdateDownloadList(); | 124 void UpdateDownloadList(); |
121 void SendDownloads(); | 125 void SendDownloads(); |
122 void AddDownload(DownloadItem* item); | 126 void AddDownload(DownloadItem* item); |
123 bool SelectTab(const GURL& url); | 127 bool SelectTab(const GURL& url); |
124 | 128 |
125 Profile* profile_; | 129 Profile* profile_; |
126 TabContents* tab_contents_; | 130 TabContents* tab_contents_; |
127 DownloadManager* download_manager_; | 131 DownloadManager* download_manager_; |
128 | 132 |
129 typedef std::vector<DownloadItem*> DownloadList; | |
130 DownloadList active_downloads_; | 133 DownloadList active_downloads_; |
131 DownloadList downloads_; | 134 DownloadList downloads_; |
132 | 135 |
133 DISALLOW_COPY_AND_ASSIGN(ActiveDownloadsHandler); | 136 DISALLOW_COPY_AND_ASSIGN(ActiveDownloadsHandler); |
134 }; | 137 }; |
135 | 138 |
136 //////////////////////////////////////////////////////////////////////////////// | 139 //////////////////////////////////////////////////////////////////////////////// |
137 // | 140 // |
138 // ActiveDownloadsUIHTMLSource | 141 // ActiveDownloadsUIHTMLSource |
139 // | 142 // |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
426 | 429 |
427 if (url.SchemeIs(chrome::kChromeUIScheme) && | 430 if (url.SchemeIs(chrome::kChromeUIScheme) && |
428 url.host() == chrome::kChromeUIActiveDownloadsHost) { | 431 url.host() == chrome::kChromeUIActiveDownloadsHost) { |
429 return (*it); | 432 return (*it); |
430 } | 433 } |
431 } | 434 } |
432 } | 435 } |
433 return NULL; | 436 return NULL; |
434 } | 437 } |
435 | 438 |
439 const ActiveDownloadsUI::DownloadList& ActiveDownloadsUI::GetDownloads() const { | |
440 DCHECK_EQ(handlers_.size(), size_t(2)); | |
441 ActiveDownloadsHandler* handler = | |
442 static_cast<ActiveDownloadsHandler*>(handlers_[1]); | |
achuithb
2011/06/22 22:50:50
I don't like this either :/
xiyuan
2011/06/22 23:01:03
Me neither. What is the other handler here? How co
achuithb
2011/06/23 02:56:38
The other handler is the GenericHandler that all W
| |
443 return handler->downloads(); | |
444 } | |
OLD | NEW |