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

Side by Side Diff: content/shell/browser/shell_download_manager_delegate.cc

Issue 231733005: Delete the GTK+ port of Chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remerge to ToT Created 6 years, 8 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "content/shell/browser/shell_download_manager_delegate.h" 5 #include "content/shell/browser/shell_download_manager_delegate.h"
6 6
7 #if defined(TOOLKIT_GTK)
8 #include <gtk/gtk.h>
9 #endif
10
11 #if defined(OS_WIN) 7 #if defined(OS_WIN)
12 #include <windows.h> 8 #include <windows.h>
13 #include <commdlg.h> 9 #include <commdlg.h>
14 #endif 10 #endif
15 11
16 #include "base/bind.h" 12 #include "base/bind.h"
17 #include "base/command_line.h" 13 #include "base/command_line.h"
18 #include "base/file_util.h" 14 #include "base/file_util.h"
19 #include "base/logging.h" 15 #include "base/logging.h"
20 #include "base/strings/string_util.h" 16 #include "base/strings/string_util.h"
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 std::wstring directory; 179 std::wstring directory;
184 if (!suggested_path.empty()) 180 if (!suggested_path.empty())
185 directory = suggested_path.DirName().value(); 181 directory = suggested_path.DirName().value();
186 182
187 save_as.lpstrInitialDir = directory.c_str(); 183 save_as.lpstrInitialDir = directory.c_str();
188 save_as.Flags = OFN_OVERWRITEPROMPT | OFN_EXPLORER | OFN_ENABLESIZING | 184 save_as.Flags = OFN_OVERWRITEPROMPT | OFN_EXPLORER | OFN_ENABLESIZING |
189 OFN_NOCHANGEDIR | OFN_PATHMUSTEXIST; 185 OFN_NOCHANGEDIR | OFN_PATHMUSTEXIST;
190 186
191 if (GetSaveFileName(&save_as)) 187 if (GetSaveFileName(&save_as))
192 result = base::FilePath(std::wstring(save_as.lpstrFile)); 188 result = base::FilePath(std::wstring(save_as.lpstrFile));
193 #elif defined(TOOLKIT_GTK)
194 GtkWidget *dialog;
195 gfx::NativeWindow parent_window;
196 std::string base_name = base::FilePath(suggested_path).BaseName().value();
197
198 parent_window = item->GetWebContents()->GetView()->GetTopLevelNativeWindow();
199 dialog = gtk_file_chooser_dialog_new("Save File",
200 parent_window,
201 GTK_FILE_CHOOSER_ACTION_SAVE,
202 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
203 GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
204 NULL);
205 gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dialog),
206 TRUE);
207 gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog),
208 base_name.c_str());
209
210 if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
211 char *filename;
212 filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
213 result = base::FilePath(filename);
214 g_free(filename);
215 }
216 gtk_widget_destroy(dialog);
217 #else 189 #else
218 NOTIMPLEMENTED(); 190 NOTIMPLEMENTED();
219 #endif 191 #endif
220 192
221 callback.Run(result, DownloadItem::TARGET_DISPOSITION_PROMPT, 193 callback.Run(result, DownloadItem::TARGET_DISPOSITION_PROMPT,
222 DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, result); 194 DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, result);
223 } 195 }
224 196
225 void ShellDownloadManagerDelegate::SetDownloadBehaviorForTesting( 197 void ShellDownloadManagerDelegate::SetDownloadBehaviorForTesting(
226 const base::FilePath& default_download_path) { 198 const base::FilePath& default_download_path) {
227 default_download_path_ = default_download_path; 199 default_download_path_ = default_download_path;
228 suppress_prompting_ = true; 200 suppress_prompting_ = true;
229 } 201 }
230 202
231 } // namespace content 203 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698