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

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: Merge with r148594 to and resolve conflicts with r148576 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 #include "ui/base/dialogs/selected_file_info.h" 13 #include "ui/base/dialogs/selected_file_info.h"
14 14
15 using content::DownloadItem; 15 using content::DownloadItem;
16 using content::DownloadManager; 16 using content::DownloadManager;
17 17
18 namespace {
19
20 // Call FileSelected on |download_manager|.
21 void FileSelectedHelper(DownloadManager* download_manager,
22 int32 download_id,
23 const FilePath& file_path) {
24 download_manager->FileSelected(file_path, download_id);
25 }
26
27 } // namespace
28
29 DownloadFilePickerChromeOS::DownloadFilePickerChromeOS() { 18 DownloadFilePickerChromeOS::DownloadFilePickerChromeOS() {
30 } 19 }
31 20
32 DownloadFilePickerChromeOS::~DownloadFilePickerChromeOS() { 21 DownloadFilePickerChromeOS::~DownloadFilePickerChromeOS() {
33 } 22 }
34 23
35 void DownloadFilePickerChromeOS::InitSuggestedPath(DownloadItem* item) { 24 void DownloadFilePickerChromeOS::InitSuggestedPath(DownloadItem* item,
36 // For GData downloads, suggested path is the virtual gdata path instead of 25 const FilePath& path) {
37 // the temporary local one. 26 // For GData downloads, |path| is the virtual gdata path instead of the
27 // temporary local one.
38 if (gdata::GDataDownloadObserver::IsGDataDownload(item)) { 28 if (gdata::GDataDownloadObserver::IsGDataDownload(item)) {
39 set_suggested_path(gdata::util::GetSpecialRemoteRootPath().Append( 29 set_suggested_path(gdata::util::GetSpecialRemoteRootPath().Append(
40 gdata::GDataDownloadObserver::GetGDataPath(item))); 30 gdata::GDataDownloadObserver::GetGDataPath(item)));
41 } else { 31 } else {
42 DownloadFilePicker::InitSuggestedPath(item); 32 DownloadFilePicker::InitSuggestedPath(item, path);
43 } 33 }
44 } 34 }
45 35
46 void DownloadFilePickerChromeOS::FileSelected(const FilePath& selected_path, 36 void DownloadFilePickerChromeOS::FileSelected(const FilePath& selected_path,
47 int index, 37 int index,
48 void* params) { 38 void* params) {
49 FileSelectedWithExtraInfo( 39 FileSelectedWithExtraInfo(
50 ui::SelectedFileInfo(selected_path, selected_path), 40 ui::SelectedFileInfo(selected_path, selected_path),
51 index, 41 index,
52 params); 42 params);
53 } 43 }
54 44
55 void DownloadFilePickerChromeOS::FileSelectedWithExtraInfo( 45 void DownloadFilePickerChromeOS::FileSelectedWithExtraInfo(
56 const ui::SelectedFileInfo& file_info, 46 const ui::SelectedFileInfo& file_info,
57 int index, 47 int index,
58 void* params) { 48 void* params) {
59 FilePath path = file_info.file_path; 49 FilePath path = file_info.file_path;
60 file_util::NormalizeFileNameEncoding(&path); 50 file_util::NormalizeFileNameEncoding(&path);
61 51
52 // Need to do this before we substitute with a temporary path. Otherwise we
53 // won't be able to detect path changes.
62 RecordFileSelected(path); 54 RecordFileSelected(path);
63 55
64 if (download_manager_) { 56 if (download_manager_) {
65 content::DownloadItem* download = 57 content::DownloadItem* download =
66 download_manager_->GetActiveDownloadItem(download_id_); 58 download_manager_->GetActiveDownloadItem(download_id_);
67 gdata::GDataDownloadObserver::SubstituteGDataDownloadPath( 59 gdata::GDataDownloadObserver::SubstituteGDataDownloadPath(
68 NULL, path, download, 60 NULL, path, download,
69 base::Bind(&FileSelectedHelper, download_manager_, download_id_)); 61 base::Bind(&DownloadFilePickerChromeOS::OnFileSelected,
62 base::Unretained(this)));
63 } else {
64 OnFileSelected(FilePath());
70 } 65 }
71 delete this; 66 // The OnFileSelected() call deletes |this|
72 } 67 }
OLDNEW
« no previous file with comments | « chrome/browser/download/download_file_picker_chromeos.h ('k') | chrome/browser/download/download_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698