| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/download/download_manager.h" | 5 #include "chrome/browser/download/download_manager.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/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 #include "chrome/browser/net/chrome_url_request_context.h" | 32 #include "chrome/browser/net/chrome_url_request_context.h" |
| 33 #include "chrome/browser/platform_util.h" | 33 #include "chrome/browser/platform_util.h" |
| 34 #include "chrome/browser/profiles/profile.h" | 34 #include "chrome/browser/profiles/profile.h" |
| 35 #include "chrome/browser/renderer_host/render_process_host.h" | 35 #include "chrome/browser/renderer_host/render_process_host.h" |
| 36 #include "chrome/browser/renderer_host/render_view_host.h" | 36 #include "chrome/browser/renderer_host/render_view_host.h" |
| 37 #include "chrome/browser/tab_contents/infobar_delegate.h" | 37 #include "chrome/browser/tab_contents/infobar_delegate.h" |
| 38 #include "chrome/browser/tab_contents/tab_contents.h" | 38 #include "chrome/browser/tab_contents/tab_contents.h" |
| 39 #include "chrome/browser/tab_contents/tab_util.h" | 39 #include "chrome/browser/tab_contents/tab_util.h" |
| 40 #include "chrome/browser/ui/browser.h" | 40 #include "chrome/browser/ui/browser.h" |
| 41 #include "chrome/common/chrome_paths.h" | 41 #include "chrome/common/chrome_paths.h" |
| 42 #include "chrome/common/notification_service.h" | |
| 43 #include "chrome/common/notification_type.h" | 42 #include "chrome/common/notification_type.h" |
| 44 #include "chrome/common/pref_names.h" | 43 #include "chrome/common/pref_names.h" |
| 45 #include "googleurl/src/gurl.h" | 44 #include "googleurl/src/gurl.h" |
| 46 #include "grit/generated_resources.h" | 45 #include "grit/generated_resources.h" |
| 47 #include "grit/theme_resources.h" | 46 #include "grit/theme_resources.h" |
| 48 #include "net/base/mime_util.h" | 47 #include "net/base/mime_util.h" |
| 49 #include "net/base/net_util.h" | 48 #include "net/base/net_util.h" |
| 50 | 49 |
| 51 #if defined(OS_WIN) | 50 #if defined(OS_WIN) |
| 52 #include "app/win_util.h" | 51 #include "app/win_util.h" |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 it->second->safety_state() == DownloadItem::DANGEROUS) && | 170 it->second->safety_state() == DownloadItem::DANGEROUS) && |
| 172 (dir_path.empty() || it->second->full_path().DirName() == dir_path)) | 171 (dir_path.empty() || it->second->full_path().DirName() == dir_path)) |
| 173 result->push_back(it->second); | 172 result->push_back(it->second); |
| 174 } | 173 } |
| 175 | 174 |
| 176 // If we have a parent profile, let it add its downloads to the results. | 175 // If we have a parent profile, let it add its downloads to the results. |
| 177 Profile* original_profile = profile_->GetOriginalProfile(); | 176 Profile* original_profile = profile_->GetOriginalProfile(); |
| 178 if (original_profile != profile_) | 177 if (original_profile != profile_) |
| 179 original_profile->GetDownloadManager()->GetCurrentDownloads(dir_path, | 178 original_profile->GetDownloadManager()->GetCurrentDownloads(dir_path, |
| 180 result); | 179 result); |
| 181 | |
| 182 } | 180 } |
| 183 | 181 |
| 184 void DownloadManager::SearchDownloads(const string16& query, | 182 void DownloadManager::SearchDownloads(const string16& query, |
| 185 std::vector<DownloadItem*>* result) { | 183 std::vector<DownloadItem*>* result) { |
| 186 DCHECK(result); | 184 DCHECK(result); |
| 187 | 185 |
| 188 string16 query_lower(l10n_util::ToLower(query)); | 186 string16 query_lower(l10n_util::ToLower(query)); |
| 189 | 187 |
| 190 for (DownloadMap::iterator it = history_downloads_.begin(); | 188 for (DownloadMap::iterator it = history_downloads_.begin(); |
| 191 it != history_downloads_.end(); ++it) { | 189 it != history_downloads_.end(); ++it) { |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 // 2) Filetypes marked "always open." If the user just wants this file | 272 // 2) Filetypes marked "always open." If the user just wants this file |
| 275 // opened, don't bother asking where to keep it. | 273 // opened, don't bother asking where to keep it. |
| 276 if (!info->is_extension_install && | 274 if (!info->is_extension_install && |
| 277 !ShouldOpenFileBasedOnExtension(generated_name)) | 275 !ShouldOpenFileBasedOnExtension(generated_name)) |
| 278 info->prompt_user_for_save_location = true; | 276 info->prompt_user_for_save_location = true; |
| 279 } | 277 } |
| 280 | 278 |
| 281 // Determine the proper path for a download, by either one of the following: | 279 // Determine the proper path for a download, by either one of the following: |
| 282 // 1) using the default download directory. | 280 // 1) using the default download directory. |
| 283 // 2) prompting the user. | 281 // 2) prompting the user. |
| 284 if (info->prompt_user_for_save_location && !last_download_path_.empty()){ | 282 if (info->prompt_user_for_save_location && !last_download_path_.empty()) { |
| 285 info->suggested_path = last_download_path_; | 283 info->suggested_path = last_download_path_; |
| 286 } else { | 284 } else { |
| 287 info->suggested_path = download_prefs_->download_path(); | 285 info->suggested_path = download_prefs_->download_path(); |
| 288 } | 286 } |
| 289 info->suggested_path = info->suggested_path.Append(generated_name); | 287 info->suggested_path = info->suggested_path.Append(generated_name); |
| 290 } else { | 288 } else { |
| 291 info->suggested_path = info->save_info.file_path; | 289 info->suggested_path = info->save_info.file_path; |
| 292 } | 290 } |
| 293 | 291 |
| 294 if (!info->prompt_user_for_save_location && | 292 if (!info->prompt_user_for_save_location && |
| (...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1033 observed_download_manager_->RemoveObserver(this); | 1031 observed_download_manager_->RemoveObserver(this); |
| 1034 } | 1032 } |
| 1035 | 1033 |
| 1036 void DownloadManager::OtherDownloadManagerObserver::ModelChanged() { | 1034 void DownloadManager::OtherDownloadManagerObserver::ModelChanged() { |
| 1037 observing_download_manager_->NotifyModelChanged(); | 1035 observing_download_manager_->NotifyModelChanged(); |
| 1038 } | 1036 } |
| 1039 | 1037 |
| 1040 void DownloadManager::OtherDownloadManagerObserver::ManagerGoingDown() { | 1038 void DownloadManager::OtherDownloadManagerObserver::ManagerGoingDown() { |
| 1041 observed_download_manager_ = NULL; | 1039 observed_download_manager_ = NULL; |
| 1042 } | 1040 } |
| OLD | NEW |