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

Unified Diff: chrome/browser/dom_ui/filebrowse_ui.cc

Issue 6320007: Updates filebrowser list when download starts/ends. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: fixing unittests Created 9 years, 11 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/dom_ui/filebrowse_ui.cc
diff --git a/chrome/browser/dom_ui/filebrowse_ui.cc b/chrome/browser/dom_ui/filebrowse_ui.cc
index ef5a86794c3d0b021d840bd46c2f8f8455a0bfb3..a30ec7f111ecb8514abeb9e2ceb5a5725ec0be6f 100644
--- a/chrome/browser/dom_ui/filebrowse_ui.cc
+++ b/chrome/browser/dom_ui/filebrowse_ui.cc
@@ -126,7 +126,7 @@ class FilebrowseHandler : public net::DirectoryLister::DirectoryListerDelegate,
// DownloadItem::Observer interface
virtual void OnDownloadUpdated(DownloadItem* download);
- virtual void OnDownloadFileCompleted(DownloadItem* download) { }
+ virtual void OnDownloadFileCompleted(DownloadItem* download);
virtual void OnDownloadOpened(DownloadItem* download) { }
// DownloadManager::Observer interface
@@ -196,6 +196,9 @@ class FilebrowseHandler : public net::DirectoryLister::DirectoryListerDelegate,
private:
+ // Retrieves downloads from the DownloadManager.
+ void GetDownloads();
+
void OpenNewWindow(const ListValue* args, bool popup);
// Clear all download items and their observers.
@@ -711,6 +714,37 @@ void FilebrowseHandler::OpenNewPopupWindow(const ListValue* args) {
OpenNewWindow(args, true);
}
+void FilebrowseHandler::GetDownloads() {
achuithb 2011/01/18 17:53:44 Maybe you could move this function to after the de
altimofeev 2011/01/19 10:29:35 Done.
+ ClearDownloadItems();
+
+ std::vector<DownloadItem*> downloads;
+ download_manager_->GetAllDownloads(FilePath(), &downloads);
+
+ std::vector<DownloadItem*> new_downloads;
+ // Scan for any in progress downloads and add ourself to them as an observer.
+ for (DownloadList::iterator it = downloads.begin();
+ it != downloads.end(); ++it) {
+ DownloadItem* download = *it;
+ // We want to know what happens as the download progresses and be notified
+ // when the user validates the dangerous download.
+ if (download->state() == DownloadItem::IN_PROGRESS ||
+ download->safety_state() == DownloadItem::DANGEROUS) {
+ download->AddObserver(this);
+ active_download_items_.push_back(download);
+ }
+ DownloadList::iterator item = find(download_items_.begin(),
+ download_items_.end(),
+ download);
+ if (item == download_items_.end() && got_first_download_list_) {
+ SendNewDownload(download);
+ }
+ new_downloads.push_back(download);
+ }
+ download_items_.swap(new_downloads);
+ got_first_download_list_ = true;
+ SendCurrentDownloads();
+}
+
void FilebrowseHandler::OpenNewWindow(const ListValue* args, bool popup) {
std::string url = WideToUTF8(ExtractStringValue(args));
Browser* browser = popup ?
@@ -901,38 +935,14 @@ void FilebrowseHandler::HandleGetMetadata(const ListValue* args) {
}
void FilebrowseHandler::HandleGetDownloads(const ListValue* args) {
- ModelChanged();
+ GetDownloads();
}
void FilebrowseHandler::ModelChanged() {
- ClearDownloadItems();
-
- std::vector<DownloadItem*> downloads;
- download_manager_->GetAllDownloads(FilePath(), &downloads);
-
- std::vector<DownloadItem*> new_downloads;
- // Scan for any in progress downloads and add ourself to them as an observer.
- for (DownloadList::iterator it = downloads.begin();
- it != downloads.end(); ++it) {
- DownloadItem* download = *it;
- // We want to know what happens as the download progresses and be notified
- // when the user validates the dangerous download.
- if (download->state() == DownloadItem::IN_PROGRESS ||
- download->safety_state() == DownloadItem::DANGEROUS) {
- download->AddObserver(this);
- active_download_items_.push_back(download);
- }
- DownloadList::iterator item = find(download_items_.begin(),
- download_items_.end(),
- download);
- if (item == download_items_.end() && got_first_download_list_) {
- SendNewDownload(download);
- }
- new_downloads.push_back(download);
- }
- download_items_.swap(new_downloads);
- got_first_download_list_ = true;
- SendCurrentDownloads();
+ if (!currentpath_.empty())
+ GetChildrenForPath(currentpath_, true);
+ else
+ GetDownloads();
}
void FilebrowseHandler::SendNewDownload(DownloadItem* download) {
@@ -1113,6 +1123,10 @@ void FilebrowseHandler::SendCurrentDownloads() {
dom_ui_->CallJavascriptFunction(L"downloadsList", results_value);
}
+void FilebrowseHandler::OnDownloadFileCompleted(DownloadItem* download) {
+ GetChildrenForPath(currentpath_, true);
+}
+
////////////////////////////////////////////////////////////////////////////////
//
// FileBrowseUI
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698