summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-08 20:49:18 +0000
committerkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-08 20:49:18 +0000
commit44b94b8f2d7a1b9a4990f0ad5c0805397215813a (patch)
treefb8201abcab9f56750cc08aeac2412c7ebb08fcd /chrome/browser
parent2c93f6f808ee1987c863ea1fbe74a21cde9e6911 (diff)
downloadchromium_src-44b94b8f2d7a1b9a4990f0ad5c0805397215813a.zip
chromium_src-44b94b8f2d7a1b9a4990f0ad5c0805397215813a.tar.gz
chromium_src-44b94b8f2d7a1b9a4990f0ad5c0805397215813a.tar.bz2
Use .crdownload file path for 'Show In Folder' while download is in progress
BUG=57037 TEST=download a huge file and click 'Show In Folder' during the download Review URL: http://codereview.chromium.org/4460002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@65418 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/automation/automation_provider.cc6
-rw-r--r--chrome/browser/cocoa/download/download_item_cell.mm2
-rw-r--r--chrome/browser/cocoa/download/download_item_controller.mm15
-rw-r--r--chrome/browser/cocoa/download/download_item_mac.h2
-rw-r--r--chrome/browser/cocoa/download/download_item_mac.mm8
-rw-r--r--chrome/browser/dom_ui/downloads_dom_handler.cc3
-rw-r--r--chrome/browser/download/download_file_manager.cc13
-rw-r--r--chrome/browser/download/download_item.cc50
-rw-r--r--chrome/browser/download/download_item.h39
-rw-r--r--chrome/browser/download/download_manager.cc26
-rw-r--r--chrome/browser/download/download_prefs.cc8
-rw-r--r--chrome/browser/download/download_prefs.h4
-rw-r--r--chrome/browser/download/download_util.cc10
-rw-r--r--chrome/browser/gtk/custom_drag.cc4
-rw-r--r--chrome/browser/gtk/download_item_gtk.cc16
-rw-r--r--chrome/browser/gtk/download_item_gtk.h4
-rw-r--r--chrome/browser/views/download_item_view.cc27
17 files changed, 122 insertions, 115 deletions
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc
index 60ed6ef..b01813f 100644
--- a/chrome/browser/automation/automation_provider.cc
+++ b/chrome/browser/automation/automation_provider.cc
@@ -282,8 +282,10 @@ DictionaryValue* AutomationProvider::GetDictionaryFromDownloadItem(
dl_item_value->SetInteger("id", static_cast<int>(download->id()));
dl_item_value->SetString("url", download->url().spec());
dl_item_value->SetString("referrer_url", download->referrer_url().spec());
- dl_item_value->SetString("file_name", download->GetFileName().value());
- dl_item_value->SetString("full_path", download->full_path().value());
+ dl_item_value->SetString("file_name",
+ download->GetFileNameToReportUser().value());
+ dl_item_value->SetString("full_path",
+ download->GetTargetFilePath().value());
dl_item_value->SetBoolean("is_paused", download->is_paused());
dl_item_value->SetBoolean("open_when_complete",
download->open_when_complete());
diff --git a/chrome/browser/cocoa/download/download_item_cell.mm b/chrome/browser/cocoa/download/download_item_cell.mm
index c286669..2f5d856 100644
--- a/chrome/browser/cocoa/download/download_item_cell.mm
+++ b/chrome/browser/cocoa/download/download_item_cell.mm
@@ -235,7 +235,7 @@ NSGradient* BackgroundTheme::GetNSGradient(int id) const {
- (void)setStateFromDownload:(BaseDownloadItemModel*)downloadModel {
// Set the name of the download.
- downloadPath_ = downloadModel->download()->GetFileName();
+ downloadPath_ = downloadModel->download()->GetFileNameToReportUser();
std::wstring statusText = downloadModel->GetStatusText();
if (statusText.empty()) {
diff --git a/chrome/browser/cocoa/download/download_item_controller.mm b/chrome/browser/cocoa/download/download_item_controller.mm
index d061e93..c210a3b 100644
--- a/chrome/browser/cocoa/download/download_item_controller.mm
+++ b/chrome/browser/cocoa/download/download_item_controller.mm
@@ -181,8 +181,8 @@ class DownloadShelfContextMenuMac : public DownloadShelfContextMenu {
// This basic fixup copies Windows DownloadItemView::DownloadItemView().
// Extract the file extension (if any).
- FilePath filepath(downloadModel->download()->original_name());
- FilePath::StringType extension = filepath.Extension();
+ FilePath filename(downloadModel->download()->target_name());
+ FilePath::StringType extension = filename.Extension();
// Remove leading '.' from the extension
if (extension.length() > 0)
@@ -197,15 +197,14 @@ class DownloadShelfContextMenuMac : public DownloadShelfContextMenu {
}
// Rebuild the filename.extension.
- std::wstring rootname =
- UTF8ToWide(filepath.BaseName().RemoveExtension().value());
+ std::wstring rootname = UTF8ToWide(filename.RemoveExtension().value());
ElideString(rootname, kFileNameMaxLength - extension.length(), &rootname);
- std::string filename = WideToUTF8(rootname);
+ std::string new_filename = WideToUTF8(rootname);
if (extension.length())
- filename += std::string(".") + extension;
+ new_filename += std::string(".") + extension;
dangerousWarning = l10n_util::GetNSStringFWithFixup(
- IDS_PROMPT_DANGEROUS_DOWNLOAD, UTF8ToUTF16(filename));
+ IDS_PROMPT_DANGEROUS_DOWNLOAD, UTF8ToUTF16(new_filename));
confirmButtonTitle = l10n_util::GetNSStringWithFixup(IDS_SAVE_DOWNLOAD);
}
[dangerousDownloadLabel_ setStringValue:dangerousWarning];
@@ -268,7 +267,7 @@ class DownloadShelfContextMenuMac : public DownloadShelfContextMenu {
- (void)updateToolTip {
string16 elidedFilename = gfx::ElideFilename(
- [self download]->GetFileName(),
+ [self download]->GetFileNameToReportUser(),
gfx::Font(), kToolTipMaxWidth);
[progressView_ setToolTip:base::SysUTF16ToNSString(elidedFilename)];
}
diff --git a/chrome/browser/cocoa/download/download_item_mac.h b/chrome/browser/cocoa/download/download_item_mac.h
index d5f013e..1a27549 100644
--- a/chrome/browser/cocoa/download/download_item_mac.h
+++ b/chrome/browser/cocoa/download/download_item_mac.h
@@ -55,7 +55,7 @@ class DownloadItemMac : DownloadItem::Observer {
CancelableRequestConsumerT<int, 0> icon_consumer_;
// Stores the last known name where the file will be saved.
- FilePath lastFilePath_;
+ FilePath lastFileName_;
DISALLOW_COPY_AND_ASSIGN(DownloadItemMac);
};
diff --git a/chrome/browser/cocoa/download/download_item_mac.mm b/chrome/browser/cocoa/download/download_item_mac.mm
index b647655..0f8c5b7 100644
--- a/chrome/browser/cocoa/download/download_item_mac.mm
+++ b/chrome/browser/cocoa/download/download_item_mac.mm
@@ -34,12 +34,12 @@ void DownloadItemMac::OnDownloadUpdated(DownloadItem* download) {
[item_controller_ clearDangerousMode];
}
- if (download->full_path() != lastFilePath_) {
- // Turns out the file path is "unconfirmed %d.download" for dangerous
+ if (download->GetUserVerifiedFileName() != lastFileName_) {
+ // Turns out the file path is "unconfirmed %d.crdownload" for dangerous
// downloads. When the download is confirmed, the file is renamed on
// another thread, so reload the icon if the download filename changes.
LoadIcon();
- lastFilePath_ = download->full_path();
+ lastFileName_ = download->GetUserVerifiedFileName();
[item_controller_ updateToolTip];
}
@@ -72,7 +72,7 @@ void DownloadItemMac::LoadIcon() {
}
// We may already have this particular image cached.
- FilePath file = download_model_->download()->full_path();
+ FilePath file = download_model_->download()->GetUserVerifiedFileName();
SkBitmap* icon_bitmap = icon_manager->LookupIcon(file, IconLoader::SMALL);
if (icon_bitmap) {
NSImage* icon = gfx::SkBitmapToNSImage(*icon_bitmap);
diff --git a/chrome/browser/dom_ui/downloads_dom_handler.cc b/chrome/browser/dom_ui/downloads_dom_handler.cc
index e193db3..e94ac0a 100644
--- a/chrome/browser/dom_ui/downloads_dom_handler.cc
+++ b/chrome/browser/dom_ui/downloads_dom_handler.cc
@@ -159,7 +159,8 @@ void DownloadsDOMHandler::HandleDrag(const ListValue* args) {
DownloadItem* file = GetDownloadByValue(args);
if (file) {
IconManager* im = g_browser_process->icon_manager();
- SkBitmap* icon = im->LookupIcon(file->full_path(), IconLoader::NORMAL);
+ SkBitmap* icon = im->LookupIcon(file->GetUserVerifiedFileName(),
+ IconLoader::NORMAL);
gfx::NativeView view = dom_ui_->tab_contents()->GetNativeView();
download_util::DragDownload(file, icon, view);
}
diff --git a/chrome/browser/download/download_file_manager.cc b/chrome/browser/download/download_file_manager.cc
index a8202e1..86346a8 100644
--- a/chrome/browser/download/download_file_manager.cc
+++ b/chrome/browser/download/download_file_manager.cc
@@ -286,7 +286,7 @@ void DownloadFileManager::OnIntermediateDownloadName(
return;
DownloadFile* download = it->second;
- if (!download->Rename(full_path, false)) {
+ if (!download->Rename(full_path, false /* is_final_rename */)) {
// Error. Between the time the UI thread generated 'full_path' to the time
// this code runs, something happened that prevents us from renaming.
CancelDownloadOnRename(id);
@@ -303,17 +303,16 @@ void DownloadFileManager::OnIntermediateDownloadName(
// 1. tmp -> foo (need_delete_crdownload=T)
// 2. foo.crdownload -> foo (need_delete_crdownload=F)
// 3. tmp-> unconfirmed.xxx.crdownload (need_delete_crdownload=F)
-void DownloadFileManager::OnFinalDownloadName(int id,
- const FilePath& full_path,
- bool need_delete_crdownload,
- DownloadManager* manager) {
+void DownloadFileManager::OnFinalDownloadName(
+ int id, const FilePath& full_path, bool need_delete_crdownload,
+ DownloadManager* download_manager) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
DownloadFile* download = GetDownloadFile(id);
if (!download)
return;
- if (download->Rename(full_path, true)) {
+ if (download->Rename(full_path, true /* is_final_rename */)) {
#if defined(OS_MACOSX)
// Done here because we only want to do this once; see
// http://crbug.com/13120 for details.
@@ -322,7 +321,7 @@ void DownloadFileManager::OnFinalDownloadName(int id,
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
NewRunnableMethod(
- manager, &DownloadManager::DownloadRenamedToFinalName, id,
+ download_manager, &DownloadManager::DownloadRenamedToFinalName, id,
full_path));
} else {
// Error. Between the time the UI thread generated 'full_path' to the time
diff --git a/chrome/browser/download/download_item.cc b/chrome/browser/download/download_item.cc
index df5edcc..25a5d28 100644
--- a/chrome/browser/download/download_item.cc
+++ b/chrome/browser/download/download_item.cc
@@ -57,7 +57,7 @@ DownloadItem::DownloadItem(DownloadManager* download_manager,
open_when_complete_(false),
safety_state_(SAFE),
auto_opened_(false),
- original_name_(info.original_name),
+ target_name_(info.original_name),
render_process_id_(-1),
request_id_(-1),
save_as_(false),
@@ -65,7 +65,6 @@ DownloadItem::DownloadItem(DownloadManager* download_manager,
is_extension_install_(info.is_extension_install),
name_finalized_(false),
is_temporary_(false),
- need_final_rename_(false),
opened_(false) {
if (state_ == IN_PROGRESS)
state_ = CANCELLED;
@@ -94,7 +93,7 @@ DownloadItem::DownloadItem(DownloadManager* download_manager,
open_when_complete_(false),
safety_state_(info.is_dangerous ? DANGEROUS : SAFE),
auto_opened_(false),
- original_name_(info.original_name),
+ target_name_(info.original_name),
render_process_id_(info.child_id),
request_id_(info.request_id),
save_as_(info.prompt_user_for_save_location),
@@ -102,7 +101,6 @@ DownloadItem::DownloadItem(DownloadManager* download_manager,
is_extension_install_(info.is_extension_install),
name_finalized_(false),
is_temporary_(!info.save_info.file_path.empty()),
- need_final_rename_(false),
opened_(false) {
Init(true /* start progress timer */);
}
@@ -130,7 +128,6 @@ DownloadItem::DownloadItem(DownloadManager* download_manager,
open_when_complete_(false),
safety_state_(SAFE),
auto_opened_(false),
- original_name_(FilePath()),
render_process_id_(-1),
request_id_(-1),
save_as_(false),
@@ -138,7 +135,6 @@ DownloadItem::DownloadItem(DownloadManager* download_manager,
is_extension_install_(false),
name_finalized_(false),
is_temporary_(false),
- need_final_rename_(false),
opened_(false) {
Init(true /* start progress timer */);
}
@@ -165,24 +161,21 @@ void DownloadItem::NotifyObserversDownloadFileCompleted() {
}
bool DownloadItem::CanOpenDownload() {
- FilePath file_to_use = full_path();
- if (!original_name().value().empty())
- file_to_use = original_name();
-
- return !Extension::IsExtension(file_to_use) &&
- !download_util::IsExecutableFile(file_to_use);
+ return !Extension::IsExtension(target_name_) &&
+ !download_util::IsExecutableFile(target_name_);
}
bool DownloadItem::ShouldOpenFileBasedOnExtension() {
- return download_manager_->ShouldOpenFileBasedOnExtension(full_path());
+ return download_manager_->ShouldOpenFileBasedOnExtension(
+ GetUserVerifiedFileName());
}
void DownloadItem::OpenFilesBasedOnExtension(bool open) {
DownloadPrefs* prefs = download_manager_->download_prefs();
if (open)
- prefs->EnableAutoOpenBasedOnExtension(full_path());
+ prefs->EnableAutoOpenBasedOnExtension(GetUserVerifiedFileName());
else
- prefs->DisableAutoOpenBasedOnExtension(full_path());
+ prefs->DisableAutoOpenBasedOnExtension(GetUserVerifiedFileName());
}
void DownloadItem::OpenDownload() {
@@ -281,7 +274,8 @@ void DownloadItem::Finished() {
*this);
auto_opened_ = true;
} else if (open_when_complete() ||
- download_manager_->ShouldOpenFileBasedOnExtension(full_path()) ||
+ download_manager_->ShouldOpenFileBasedOnExtension(
+ GetUserVerifiedFileName()) ||
is_temporary()) {
// If the download is temporary, like in drag-and-drop, do not open it but
// we still need to set it auto-opened so that it can be removed from the
@@ -344,7 +338,6 @@ int DownloadItem::PercentComplete() const {
void DownloadItem::Rename(const FilePath& full_path) {
DCHECK(!full_path.empty());
full_path_ = full_path;
- file_name_ = full_path_.BaseName();
}
void DownloadItem::TogglePause() {
@@ -386,26 +379,35 @@ bool DownloadItem::MatchesQuery(const string16& query) const {
if (url_formatted.find(query) != string16::npos)
return true;
- string16 path(l10n_util::ToLower(WideToUTF16(full_path_.ToWStringHack())));
+ string16 path(l10n_util::ToLower(WideToUTF16(full_path().ToWStringHack())));
if (path.find(query) != std::wstring::npos)
return true;
return false;
}
-FilePath DownloadItem::GetFileName() const {
- if (safety_state_ == DownloadItem::SAFE)
- return file_name_;
+FilePath DownloadItem::GetTargetFilePath() const {
+ return full_path_.DirName().Append(target_name_);
+}
+
+FilePath DownloadItem::GetFileNameToReportUser() const {
if (path_uniquifier_ > 0) {
- FilePath name(original_name_);
+ FilePath name(target_name_);
download_util::AppendNumberToPath(&name, path_uniquifier_);
return name;
}
- return original_name_;
+ return target_name_;
+}
+
+FilePath DownloadItem::GetUserVerifiedFileName() const {
+ if (safety_state_ == DownloadItem::SAFE)
+ return target_name_;
+ return full_path_.BaseName();
}
void DownloadItem::Init(bool start_timer) {
- file_name_ = full_path_.BaseName();
+ if (target_name_.value().empty())
+ target_name_ = full_path_.BaseName();
if (start_timer)
StartProgressTimer();
}
diff --git a/chrome/browser/download/download_item.h b/chrome/browser/download/download_item.h
index 3431bc7..4bc2b39 100644
--- a/chrome/browser/download/download_item.h
+++ b/chrome/browser/download/download_item.h
@@ -187,23 +187,31 @@ class DownloadItem {
safety_state_ = safety_state;
}
bool auto_opened() { return auto_opened_; }
- FilePath original_name() const { return original_name_; }
+ FilePath target_name() const { return target_name_; }
bool save_as() const { return save_as_; }
bool is_otr() const { return is_otr_; }
bool is_extension_install() const { return is_extension_install_; }
bool name_finalized() const { return name_finalized_; }
bool is_temporary() const { return is_temporary_; }
- bool need_final_rename() const { return need_final_rename_; }
- void set_need_final_rename(bool need_final_rename) {
- need_final_rename_ = need_final_rename;
- }
void set_opened(bool opened) { opened_ = opened; }
bool opened() const { return opened_; }
+ // Returns the final target file path for the download.
+ FilePath GetTargetFilePath() const;
+
// Returns the file-name that should be reported to the user, which is
- // file_name_ for safe downloads and original_name_ for dangerous ones with
- // the uniquifier number.
- FilePath GetFileName() const;
+ // target_name_ possibly with the uniquifier number.
+ FilePath GetFileNameToReportUser() const;
+
+ // Returns the user-verified target name for the download.
+ // This returns the same path as target_name() for safe downloads
+ // but does not for dangerous downloads until the name is verified.
+ FilePath GetUserVerifiedFileName() const;
+
+ // Returns true if the current file name is not the final target name yet.
+ bool NeedsRename() const {
+ return target_name_ != full_path_.BaseName();
+ }
private:
void Init(bool start_timer);
@@ -218,16 +226,13 @@ class DownloadItem {
// Request ID assigned by the ResourceDispatcherHost.
int32 id_;
- // Full path to the downloaded file
+ // Full path to the downloaded or downloading file.
FilePath full_path_;
// A number that should be appended to the path to make it unique, or 0 if the
// path should be used as is.
int path_uniquifier_;
- // Short display version of the file
- FilePath file_name_;
-
// The URL from whence we came.
GURL url_;
@@ -283,9 +288,10 @@ class DownloadItem {
// before the observer is added.
bool auto_opened_;
- // Dangerous download are given temporary names until the user approves them.
- // This stores their original name.
- FilePath original_name_;
+ // Dangerous downloads or ongoing downloads are given temporary names until
+ // the user approves them or the downloads finish.
+ // This stores their final target name.
+ FilePath target_name_;
// For canceling or pausing requests.
int render_process_id_;
@@ -306,9 +312,6 @@ class DownloadItem {
// True if the item was downloaded temporarily.
bool is_temporary_;
- // True if the file needs final rename.
- bool need_final_rename_;
-
// Did the user open the item either directly or indirectly (such as by
// setting always open files of this type)? The shelf also sets this field
// when the user closes the shelf before the item has been opened but should
diff --git a/chrome/browser/download/download_manager.cc b/chrome/browser/download/download_manager.cc
index 7669d9e..af0f60e 100644
--- a/chrome/browser/download/download_manager.cc
+++ b/chrome/browser/download/download_manager.cc
@@ -450,7 +450,7 @@ void DownloadManager::CreateDownloadItem(DownloadCreateInfo* info,
NewRunnableMethod(
file_manager_, &DownloadFileManager::OnIntermediateDownloadName,
download->id(), download_path, this));
- download->set_need_final_rename(true);
+ download->Rename(download_path);
}
if (download_finished) {
@@ -460,8 +460,6 @@ void DownloadManager::CreateDownloadItem(DownloadCreateInfo* info,
pending_finished_downloads_[info->download_id]);
}
- download->Rename(target_path);
-
download_history_->AddEntry(*info, download,
NewCallback(this, &DownloadManager::OnCreateDownloadEntryComplete));
@@ -526,16 +524,16 @@ void DownloadManager::OnAllDataSaved(int32 download_id, int64 size) {
NewRunnableMethod(
this, &DownloadManager::ProceedWithFinishedDangerousDownload,
download->db_handle(),
- download->full_path(), download->original_name()));
+ download->full_path(), download->target_name()));
return;
}
- if (download->need_final_rename()) {
+ if (download->NeedsRename()) {
BrowserThread::PostTask(
BrowserThread::FILE, FROM_HERE,
NewRunnableMethod(
file_manager_, &DownloadFileManager::OnFinalDownloadName,
- download->id(), download->full_path(), false, this));
+ download->id(), download->GetTargetFilePath(), false, this));
return;
}
@@ -545,16 +543,18 @@ void DownloadManager::OnAllDataSaved(int32 download_id, int64 size) {
void DownloadManager::DownloadRenamedToFinalName(int download_id,
const FilePath& full_path) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
-
DownloadItem* item = GetDownloadItem(download_id);
if (!item)
return;
+
+ bool needed_rename = item->NeedsRename();
+ item->Rename(full_path);
+
item->OnNameFinalized();
- // This was called from DownloadFinished; continue to call
- // ContinueDownloadFinished.
- if (item->need_final_rename()) {
- item->set_need_final_rename(false);
+ if (needed_rename) {
+ // This was called from OnAllDataSaved; continue to call
+ // ContinueDownloadFinished.
ContinueDownloadFinished(item);
}
}
@@ -613,7 +613,7 @@ void DownloadManager::DangerousDownloadRenamed(int64 download_handle,
// If we failed to rename the file, we'll just keep the name as is.
if (success) {
// We need to update the path uniquifier so that the UI shows the right
- // name when calling GetFileName().
+ // name when calling GetFileNameToReportUser().
download->set_path_uniquifier(new_path_uniquifier);
RenameDownload(download, new_path);
}
@@ -894,7 +894,7 @@ void DownloadManager::DangerousDownloadValidated(DownloadItem* download) {
NewRunnableMethod(
this, &DownloadManager::ProceedWithFinishedDangerousDownload,
download->db_handle(), download->full_path(),
- download->original_name()));
+ download->target_name()));
}
// Operations posted to us from the history service ----------------------------
diff --git a/chrome/browser/download/download_prefs.cc b/chrome/browser/download/download_prefs.cc
index b8645db..8673e0a 100644
--- a/chrome/browser/download/download_prefs.cc
+++ b/chrome/browser/download/download_prefs.cc
@@ -81,8 +81,8 @@ bool DownloadPrefs::IsAutoOpenEnabledForExtension(
return auto_open_.find(extension) != auto_open_.end();
}
-bool DownloadPrefs::EnableAutoOpenBasedOnExtension(const FilePath& file_path) {
- FilePath::StringType extension = file_path.Extension();
+bool DownloadPrefs::EnableAutoOpenBasedOnExtension(const FilePath& file_name) {
+ FilePath::StringType extension = file_name.Extension();
if (extension.empty())
return false;
DCHECK(extension[0] == FilePath::kExtensionSeparator);
@@ -95,8 +95,8 @@ bool DownloadPrefs::EnableAutoOpenBasedOnExtension(const FilePath& file_path) {
return true;
}
-void DownloadPrefs::DisableAutoOpenBasedOnExtension(const FilePath& file_path) {
- FilePath::StringType extension = file_path.Extension();
+void DownloadPrefs::DisableAutoOpenBasedOnExtension(const FilePath& file_name) {
+ FilePath::StringType extension = file_name.Extension();
if (extension.empty())
return;
DCHECK(extension[0] == FilePath::kExtensionSeparator);
diff --git a/chrome/browser/download/download_prefs.h b/chrome/browser/download/download_prefs.h
index bc8a9f3..1345a44 100644
--- a/chrome/browser/download/download_prefs.h
+++ b/chrome/browser/download/download_prefs.h
@@ -33,10 +33,10 @@ class DownloadPrefs {
// Enables auto-open based on file extension. Returns true on success.
// TODO(phajdan.jr): Add WARN_UNUSED_RESULT here.
- bool EnableAutoOpenBasedOnExtension(const FilePath& file_path);
+ bool EnableAutoOpenBasedOnExtension(const FilePath& file_name);
// Disables auto-open based on file extension.
- void DisableAutoOpenBasedOnExtension(const FilePath& file_path);
+ void DisableAutoOpenBasedOnExtension(const FilePath& file_name);
void ResetToDefaults();
void ResetAutoOpen();
diff --git a/chrome/browser/download/download_util.cc b/chrome/browser/download/download_util.cc
index 8c0331e..db509c8 100644
--- a/chrome/browser/download/download_util.cc
+++ b/chrome/browser/download/download_util.cc
@@ -448,8 +448,8 @@ void DragDownload(const DownloadItem* download,
OSExchangeData data;
if (icon) {
- drag_utils::CreateDragImageForFile(download->GetFileName().value(), icon,
- &data);
+ drag_utils::CreateDragImageForFile(
+ download->GetFileNameToReportUser().value(), icon, &data);
}
const FilePath full_path = download->full_path();
@@ -462,7 +462,7 @@ void DragDownload(const DownloadItem* download,
// Add URL so that we can load supported files when dragged to TabContents.
if (net::IsSupportedMimeType(mime_type)) {
data.SetURL(GURL(WideToUTF8(full_path.ToWStringHack())),
- download->GetFileName().ToWStringHack());
+ download->GetFileNameToReportUser().ToWStringHack());
}
#if defined(OS_WIN)
@@ -502,10 +502,10 @@ DictionaryValue* CreateDownloadItemValue(DownloadItem* download, int id) {
WideToUTF16Hack(base::TimeFormatShortDate(download->start_time())));
file_value->SetInteger("id", id);
file_value->SetString("file_path",
- WideToUTF16Hack(download->full_path().ToWStringHack()));
+ WideToUTF16Hack(download->GetTargetFilePath().ToWStringHack()));
// Keep file names as LTR.
string16 file_name = WideToUTF16Hack(
- download->GetFileName().ToWStringHack());
+ download->GetFileNameToReportUser().ToWStringHack());
file_name = base::i18n::GetDisplayStringInLTRDirectionality(file_name);
file_value->SetString("file_name", file_name);
file_value->SetString("url", download->url().spec());
diff --git a/chrome/browser/gtk/custom_drag.cc b/chrome/browser/gtk/custom_drag.cc
index 58b1717..6556e85 100644
--- a/chrome/browser/gtk/custom_drag.cc
+++ b/chrome/browser/gtk/custom_drag.cc
@@ -26,7 +26,8 @@ void OnDragDataGetForDownloadItem(GtkSelectionData* selection_data,
const DownloadItem* download_item) {
GURL url = net::FilePathToFileURL(download_item->full_path());
gtk_dnd_util::WriteURLWithName(selection_data, url,
- UTF8ToUTF16(download_item->GetFileName().value()), target_type);
+ UTF8ToUTF16(download_item->GetFileNameToReportUser().value()),
+ target_type);
}
void OnDragDataGetStandalone(GtkWidget* widget, GdkDragContext* context,
@@ -146,4 +147,3 @@ void BookmarkDrag::BeginDrag(Profile* profile,
const std::vector<const BookmarkNode*>& nodes) {
new BookmarkDrag(profile, nodes);
}
-
diff --git a/chrome/browser/gtk/download_item_gtk.cc b/chrome/browser/gtk/download_item_gtk.cc
index f1deda3..844c751 100644
--- a/chrome/browser/gtk/download_item_gtk.cc
+++ b/chrome/browser/gtk/download_item_gtk.cc
@@ -355,8 +355,8 @@ void DownloadItemGtk::OnDownloadUpdated(DownloadItem* download) {
parent_shelf_->MaybeShowMoreDownloadItems();
}
- if (download->full_path() != icon_filepath_) {
- // Turns out the file path is "unconfirmed %d.download" for dangerous
+ if (download->GetUserVerifiedFileName() != icon_filename_) {
+ // Turns out the file path is "unconfirmed %d.crdownload" for dangerous
// downloads. When the download is confirmed, the file is renamed on
// another thread, so reload the icon if the download filename changes.
LoadIcon();
@@ -510,18 +510,18 @@ void DownloadItemGtk::OnLoadLargeIconComplete(IconManager::Handle handle,
void DownloadItemGtk::LoadIcon() {
icon_consumer_.CancelAllRequests();
IconManager* im = g_browser_process->icon_manager();
- icon_filepath_ = get_download()->full_path();
- im->LoadIcon(icon_filepath_,
+ icon_filename_ = get_download()->GetUserVerifiedFileName();
+ im->LoadIcon(icon_filename_,
IconLoader::SMALL, &icon_consumer_,
NewCallback(this, &DownloadItemGtk::OnLoadSmallIconComplete));
- im->LoadIcon(icon_filepath_,
+ im->LoadIcon(icon_filename_,
IconLoader::LARGE, &icon_consumer_,
NewCallback(this, &DownloadItemGtk::OnLoadLargeIconComplete));
}
void DownloadItemGtk::UpdateTooltip() {
string16 elided_filename = gfx::ElideFilename(
- get_download()->GetFileName(),
+ get_download()->GetFileNameToReportUser(),
gfx::Font(), kTooltipMaxWidth);
gtk_widget_set_tooltip_text(body_.get(),
UTF16ToUTF8(elided_filename).c_str());
@@ -533,7 +533,7 @@ void DownloadItemGtk::UpdateNameLabel() {
// much padding when we set the size request. We need to either use gfx::Font
// or somehow extend TextElider.
string16 elided_filename = gfx::ElideFilename(
- get_download()->GetFileName(),
+ get_download()->GetFileNameToReportUser(),
gfx::Font(), kTextWidth);
GdkColor color = theme_provider_->GetGdkColor(
@@ -584,7 +584,7 @@ void DownloadItemGtk::UpdateDangerWarning() {
l10n_util::GetStringUTF16(IDS_PROMPT_DANGEROUS_DOWNLOAD_EXTENSION);
} else {
string16 elided_filename = gfx::ElideFilename(
- get_download()->original_name(), gfx::Font(), kTextWidth);
+ get_download()->target_name(), gfx::Font(), kTextWidth);
dangerous_warning =
l10n_util::GetStringFUTF16(IDS_PROMPT_DANGEROUS_DOWNLOAD,
diff --git a/chrome/browser/gtk/download_item_gtk.h b/chrome/browser/gtk/download_item_gtk.h
index 5e4d64e..f73592a 100644
--- a/chrome/browser/gtk/download_item_gtk.h
+++ b/chrome/browser/gtk/download_item_gtk.h
@@ -202,8 +202,8 @@ class DownloadItemGtk : public DownloadItem::Observer,
SkBitmap* icon_small_;
SkBitmap* icon_large_;
- // The last download file path for which we requested an icon.
- FilePath icon_filepath_;
+ // The last download file name for which we requested an icon.
+ FilePath icon_filename_;
NotificationRegistrar registrar_;
diff --git a/chrome/browser/views/download_item_view.cc b/chrome/browser/views/download_item_view.cc
index 695abe4..3ceaf52 100644
--- a/chrome/browser/views/download_item_view.cc
+++ b/chrome/browser/views/download_item_view.cc
@@ -209,7 +209,7 @@ DownloadItemView::DownloadItemView(DownloadItem* download,
dangerous_mode_body_image_set_ = dangerous_mode_body_image_set;
LoadIcon();
- tooltip_text_ = download_->GetFileName().ToWStringHack();
+ tooltip_text_ = download_->GetFileNameToReportUser().ToWStringHack();
font_ = ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::BaseFont);
box_height_ = std::max<int>(2 * kVerticalPadding + font_.GetHeight() +
@@ -257,11 +257,11 @@ DownloadItemView::DownloadItemView(DownloadItem* download,
// Ensure the file name is not too long.
// Extract the file extension (if any).
- FilePath filepath(download->original_name());
+ FilePath filename(download->target_name());
#if defined(OS_LINUX)
- std::wstring extension = base::SysNativeMBToWide(filepath.Extension());
+ std::wstring extension = base::SysNativeMBToWide(filename.Extension());
#else
- std::wstring extension = filepath.Extension();
+ std::wstring extension = filename.Extension();
#endif
// Remove leading '.'
@@ -269,9 +269,9 @@ DownloadItemView::DownloadItemView(DownloadItem* download,
extension = extension.substr(1);
#if defined(OS_LINUX)
std::wstring rootname =
- base::SysNativeMBToWide(filepath.BaseName().RemoveExtension().value());
+ base::SysNativeMBToWide(filename.RemoveExtension().value());
#else
- std::wstring rootname = filepath.BaseName().RemoveExtension().value();
+ std::wstring rootname = filename.RemoveExtension().value();
#endif
// Elide giant extensions (this shouldn't currently be hit, but might
@@ -602,7 +602,7 @@ void DownloadItemView::Paint(gfx::Canvas* canvas) {
if (!IsDangerousMode()) {
string16 filename;
if (!disabled_while_opening_) {
- filename = gfx::ElideFilename(download_->GetFileName(),
+ filename = gfx::ElideFilename(download_->GetFileNameToReportUser(),
font_, kTextWidth);
} else {
// First, Calculate the download status opening string width.
@@ -612,7 +612,7 @@ void DownloadItemView::Paint(gfx::Canvas* canvas) {
int status_string_width = font_.GetStringWidth(status_string);
// Then, elide the file name.
string16 filename_string =
- gfx::ElideFilename(download_->GetFileName(), font_,
+ gfx::ElideFilename(download_->GetFileNameToReportUser(), font_,
kTextWidth - status_string_width);
// Last, concat the whole string.
filename = l10n_util::GetStringFUTF16(IDS_DOWNLOAD_STATUS_OPENING,
@@ -637,7 +637,7 @@ void DownloadItemView::Paint(gfx::Canvas* canvas) {
// Paint the icon.
IconManager* im = g_browser_process->icon_manager();
SkBitmap* icon = IsDangerousMode() ? warning_icon_ :
- im->LookupIcon(download_->full_path(), IconLoader::SMALL);
+ im->LookupIcon(download_->GetUserVerifiedFileName(), IconLoader::SMALL);
// We count on the fact that the icon manager will cache the icons and if one
// is available, it will be cached here. We *don't* want to request the icon
@@ -731,7 +731,7 @@ void DownloadItemView::ClearDangerousMode() {
// We need to load the icon now that the download_ has the real path.
LoadIcon();
- tooltip_text_ = download_->GetFileName().ToWStringHack();
+ tooltip_text_ = download_->GetFileNameToReportUser().ToWStringHack();
// Force the shelf to layout again as our size has changed.
parent_->Layout();
@@ -849,7 +849,7 @@ bool DownloadItemView::OnMouseDragged(const views::MouseEvent& event) {
if (dragging_) {
if (download_->state() == DownloadItem::COMPLETE) {
IconManager* im = g_browser_process->icon_manager();
- SkBitmap* icon = im->LookupIcon(download_->full_path(),
+ SkBitmap* icon = im->LookupIcon(download_->GetUserVerifiedFileName(),
IconLoader::SMALL);
if (icon) {
views::Widget* widget = GetWidget();
@@ -960,7 +960,8 @@ void DownloadItemView::OnExtractIconComplete(IconManager::Handle handle,
void DownloadItemView::LoadIcon() {
IconManager* im = g_browser_process->icon_manager();
- im->LoadIcon(download_->full_path(), IconLoader::SMALL, &icon_consumer_,
+ im->LoadIcon(download_->GetUserVerifiedFileName(),
+ IconLoader::SMALL, &icon_consumer_,
NewCallback(this, &DownloadItemView::OnExtractIconComplete));
}
@@ -1062,7 +1063,7 @@ void DownloadItemView::UpdateAccessibleName() {
new_name = dangerous_download_label_->GetText();
} else {
new_name = status_text_ + L" " +
- download_->GetFileName().ToWStringHack();
+ download_->GetFileNameToReportUser().ToWStringHack();
}
// If the name has changed, call SetAccessibleName and notify