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/download/download_manager.h" | 5 #include "chrome/browser/download/download_manager.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/i18n/case_conversion.h" | 9 #include "base/i18n/case_conversion.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 if (!state.prompt_user_for_save_location) { | 351 if (!state.prompt_user_for_save_location) { |
352 if (UserScript::IsURLUserScript(download->GetURL(), | 352 if (UserScript::IsURLUserScript(download->GetURL(), |
353 download->mime_type()) || | 353 download->mime_type()) || |
354 (download->mime_type() == Extension::kMimeType)) { | 354 (download->mime_type() == Extension::kMimeType)) { |
355 state.is_extension_install = true; | 355 state.is_extension_install = true; |
356 } | 356 } |
357 } | 357 } |
358 | 358 |
359 if (state.force_file_name.empty()) { | 359 if (state.force_file_name.empty()) { |
360 FilePath generated_name; | 360 FilePath generated_name; |
361 download_util::GenerateFileNameFromRequest(download->GetURL(), | 361 download_util::GenerateFileNameFromRequest(*download, |
362 download->content_disposition(), | |
363 download->referrer_charset(), | |
364 download->mime_type(), | |
365 &generated_name); | 362 &generated_name); |
366 | 363 |
367 // Freeze the user's preference for showing a Save As dialog. We're going | 364 // Freeze the user's preference for showing a Save As dialog. We're going |
368 // to bounce around a bunch of threads and we don't want to worry about race | 365 // to bounce around a bunch of threads and we don't want to worry about race |
369 // conditions where the user changes this pref out from under us. | 366 // conditions where the user changes this pref out from under us. |
370 if (download_prefs_->PromptForDownload()) { | 367 if (download_prefs_->PromptForDownload()) { |
371 // But ignore the user's preference for the following scenarios: | 368 // But ignore the user's preference for the following scenarios: |
372 // 1) Extension installation. Note that we only care here about the case | 369 // 1) Extension installation. Note that we only care here about the case |
373 // where an extension is installed, not when one is downloaded with | 370 // where an extension is installed, not when one is downloaded with |
374 // "save as...". | 371 // "save as...". |
(...skipping 971 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1346 observed_download_manager_->RemoveObserver(this); | 1343 observed_download_manager_->RemoveObserver(this); |
1347 } | 1344 } |
1348 | 1345 |
1349 void DownloadManager::OtherDownloadManagerObserver::ModelChanged() { | 1346 void DownloadManager::OtherDownloadManagerObserver::ModelChanged() { |
1350 observing_download_manager_->NotifyModelChanged(); | 1347 observing_download_manager_->NotifyModelChanged(); |
1351 } | 1348 } |
1352 | 1349 |
1353 void DownloadManager::OtherDownloadManagerObserver::ManagerGoingDown() { | 1350 void DownloadManager::OtherDownloadManagerObserver::ManagerGoingDown() { |
1354 observed_download_manager_ = NULL; | 1351 observed_download_manager_ = NULL; |
1355 } | 1352 } |
OLD | NEW |