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

Side by Side Diff: chrome/browser/ui/webui/print_preview/sticky_settings.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: minor fixes 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 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/ui/webui/print_preview/sticky_settings.h" 5 #include "chrome/browser/ui/webui/print_preview/sticky_settings.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/file_path.h"
9 #include "base/values.h" 8 #include "base/values.h"
10 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/common/chrome_switches.h" 10 #include "chrome/common/chrome_switches.h"
12 #include "chrome/common/pref_names.h" 11 #include "chrome/common/pref_names.h"
13 #include "components/pref_registry/pref_registry_syncable.h" 12 #include "components/pref_registry/pref_registry_syncable.h"
14 #include "components/prefs/pref_service.h" 13 #include "components/prefs/pref_service.h"
15 #include "printing/page_size_margins.h" 14 #include "printing/page_size_margins.h"
16 15
17 namespace printing { 16 namespace printing {
18 17
19 const char kSettingSavePath[] = "savePath";
20 const char kSettingAppState[] = "appState"; 18 const char kSettingAppState[] = "appState";
21 19
22 StickySettings::StickySettings() {} 20 StickySettings::StickySettings() {}
23 21
24 StickySettings::~StickySettings() {} 22 StickySettings::~StickySettings() {}
25 23
26 void StickySettings::StoreAppState(const std::string& data) { 24 void StickySettings::StoreAppState(const std::string& data) {
27 printer_app_state_.reset(new std::string(data)); 25 printer_app_state_.reset(new std::string(data));
28 } 26 }
29 27
30 void StickySettings::StoreSavePath(const base::FilePath& path) {
31 save_path_.reset(new base::FilePath(path));
32 }
33
34 void StickySettings::SaveInPrefs(PrefService* prefs) { 28 void StickySettings::SaveInPrefs(PrefService* prefs) {
35 DCHECK(prefs); 29 DCHECK(prefs);
36 if (prefs) { 30 if (prefs) {
37 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue); 31 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue);
38 if (save_path_.get())
39 value->SetString(printing::kSettingSavePath, save_path_->value());
40 if (printer_app_state_.get()) 32 if (printer_app_state_.get())
41 value->SetString(printing::kSettingAppState, 33 value->SetString(printing::kSettingAppState,
42 *printer_app_state_); 34 *printer_app_state_);
43 prefs->Set(prefs::kPrintPreviewStickySettings, *value); 35 prefs->Set(prefs::kPrintPreviewStickySettings, *value);
44 } 36 }
45 } 37 }
46 38
47 void StickySettings::RestoreFromPrefs(PrefService* prefs) { 39 void StickySettings::RestoreFromPrefs(PrefService* prefs) {
48 DCHECK(prefs); 40 DCHECK(prefs);
49 if (prefs) { 41 if (prefs) {
50 const base::DictionaryValue* value = 42 const base::DictionaryValue* value =
51 prefs->GetDictionary(prefs::kPrintPreviewStickySettings); 43 prefs->GetDictionary(prefs::kPrintPreviewStickySettings);
52 44
53 base::FilePath::StringType save_path;
54 if (value->GetString(printing::kSettingSavePath, &save_path))
55 save_path_.reset(new base::FilePath(save_path));
56 std::string buffer; 45 std::string buffer;
57 if (value->GetString(printing::kSettingAppState, &buffer)) 46 if (value->GetString(printing::kSettingAppState, &buffer))
58 printer_app_state_.reset(new std::string(buffer)); 47 printer_app_state_.reset(new std::string(buffer));
59 } 48 }
60 } 49 }
61 50
62 void StickySettings::RegisterProfilePrefs( 51 void StickySettings::RegisterProfilePrefs(
63 user_prefs::PrefRegistrySyncable* registry) { 52 user_prefs::PrefRegistrySyncable* registry) {
64 registry->RegisterDictionaryPref(prefs::kPrintPreviewStickySettings); 53 registry->RegisterDictionaryPref(prefs::kPrintPreviewStickySettings);
65 } 54 }
66 55
67 std::string* StickySettings::printer_app_state() { 56 std::string* StickySettings::printer_app_state() {
68 return printer_app_state_.get(); 57 return printer_app_state_.get();
69 } 58 }
70 59
71 base::FilePath* StickySettings::save_path() {
72 return save_path_.get();
73 }
74
75 } // namespace printing 60 } // namespace printing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698