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

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

Issue 2688413007: Add display::GetDisplayNearestView (Closed)
Patch Set: add missing files Created 3 years, 10 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
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.h" 5 #include "chrome/browser/download/download_file_picker.h"
6 6
7 #include "base/metrics/histogram_macros.h" 7 #include "base/metrics/histogram_macros.h"
8 #include "chrome/browser/download/download_prefs.h" 8 #include "chrome/browser/download/download_prefs.h"
9 #include "chrome/browser/platform_util.h"
10 #include "chrome/browser/ui/chrome_select_file_policy.h" 9 #include "chrome/browser/ui/chrome_select_file_policy.h"
11 #include "content/public/browser/browser_context.h" 10 #include "content/public/browser/browser_context.h"
12 #include "content/public/browser/download_item.h" 11 #include "content/public/browser/download_item.h"
13 #include "content/public/browser/download_manager.h" 12 #include "content/public/browser/download_manager.h"
14 #include "content/public/browser/web_contents.h" 13 #include "content/public/browser/web_contents.h"
14 #include "ui/gfx/view_util.h"
15 15
16 using content::DownloadItem; 16 using content::DownloadItem;
17 using content::DownloadManager; 17 using content::DownloadManager;
18 using content::WebContents; 18 using content::WebContents;
19 19
20 namespace { 20 namespace {
21 21
22 enum FilePickerResult { 22 enum FilePickerResult {
23 FILE_PICKER_SAME, 23 FILE_PICKER_SAME,
24 FILE_PICKER_DIFFERENT_DIR, 24 FILE_PICKER_DIFFERENT_DIR,
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 // with double extensions like .tar.gz, so only pass in normal ones. 78 // with double extensions like .tar.gz, so only pass in normal ones.
79 base::FilePath::StringType extension = suggested_path_.FinalExtension(); 79 base::FilePath::StringType extension = suggested_path_.FinalExtension();
80 if (!extension.empty()) { 80 if (!extension.empty()) {
81 extension.erase(extension.begin()); // drop the . 81 extension.erase(extension.begin()); // drop the .
82 file_type_info.extensions.resize(1); 82 file_type_info.extensions.resize(1);
83 file_type_info.extensions[0].push_back(extension); 83 file_type_info.extensions[0].push_back(extension);
84 } 84 }
85 file_type_info.include_all_files = true; 85 file_type_info.include_all_files = true;
86 file_type_info.allowed_paths = 86 file_type_info.allowed_paths =
87 ui::SelectFileDialog::FileTypeInfo::NATIVE_OR_DRIVE_PATH; 87 ui::SelectFileDialog::FileTypeInfo::NATIVE_OR_DRIVE_PATH;
88 gfx::NativeWindow owning_window = web_contents ? 88 gfx::NativeWindow owning_window =
89 platform_util::GetTopLevel(web_contents->GetNativeView()) : NULL; 89 web_contents ? gfx::GetTopLevel(web_contents->GetNativeView()) : NULL;
90 90
91 select_file_dialog_->SelectFile(ui::SelectFileDialog::SELECT_SAVEAS_FILE, 91 select_file_dialog_->SelectFile(ui::SelectFileDialog::SELECT_SAVEAS_FILE,
92 base::string16(), 92 base::string16(),
93 suggested_path_, 93 suggested_path_,
94 &file_type_info, 94 &file_type_info,
95 0, 95 0,
96 base::FilePath::StringType(), 96 base::FilePath::StringType(),
97 owning_window, 97 owning_window,
98 NULL); 98 NULL);
99 } 99 }
(...skipping 20 matching lines...) Expand all
120 // Deletes |this| 120 // Deletes |this|
121 } 121 }
122 122
123 // static 123 // static
124 void DownloadFilePicker::ShowFilePicker(DownloadItem* item, 124 void DownloadFilePicker::ShowFilePicker(DownloadItem* item,
125 const base::FilePath& suggested_path, 125 const base::FilePath& suggested_path,
126 const FileSelectedCallback& callback) { 126 const FileSelectedCallback& callback) {
127 new DownloadFilePicker(item, suggested_path, callback); 127 new DownloadFilePicker(item, suggested_path, callback);
128 // DownloadFilePicker deletes itself. 128 // DownloadFilePicker deletes itself.
129 } 129 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698