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

Side by Side Diff: chrome/browser/ui/webui/print_preview/sticky_settings.h

Issue 10909124: Improves application state persistance. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Updates unit tests. Created 8 years, 3 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 #ifndef CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_STICKY_SETTINGS_H_ 5 #ifndef CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_STICKY_SETTINGS_H_
6 #define CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_STICKY_SETTINGS_H_ 6 #define CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_STICKY_SETTINGS_H_
7 7
8 #include "printing/print_job_constants.h" 8 #include "printing/print_job_constants.h"
9 9
10 #include <string> 10 #include <string>
11 11
12 #include "base/gtest_prod_util.h"
13 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
14 13
15 class FilePath; 14 class FilePath;
16 class PrintPreviewHandlerTest; 15 class PrintPreviewHandlerTest;
17 class PrefService; 16 class PrefService;
18 17
19 namespace base { 18 namespace base {
20 class DictionaryValue; 19 class DictionaryValue;
21 } 20 }
22 21
23 namespace printing { 22 namespace printing {
24 struct PageSizeMargins;
25 }
26
27 FORWARD_DECLARE_TEST(PrintPreviewHandlerTest, StickyMarginsCustom);
28 FORWARD_DECLARE_TEST(PrintPreviewHandlerTest, StickyMarginsDefault);
29 FORWARD_DECLARE_TEST(PrintPreviewHandlerTest, StickyMarginsCustomThenDefault);
30 FORWARD_DECLARE_TEST(PrintPreviewHandlerTest, GetLastUsedMarginSettingsCustom);
31 FORWARD_DECLARE_TEST(PrintPreviewHandlerTest, GetLastUsedMarginSettingsDefault);
32
33 namespace printing {
34 23
35 // Holds all the settings that should be remembered (sticky) in print preview. 24 // Holds all the settings that should be remembered (sticky) in print preview.
36 // A sticky setting will be restored next time the user launches print preview. 25 // A sticky setting will be restored next time the user launches print preview.
37 // Only one instance of this class is instantiated. 26 // Only one instance of this class is instantiated.
38 // TODO(abodenha) Simplify this class. See http://crbug.com/136926.
39 class StickySettings { 27 class StickySettings {
40 public: 28 public:
41 StickySettings(); 29 StickySettings();
42 ~StickySettings(); 30 ~StickySettings();
43 31
44 // Populates |last_used_custom_margins| according to the last used margin 32 FilePath* save_path();
45 // settings. 33 std::string* printer_app_state();
46 void GetLastUsedMarginSettings(
47 base::DictionaryValue* last_used_custom_margins) const;
48 34
49 std::string* printer_name(); 35 // Stores app state for the last used printer.
50 std::string* printer_cloud_print_data(); 36 void StoreAppState(const std::string& app_state);
51 printing::ColorModels color_model() const;
52 bool headers_footers() const;
53 FilePath* save_path();
54 printing::DuplexMode duplex_mode() const;
55
56 // Stores color model, duplex mode, margins and headers footers.
57 void Store(const base::DictionaryValue& settings);
58 // Stores last used printer name.
59 void StorePrinterName(const std::string& printer_name);
60 // Stores last used printer cloud print data.
61 void StoreCloudPrintData(const std::string& cloud_print_data);
62 // Stores the last path the user used to save to pdf. 37 // Stores the last path the user used to save to pdf.
63 void StoreSavePath(const FilePath& path); 38 void StoreSavePath(const FilePath& path);
64 39
65 void SaveInPrefs(PrefService* profile); 40 void SaveInPrefs(PrefService* profile);
66 void RestoreFromPrefs(PrefService* profile); 41 void RestoreFromPrefs(PrefService* profile);
67 static void RegisterUserPrefs(PrefService* prefs); 42 static void RegisterUserPrefs(PrefService* prefs);
68 private: 43 private:
69 void StoreColorModel(const base::DictionaryValue& settings);
70 void StoreMarginSettings(const base::DictionaryValue& settings);
71 void StoreHeadersFooters(const base::DictionaryValue& settings);
72 void StoreDuplexMode(const base::DictionaryValue& settings);
73 44
74 scoped_ptr<FilePath> save_path_; 45 scoped_ptr<FilePath> save_path_;
75 scoped_ptr<std::string> printer_name_; 46 scoped_ptr<std::string> printer_app_state_;
76 scoped_ptr<std::string> printer_cloud_print_data_;
77 printing::ColorModels color_model_;
78 printing::MarginType margins_type_;
79 scoped_ptr<printing::PageSizeMargins> page_size_margins_;
80 bool headers_footers_;
81 printing::DuplexMode duplex_mode_;
82
83 friend class ::PrintPreviewHandlerTest;
84 FRIEND_TEST_ALL_PREFIXES(::PrintPreviewHandlerTest, StickyMarginsCustom);
85 FRIEND_TEST_ALL_PREFIXES(::PrintPreviewHandlerTest, StickyMarginsDefault);
86 FRIEND_TEST_ALL_PREFIXES(::PrintPreviewHandlerTest,
87 StickyMarginsCustomThenDefault);
88 FRIEND_TEST_ALL_PREFIXES(::PrintPreviewHandlerTest,
89 GetLastUsedMarginSettingsCustom);
90 FRIEND_TEST_ALL_PREFIXES(::PrintPreviewHandlerTest,
91 GetLastUsedMarginSettingsDefault);
92 }; 47 };
93 48
94 } // namespace printing 49 } // namespace printing
95 50
96 #endif // CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_STICKY_SETTINGS_H_ 51 #endif // CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_STICKY_SETTINGS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698