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

Unified Diff: chrome/browser/ui/webui/print_preview/print_preview_handler.cc

Issue 2139303003: Modified printing to no longer store its own save path. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed comments, spacing Created 4 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/print_preview/print_preview_handler.cc
diff --git a/chrome/browser/ui/webui/print_preview/print_preview_handler.cc b/chrome/browser/ui/webui/print_preview/print_preview_handler.cc
index 3c419ca02e3964d021d0870ab6df1de8ddcbaa34..159d61be36dfd00a34b200acf65a3e07ae9d95d8 100644
--- a/chrome/browser/ui/webui/print_preview/print_preview_handler.cc
+++ b/chrome/browser/ui/webui/print_preview/print_preview_handler.cc
@@ -34,6 +34,7 @@
#include "build/build_config.h"
#include "chrome/browser/app_mode/app_mode_utils.h"
#include "chrome/browser/browser_process.h"
+#include "chrome/browser/download/download_prefs.h"
#include "chrome/browser/platform_util.h"
#include "chrome/browser/printing/print_dialog_cloud.h"
#include "chrome/browser/printing/print_error_dialog.h"
@@ -1357,20 +1358,13 @@ void PrintPreviewHandler::SelectFile(const base::FilePath& default_filename,
}
}
- // Initializing |save_path_| if it is not already initialized.
+ // Get save location from Download Preferences.
printing::StickySettings* sticky_settings = GetStickySettings();
Lei Zhang 2016/07/13 22:16:09 Move this down to line 1365, so it is closer to wh
- if (!sticky_settings->save_path()) {
- // Allowing IO operation temporarily. It is ok to do so here because
- // the select file dialog performs IO anyway in order to display the
- // folders and also it is modal.
- base::ThreadRestrictions::ScopedAllowIO allow_io;
Lei Zhang 2016/07/13 22:20:52 The #includes for base/path_service.h, base/thread
- base::FilePath file_path;
- PathService::Get(chrome::DIR_USER_DOCUMENTS, &file_path);
- sticky_settings->StoreSavePath(file_path);
- sticky_settings->SaveInPrefs(Profile::FromBrowserContext(
- preview_web_contents()->GetBrowserContext())->GetPrefs());
- }
-
+ DownloadPrefs* download_prefs = DownloadPrefs::FromBrowserContext(
+ preview_web_contents()->GetBrowserContext());
+ base::FilePath file_path = download_prefs->SaveFilePath();
+ sticky_settings->SaveInPrefs(Profile::FromBrowserContext(
+ preview_web_contents()->GetBrowserContext())->GetPrefs());
// Handle the no prompting case. Like the dialog prompt, this function
// returns and eventually FileSelected() gets called.
if (!prompt_user) {
@@ -1378,7 +1372,7 @@ void PrintPreviewHandler::SelectFile(const base::FilePath& default_filename,
BrowserThread::GetBlockingPool(),
FROM_HERE,
base::Bind(&GetUniquePath,
- sticky_settings->save_path()->Append(default_filename)),
+ download_prefs->SaveFilePath().Append(default_filename)),
base::Bind(&PrintPreviewHandler::OnGotUniqueFileName,
weak_factory_.GetWeakPtr()));
return;
@@ -1394,7 +1388,7 @@ void PrintPreviewHandler::SelectFile(const base::FilePath& default_filename,
select_file_dialog_->SelectFile(
ui::SelectFileDialog::SELECT_SAVEAS_FILE,
base::string16(),
- sticky_settings->save_path()->Append(default_filename),
+ download_prefs->SaveFilePath().Append(default_filename),
&file_type_info,
0,
base::FilePath::StringType(),
@@ -1422,9 +1416,11 @@ void PrintPreviewHandler::ShowSystemDialog() {
void PrintPreviewHandler::FileSelected(const base::FilePath& path,
int /* index */,
void* /* params */) {
- // Updating |save_path_| to the newly selected folder.
+ // Update downloads location and save sticky settings.
printing::StickySettings* sticky_settings = GetStickySettings();
- sticky_settings->StoreSavePath(path.DirName());
+ DownloadPrefs* download_prefs = DownloadPrefs::FromBrowserContext(
+ preview_web_contents()->GetBrowserContext());
+ download_prefs->SetSaveFilePath(path.DirName());
sticky_settings->SaveInPrefs(Profile::FromBrowserContext(
preview_web_contents()->GetBrowserContext())->GetPrefs());
web_ui()->CallJavascriptFunctionUnsafe("fileSelectionCompleted");

Powered by Google App Engine
This is Rietveld 408576698