OLD | NEW |
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.h" | 5 #include "chrome/browser/download/download_file_picker.h" |
6 | 6 |
7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "chrome/browser/download/download_prefs.h" | 8 #include "chrome/browser/download/download_prefs.h" |
9 #include "chrome/browser/platform_util.h" | 9 #include "chrome/browser/platform_util.h" |
10 #include "chrome/browser/ui/chrome_select_file_policy.h" | 10 #include "chrome/browser/ui/chrome_select_file_policy.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 DownloadItem* item, | 63 DownloadItem* item, |
64 const FilePath& suggested_path, | 64 const FilePath& suggested_path, |
65 const ChromeDownloadManagerDelegate::FileSelectedCallback& callback) { | 65 const ChromeDownloadManagerDelegate::FileSelectedCallback& callback) { |
66 download_manager_ = download_manager; | 66 download_manager_ = download_manager; |
67 download_id_ = item->GetId(); | 67 download_id_ = item->GetId(); |
68 file_selected_callback_ = callback; | 68 file_selected_callback_ = callback; |
69 InitSuggestedPath(item, suggested_path); | 69 InitSuggestedPath(item, suggested_path); |
70 | 70 |
71 DCHECK(download_manager_); | 71 DCHECK(download_manager_); |
72 WebContents* web_contents = item->GetWebContents(); | 72 WebContents* web_contents = item->GetWebContents(); |
73 select_file_dialog_ = SelectFileDialog::Create( | 73 select_file_dialog_ = ui::SelectFileDialog::Create( |
74 this, new ChromeSelectFilePolicy(web_contents)); | 74 this, new ChromeSelectFilePolicy(web_contents)); |
75 SelectFileDialog::FileTypeInfo file_type_info; | 75 ui::SelectFileDialog::FileTypeInfo file_type_info; |
76 FilePath::StringType extension = suggested_path_.Extension(); | 76 FilePath::StringType extension = suggested_path_.Extension(); |
77 if (!extension.empty()) { | 77 if (!extension.empty()) { |
78 extension.erase(extension.begin()); // drop the . | 78 extension.erase(extension.begin()); // drop the . |
79 file_type_info.extensions.resize(1); | 79 file_type_info.extensions.resize(1); |
80 file_type_info.extensions[0].push_back(extension); | 80 file_type_info.extensions[0].push_back(extension); |
81 } | 81 } |
82 file_type_info.include_all_files = true; | 82 file_type_info.include_all_files = true; |
83 gfx::NativeWindow owning_window = web_contents ? | 83 gfx::NativeWindow owning_window = web_contents ? |
84 platform_util::GetTopLevel(web_contents->GetNativeView()) : NULL; | 84 platform_util::GetTopLevel(web_contents->GetNativeView()) : NULL; |
85 | 85 |
86 select_file_dialog_->SelectFile( | 86 select_file_dialog_->SelectFile( |
87 SelectFileDialog::SELECT_SAVEAS_FILE, | 87 ui::SelectFileDialog::SELECT_SAVEAS_FILE, |
88 string16(), | 88 string16(), |
89 suggested_path_, | 89 suggested_path_, |
90 &file_type_info, | 90 &file_type_info, |
91 0, | 91 0, |
92 FILE_PATH_LITERAL(""), | 92 FILE_PATH_LITERAL(""), |
93 owning_window, | 93 owning_window, |
94 NULL); | 94 NULL); |
95 } | 95 } |
96 | 96 |
97 DownloadFilePicker::~DownloadFilePicker() { | 97 DownloadFilePicker::~DownloadFilePicker() { |
(...skipping 20 matching lines...) Expand all Loading... |
118 RecordFileSelected(path); | 118 RecordFileSelected(path); |
119 OnFileSelected(path); | 119 OnFileSelected(path); |
120 // Deletes |this| | 120 // Deletes |this| |
121 } | 121 } |
122 | 122 |
123 void DownloadFilePicker::FileSelectionCanceled(void* params) { | 123 void DownloadFilePicker::FileSelectionCanceled(void* params) { |
124 RecordFilePickerResult(download_manager_, FILE_PICKER_CANCEL); | 124 RecordFilePickerResult(download_manager_, FILE_PICKER_CANCEL); |
125 OnFileSelected(FilePath()); | 125 OnFileSelected(FilePath()); |
126 // Deletes |this| | 126 // Deletes |this| |
127 } | 127 } |
OLD | NEW |