| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/dom_ui/filebrowse_ui.h" | 5 #include "chrome/browser/dom_ui/filebrowse_ui.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 #endif | 120 #endif |
| 121 | 121 |
| 122 // DownloadItem::Observer interface | 122 // DownloadItem::Observer interface |
| 123 virtual void OnDownloadUpdated(DownloadItem* download); | 123 virtual void OnDownloadUpdated(DownloadItem* download); |
| 124 virtual void OnDownloadFileCompleted(DownloadItem* download) { } | 124 virtual void OnDownloadFileCompleted(DownloadItem* download) { } |
| 125 virtual void OnDownloadOpened(DownloadItem* download) { } | 125 virtual void OnDownloadOpened(DownloadItem* download) { } |
| 126 | 126 |
| 127 // DownloadManager::Observer interface | 127 // DownloadManager::Observer interface |
| 128 virtual void ModelChanged(); | 128 virtual void ModelChanged(); |
| 129 | 129 |
| 130 void OnSearchDownloadsComplete(std::vector<DownloadItem*> downloads); | |
| 131 | |
| 132 // Callback for the "getRoots" message. | 130 // Callback for the "getRoots" message. |
| 133 void HandleGetRoots(const Value* value); | 131 void HandleGetRoots(const Value* value); |
| 134 | 132 |
| 135 void GetChildrenForPath(FilePath& path, bool is_refresh); | 133 void GetChildrenForPath(FilePath& path, bool is_refresh); |
| 136 | 134 |
| 137 void OnURLFetchComplete(const URLFetcher* source, | 135 void OnURLFetchComplete(const URLFetcher* source, |
| 138 const GURL& url, | 136 const GURL& url, |
| 139 const URLRequestStatus& status, | 137 const URLRequestStatus& status, |
| 140 int response_code, | 138 int response_code, |
| 141 const ResponseCookies& cookies, | 139 const ResponseCookies& cookies, |
| (...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 960 | 958 |
| 961 void FilebrowseHandler::HandleGetMetadata(const Value* value) { | 959 void FilebrowseHandler::HandleGetMetadata(const Value* value) { |
| 962 } | 960 } |
| 963 | 961 |
| 964 void FilebrowseHandler::HandleGetDownloads(const Value* value) { | 962 void FilebrowseHandler::HandleGetDownloads(const Value* value) { |
| 965 ModelChanged(); | 963 ModelChanged(); |
| 966 } | 964 } |
| 967 | 965 |
| 968 void FilebrowseHandler::ModelChanged() { | 966 void FilebrowseHandler::ModelChanged() { |
| 969 ClearDownloadItems(); | 967 ClearDownloadItems(); |
| 970 download_manager_->GetAllDownloads(this, FilePath()); | |
| 971 } | |
| 972 | 968 |
| 973 void FilebrowseHandler::OnSearchDownloadsComplete( | 969 std::vector<DownloadItem*> downloads; |
| 974 std::vector<DownloadItem*> downloads) { | 970 download_manager_->GetAllDownloads(FilePath(), &downloads); |
| 975 ClearDownloadItems(); | 971 |
| 976 std::vector<DownloadItem*> new_downloads; | 972 std::vector<DownloadItem*> new_downloads; |
| 977 // Scan for any in progress downloads and add ourself to them as an observer. | 973 // Scan for any in progress downloads and add ourself to them as an observer. |
| 978 for (DownloadList::iterator it = downloads.begin(); | 974 for (DownloadList::iterator it = downloads.begin(); |
| 979 it != downloads.end(); ++it) { | 975 it != downloads.end(); ++it) { |
| 980 DownloadItem* download = *it; | 976 DownloadItem* download = *it; |
| 981 // We want to know what happens as the download progresses and be notified | 977 // We want to know what happens as the download progresses and be notified |
| 982 // when the user validates the dangerous download. | 978 // when the user validates the dangerous download. |
| 983 if (download->state() == DownloadItem::IN_PROGRESS || | 979 if (download->state() == DownloadItem::IN_PROGRESS || |
| 984 download->safety_state() == DownloadItem::DANGEROUS) { | 980 download->safety_state() == DownloadItem::DANGEROUS) { |
| 985 download->AddObserver(this); | 981 download->AddObserver(this); |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1153 } | 1149 } |
| 1154 } | 1150 } |
| 1155 | 1151 |
| 1156 return NULL; | 1152 return NULL; |
| 1157 } | 1153 } |
| 1158 | 1154 |
| 1159 const int FileBrowseUI::kPopupWidth = 250; | 1155 const int FileBrowseUI::kPopupWidth = 250; |
| 1160 const int FileBrowseUI::kPopupHeight = 300; | 1156 const int FileBrowseUI::kPopupHeight = 300; |
| 1161 const int FileBrowseUI::kSmallPopupWidth = 250; | 1157 const int FileBrowseUI::kSmallPopupWidth = 250; |
| 1162 const int FileBrowseUI::kSmallPopupHeight = 50; | 1158 const int FileBrowseUI::kSmallPopupHeight = 50; |
| OLD | NEW |