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

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

Issue 10704052: Download filename determination refactor (3/3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 8 years, 5 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
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/download_file_picker_chromeos.h" 5 #include "chrome/browser/download/download_file_picker_chromeos.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/i18n/file_util_icu.h" 8 #include "base/i18n/file_util_icu.h"
9 #include "chrome/browser/chromeos/gdata/gdata_download_observer.h" 9 #include "chrome/browser/chromeos/gdata/gdata_download_observer.h"
10 #include "chrome/browser/chromeos/gdata/gdata_util.h" 10 #include "chrome/browser/chromeos/gdata/gdata_util.h"
11 #include "content/public/browser/download_item.h" 11 #include "content/public/browser/download_item.h"
12 #include "content/public/browser/download_manager.h" 12 #include "content/public/browser/download_manager.h"
13 13
14 using content::DownloadItem; 14 using content::DownloadItem;
15 using content::DownloadManager; 15 using content::DownloadManager;
16 16
17 namespace {
18
19 // Call FileSelected on |download_manager|.
20 void FileSelectedHelper(DownloadManager* download_manager,
21 int32 download_id,
22 const FilePath& file_path) {
23 download_manager->FileSelected(file_path, download_id);
24 }
25
26 } // namespace
27
28 DownloadFilePickerChromeOS::DownloadFilePickerChromeOS() { 17 DownloadFilePickerChromeOS::DownloadFilePickerChromeOS() {
29 } 18 }
30 19
31 DownloadFilePickerChromeOS::~DownloadFilePickerChromeOS() { 20 DownloadFilePickerChromeOS::~DownloadFilePickerChromeOS() {
32 } 21 }
33 22
34 void DownloadFilePickerChromeOS::InitSuggestedPath(DownloadItem* item) { 23 void DownloadFilePickerChromeOS::InitSuggestedPath(DownloadItem* item,
35 // For GData downloads, suggested path is the virtual gdata path instead of 24 const FilePath& path) {
36 // the temporary local one. 25 // For GData downloads, |path| is the virtual gdata path instead of the
26 // temporary local one.
37 if (gdata::GDataDownloadObserver::IsGDataDownload(item)) { 27 if (gdata::GDataDownloadObserver::IsGDataDownload(item)) {
38 set_suggested_path(gdata::util::GetSpecialRemoteRootPath().Append( 28 set_suggested_path(gdata::util::GetSpecialRemoteRootPath().Append(
39 gdata::GDataDownloadObserver::GetGDataPath(item))); 29 gdata::GDataDownloadObserver::GetGDataPath(item)));
40 } else { 30 } else {
41 DownloadFilePicker::InitSuggestedPath(item); 31 DownloadFilePicker::InitSuggestedPath(item, path);
42 } 32 }
43 } 33 }
44 34
45 void DownloadFilePickerChromeOS::FileSelected(const FilePath& selected_path, 35 void DownloadFilePickerChromeOS::FileSelected(const FilePath& selected_path,
46 int index, 36 int index,
47 void* params) { 37 void* params) {
48 FilePath path = selected_path; 38 FilePath path = selected_path;
49 file_util::NormalizeFileNameEncoding(&path); 39 file_util::NormalizeFileNameEncoding(&path);
50 40
41 // Need to do this before we substitute with a temporary path. Otherwise we
42 // won't be able to detect path changes.
51 RecordFileSelected(path); 43 RecordFileSelected(path);
52 44
53 if (download_manager_) { 45 if (download_manager_) {
54 content::DownloadItem* download = 46 content::DownloadItem* download =
55 download_manager_->GetActiveDownloadItem(download_id_); 47 download_manager_->GetActiveDownloadItem(download_id_);
56 gdata::GDataDownloadObserver::SubstituteGDataDownloadPath( 48 gdata::GDataDownloadObserver::SubstituteGDataDownloadPath(
57 NULL, path, download, 49 NULL, path, download,
58 base::Bind(&FileSelectedHelper, download_manager_, download_id_)); 50 base::Bind(&DownloadFilePickerChromeOS::OnFileSelected,
51 base::Unretained(this)));
52 } else {
53 OnFileSelected(FilePath());
59 } 54 }
60 delete this; 55 // The OnFileSelected() call deletes |this|
61 } 56 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698