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

Side by Side Diff: chrome/browser/download/chrome_download_manager_delegate.cc

Issue 11092088: Cleanup referrer_charset (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync Created 8 years, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/net/chrome_url_request_context.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/chrome_download_manager_delegate.h" 5 #include "chrome/browser/download/chrome_download_manager_delegate.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 106
107 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingState); 107 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingState);
108 }; 108 };
109 109
110 SafeBrowsingState::~SafeBrowsingState() {} 110 SafeBrowsingState::~SafeBrowsingState() {}
111 111
112 // Generate a filename based on the response from the server. Similar 112 // Generate a filename based on the response from the server. Similar
113 // in operation to net::GenerateFileName(), but uses a localized 113 // in operation to net::GenerateFileName(), but uses a localized
114 // default name. 114 // default name.
115 void GenerateFileNameFromRequest(const DownloadItem& download_item, 115 void GenerateFileNameFromRequest(const DownloadItem& download_item,
116 FilePath* generated_name) { 116 FilePath* generated_name,
117 std::string referrer_charset) {
117 std::string default_file_name( 118 std::string default_file_name(
118 l10n_util::GetStringUTF8(IDS_DEFAULT_DOWNLOAD_FILENAME)); 119 l10n_util::GetStringUTF8(IDS_DEFAULT_DOWNLOAD_FILENAME));
119 120
120 *generated_name = net::GenerateFileName(download_item.GetURL(), 121 *generated_name = net::GenerateFileName(download_item.GetURL(),
121 download_item.GetContentDisposition(), 122 download_item.GetContentDisposition(),
122 download_item.GetReferrerCharset(), 123 referrer_charset,
123 download_item.GetSuggestedFilename(), 124 download_item.GetSuggestedFilename(),
124 download_item.GetMimeType(), 125 download_item.GetMimeType(),
125 default_file_name); 126 default_file_name);
126 } 127 }
127 128
128 // Needed to give PostTask a void closure in OnWebIntentDispatchCompleted. 129 // Needed to give PostTask a void closure in OnWebIntentDispatchCompleted.
129 void DeleteFile(const FilePath& file_path) { 130 void DeleteFile(const FilePath& file_path) {
130 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 131 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
131 file_util::Delete(file_path, false); 132 file_util::Delete(file_path, false);
132 } 133 }
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 712
712 bool should_prompt = (download->GetTargetDisposition() == 713 bool should_prompt = (download->GetTargetDisposition() ==
713 DownloadItem::TARGET_DISPOSITION_PROMPT); 714 DownloadItem::TARGET_DISPOSITION_PROMPT);
714 bool is_forced_path = !download->GetForcedFilePath().empty(); 715 bool is_forced_path = !download->GetForcedFilePath().empty();
715 FilePath suggested_path; 716 FilePath suggested_path;
716 717
717 // Check whether this download is for an extension install or not. 718 // Check whether this download is for an extension install or not.
718 // Allow extensions to be explicitly saved. 719 // Allow extensions to be explicitly saved.
719 if (!is_forced_path) { 720 if (!is_forced_path) {
720 FilePath generated_name; 721 FilePath generated_name;
721 GenerateFileNameFromRequest(*download, &generated_name); 722 GenerateFileNameFromRequest(
723 *download,
724 &generated_name,
725 profile_->GetPrefs()->GetString(prefs::kDefaultCharset));
722 726
723 // Freeze the user's preference for showing a Save As dialog. We're going 727 // Freeze the user's preference for showing a Save As dialog. We're going
724 // to bounce around a bunch of threads and we don't want to worry about race 728 // to bounce around a bunch of threads and we don't want to worry about race
725 // conditions where the user changes this pref out from under us. 729 // conditions where the user changes this pref out from under us.
726 if (download_prefs_->PromptForDownload()) { 730 if (download_prefs_->PromptForDownload()) {
727 // But ignore the user's preference for the following scenarios: 731 // But ignore the user's preference for the following scenarios:
728 // 1) Extension installation. Note that we only care here about the case 732 // 1) Extension installation. Note that we only care here about the case
729 // where an extension is installed, not when one is downloaded with 733 // where an extension is installed, not when one is downloaded with
730 // "save as...". 734 // "save as...".
731 // 2) Filetypes marked "always open." If the user just wants this file 735 // 2) Filetypes marked "always open." If the user just wants this file
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
891 int32 download_id, int64 db_handle) { 895 int32 download_id, int64 db_handle) {
892 // It's not immediately obvious, but HistoryBackend::CreateDownload() can 896 // It's not immediately obvious, but HistoryBackend::CreateDownload() can
893 // call this function with an invalid |db_handle|. For instance, this can 897 // call this function with an invalid |db_handle|. For instance, this can
894 // happen when the history database is offline. We cannot have multiple 898 // happen when the history database is offline. We cannot have multiple
895 // DownloadItems with the same invalid db_handle, so we need to assign a 899 // DownloadItems with the same invalid db_handle, so we need to assign a
896 // unique |db_handle| here. 900 // unique |db_handle| here.
897 if (db_handle == DownloadItem::kUninitializedHandle) 901 if (db_handle == DownloadItem::kUninitializedHandle)
898 db_handle = download_history_->GetNextFakeDbHandle(); 902 db_handle = download_history_->GetNextFakeDbHandle();
899 download_manager_->OnItemAddedToPersistentStore(download_id, db_handle); 903 download_manager_->OnItemAddedToPersistentStore(download_id, db_handle);
900 } 904 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/net/chrome_url_request_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698