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

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

Issue 10667026: Start consolidating cross-port file selection code into ui/base/dialogs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Attempt to fix win 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/save_package_file_picker_chromeos.h" 5 #include "chrome/browser/download/save_package_file_picker_chromeos.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/i18n/file_util_icu.h" 9 #include "base/i18n/file_util_icu.h"
10 #include "base/threading/sequenced_worker_pool.h" 10 #include "base/threading/sequenced_worker_pool.h"
11 #include "chrome/browser/chromeos/gdata/gdata_download_observer.h" 11 #include "chrome/browser/chromeos/gdata/gdata_download_observer.h"
12 #include "chrome/browser/chromeos/gdata/gdata_util.h" 12 #include "chrome/browser/chromeos/gdata/gdata_util.h"
13 #include "chrome/browser/platform_util.h" 13 #include "chrome/browser/platform_util.h"
14 #include "chrome/browser/profiles/profile_manager.h" 14 #include "chrome/browser/profiles/profile_manager.h"
15 #include "chrome/browser/ui/chrome_select_file_policy.h"
15 #include "content/public/browser/browser_thread.h" 16 #include "content/public/browser/browser_thread.h"
16 #include "content/public/browser/download_item.h" 17 #include "content/public/browser/download_item.h"
17 #include "content/public/browser/web_contents.h" 18 #include "content/public/browser/web_contents.h"
18 19
19 namespace { 20 namespace {
20 21
21 // If false, we don't prompt the user as to where to save the file. This 22 // If false, we don't prompt the user as to where to save the file. This
22 // exists only for testing. 23 // exists only for testing.
23 bool g_should_prompt_for_filename = true; 24 bool g_should_prompt_for_filename = true;
24 25
25 // Trampoline callback between GetGDataTempDownloadPath() and |callback|. 26 // Trampoline callback between GetGDataTempDownloadPath() and |callback|.
26 void ContinueSettingUpGDataDownload( 27 void ContinueSettingUpGDataDownload(
27 const content::SavePackagePathPickedCallback& callback, 28 const content::SavePackagePathPickedCallback& callback,
28 const FilePath& gdata_path, 29 const FilePath& gdata_path,
29 const FilePath& gdata_tmp_download_path) { 30 const FilePath& gdata_tmp_download_path) {
30 callback.Run(gdata_tmp_download_path, content::SAVE_PAGE_TYPE_AS_MHTML, 31 callback.Run(gdata_tmp_download_path, content::SAVE_PAGE_TYPE_AS_MHTML,
31 base::Bind(&gdata::GDataDownloadObserver::SetDownloadParams, 32 base::Bind(&gdata::GDataDownloadObserver::SetDownloadParams,
32 gdata_path)); 33 gdata_path));
33 } 34 }
34 35
35 } // anonymous namespace 36 } // anonymous namespace
36 37
37 SavePackageFilePickerChromeOS::SavePackageFilePickerChromeOS( 38 SavePackageFilePickerChromeOS::SavePackageFilePickerChromeOS(
38 content::WebContents* web_contents, 39 content::WebContents* web_contents,
39 const FilePath& suggested_path, 40 const FilePath& suggested_path,
40 const content::SavePackagePathPickedCallback& callback) 41 const content::SavePackagePathPickedCallback& callback)
41 : content::WebContentsObserver(web_contents), 42 : content::WebContentsObserver(web_contents),
42 callback_(callback) { 43 callback_(callback) {
43 if (g_should_prompt_for_filename) { 44 if (g_should_prompt_for_filename) {
44 select_file_dialog_ = SelectFileDialog::Create(this); 45 select_file_dialog_ = SelectFileDialog::Create(
46 this, new ChromeSelectFilePolicy(web_contents));
45 select_file_dialog_->SelectFile(SelectFileDialog::SELECT_SAVEAS_FILE, 47 select_file_dialog_->SelectFile(SelectFileDialog::SELECT_SAVEAS_FILE,
46 string16(), 48 string16(),
47 suggested_path.ReplaceExtension("mhtml"), 49 suggested_path.ReplaceExtension("mhtml"),
48 NULL, 50 NULL,
49 0, 51 0,
50 "mhtml", 52 "mhtml",
51 web_contents,
52 platform_util::GetTopLevel( 53 platform_util::GetTopLevel(
53 web_contents->GetNativeView()), 54 web_contents->GetNativeView()),
54 NULL); 55 NULL);
55 } else { 56 } else {
56 FileSelected(suggested_path.ReplaceExtension("mhtml"), 0, NULL); 57 FileSelected(suggested_path.ReplaceExtension("mhtml"), 0, NULL);
57 } 58 }
58 } 59 }
59 60
60 void SavePackageFilePickerChromeOS::SetShouldPromptUser(bool should_prompt) { 61 void SavePackageFilePickerChromeOS::SetShouldPromptUser(bool should_prompt) {
61 g_should_prompt_for_filename = should_prompt; 62 g_should_prompt_for_filename = should_prompt;
(...skipping 28 matching lines...) Expand all
90 } else { 91 } else {
91 callback_.Run(selected_path, content::SAVE_PAGE_TYPE_AS_MHTML, 92 callback_.Run(selected_path, content::SAVE_PAGE_TYPE_AS_MHTML,
92 content::SavePackageDownloadCreatedCallback()); 93 content::SavePackageDownloadCreatedCallback());
93 } 94 }
94 delete this; 95 delete this;
95 } 96 }
96 97
97 void SavePackageFilePickerChromeOS::FileSelectionCanceled(void* params) { 98 void SavePackageFilePickerChromeOS::FileSelectionCanceled(void* params) {
98 delete this; 99 delete this;
99 } 100 }
OLDNEW
« no previous file with comments | « chrome/browser/download/save_package_file_picker.cc ('k') | chrome/browser/extensions/api/file_system/file_system_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698