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

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

Powered by Google App Engine
This is Rietveld 408576698