Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / chrome / browser / ui / webui / print_preview / sticky_settings.cc
blobe9077b1dae31adb0b01d2187d4e86d36ead464de
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
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/webui/print_preview/sticky_settings.h"
7 #include "base/command_line.h"
8 #include "base/files/file_path.h"
9 #include "base/prefs/pref_service.h"
10 #include "base/values.h"
11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/common/chrome_switches.h"
13 #include "chrome/common/pref_names.h"
14 #include "components/pref_registry/pref_registry_syncable.h"
15 #include "printing/page_size_margins.h"
17 namespace printing {
19 const char kSettingSavePath[] = "savePath";
20 const char kSettingAppState[] = "appState";
22 StickySettings::StickySettings() {}
24 StickySettings::~StickySettings() {}
26 void StickySettings::StoreAppState(const std::string& data) {
27 printer_app_state_.reset(new std::string(data));
30 void StickySettings::StoreSavePath(const base::FilePath& path) {
31 save_path_.reset(new base::FilePath(path));
34 void StickySettings::SaveInPrefs(PrefService* prefs) {
35 DCHECK(prefs);
36 if (prefs) {
37 scoped_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())
41 value->SetString(printing::kSettingAppState,
42 *printer_app_state_);
43 prefs->Set(prefs::kPrintPreviewStickySettings, *value);
47 void StickySettings::RestoreFromPrefs(PrefService* prefs) {
48 DCHECK(prefs);
49 if (prefs) {
50 const base::DictionaryValue* value =
51 prefs->GetDictionary(prefs::kPrintPreviewStickySettings);
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;
57 if (value->GetString(printing::kSettingAppState, &buffer))
58 printer_app_state_.reset(new std::string(buffer));
62 void StickySettings::RegisterProfilePrefs(
63 user_prefs::PrefRegistrySyncable* registry) {
64 registry->RegisterDictionaryPref(prefs::kPrintPreviewStickySettings);
67 std::string* StickySettings::printer_app_state() {
68 return printer_app_state_.get();
71 base::FilePath* StickySettings::save_path() {
72 return save_path_.get();
75 } // namespace printing