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

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

Issue 10804026: Fix open dialog not remembering last opened folder on drive (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase 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 "chrome/browser/ui/chrome_select_file_policy.h"
16 #include "content/public/browser/browser_thread.h" 16 #include "content/public/browser/browser_thread.h"
17 #include "content/public/browser/download_item.h" 17 #include "content/public/browser/download_item.h"
18 #include "content/public/browser/web_contents.h" 18 #include "content/public/browser/web_contents.h"
19 #include "ui/base/dialogs/selected_file_info.h"
19 20
20 namespace { 21 namespace {
21 22
22 // If false, we don't prompt the user as to where to save the file. This 23 // If false, we don't prompt the user as to where to save the file. This
23 // exists only for testing. 24 // exists only for testing.
24 bool g_should_prompt_for_filename = true; 25 bool g_should_prompt_for_filename = true;
25 26
26 // Trampoline callback between GetGDataTempDownloadPath() and |callback|. 27 // Trampoline callback between GetGDataTempDownloadPath() and |callback|.
27 void ContinueSettingUpGDataDownload( 28 void ContinueSettingUpGDataDownload(
28 const content::SavePackagePathPickedCallback& callback, 29 const content::SavePackagePathPickedCallback& callback,
(...skipping 30 matching lines...) Expand all
59 } 60 }
60 61
61 void SavePackageFilePickerChromeOS::SetShouldPromptUser(bool should_prompt) { 62 void SavePackageFilePickerChromeOS::SetShouldPromptUser(bool should_prompt) {
62 g_should_prompt_for_filename = should_prompt; 63 g_should_prompt_for_filename = should_prompt;
63 } 64 }
64 65
65 SavePackageFilePickerChromeOS::~SavePackageFilePickerChromeOS() { 66 SavePackageFilePickerChromeOS::~SavePackageFilePickerChromeOS() {
66 } 67 }
67 68
68 void SavePackageFilePickerChromeOS::FileSelected( 69 void SavePackageFilePickerChromeOS::FileSelected(
69 const FilePath& selected_path_const, 70 const FilePath& selected_path,
71 int unused_index,
72 void* unused_params) {
73 FileSelectedWithExtraInfo(
74 ui::SelectedFileInfo(selected_path, selected_path),
75 unused_index,
76 unused_params);
77 }
78
79 void SavePackageFilePickerChromeOS::FileSelectedWithExtraInfo(
80 const ui::SelectedFileInfo& selected_file_info,
70 int unused_index, 81 int unused_index,
71 void* unused_params) { 82 void* unused_params) {
72 if (!web_contents()) { 83 if (!web_contents()) {
73 delete this; 84 delete this;
74 return; 85 return;
75 } 86 }
76 FilePath selected_path = selected_path_const; 87 FilePath selected_path = selected_file_info.file_path;
77 file_util::NormalizeFileNameEncoding(&selected_path); 88 file_util::NormalizeFileNameEncoding(&selected_path);
78 Profile* profile = Profile::FromBrowserContext( 89 Profile* profile = Profile::FromBrowserContext(
79 web_contents()->GetBrowserContext()); 90 web_contents()->GetBrowserContext());
80 DCHECK(profile); 91 DCHECK(profile);
81 92
82 if (gdata::util::IsUnderGDataMountPoint(selected_path)) { 93 if (gdata::util::IsUnderGDataMountPoint(selected_path)) {
83 // Here's a map to the callback chain: 94 // Here's a map to the callback chain:
84 // GetGDataTempDownloadPath -> 95 // GetGDataTempDownloadPath ->
85 // ContinueSettingUpGDataDownload -> 96 // ContinueSettingUpGDataDownload ->
86 // callback_ = SavePackage::OnPathPicked -> 97 // callback_ = SavePackage::OnPathPicked ->
87 // download_created_callback = OnSavePackageDownloadCreated 98 // download_created_callback = OnSavePackageDownloadCreated
88 gdata::GDataDownloadObserver::SubstituteGDataDownloadPath( 99 gdata::GDataDownloadObserver::SubstituteGDataDownloadPath(
89 profile, selected_path, NULL, 100 profile, selected_path, NULL,
90 base::Bind(&ContinueSettingUpGDataDownload, callback_, selected_path)); 101 base::Bind(&ContinueSettingUpGDataDownload, callback_, selected_path));
91 } else { 102 } else {
92 callback_.Run(selected_path, content::SAVE_PAGE_TYPE_AS_MHTML, 103 callback_.Run(selected_path, content::SAVE_PAGE_TYPE_AS_MHTML,
93 content::SavePackageDownloadCreatedCallback()); 104 content::SavePackageDownloadCreatedCallback());
94 } 105 }
95 delete this; 106 delete this;
96 } 107 }
97 108
98 void SavePackageFilePickerChromeOS::FileSelectionCanceled(void* params) { 109 void SavePackageFilePickerChromeOS::FileSelectionCanceled(void* params) {
99 delete this; 110 delete this;
100 } 111 }
OLDNEW
« no previous file with comments | « chrome/browser/download/save_package_file_picker_chromeos.h ('k') | chrome/browser/file_select_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698