OLD | NEW |
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_SERVICE_CLOUD_PRINT_CONNECTOR_SETTINGS_H_ | 5 #ifndef CHROME_SERVICE_CLOUD_PRINT_CONNECTOR_SETTINGS_H_ |
6 #define CHROME_SERVICE_CLOUD_PRINT_CONNECTOR_SETTINGS_H_ | 6 #define CHROME_SERVICE_CLOUD_PRINT_CONNECTOR_SETTINGS_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 | 10 |
| 11 #include "base/gtest_prod_util.h" |
11 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
12 #include "googleurl/src/gurl.h" | 13 #include "googleurl/src/gurl.h" |
13 | 14 |
14 class ServiceProcessPrefs; | 15 class ServiceProcessPrefs; |
15 | 16 |
16 namespace base { | 17 namespace base { |
17 class DictionaryValue; | 18 class DictionaryValue; |
18 } | 19 } |
19 | 20 |
20 namespace cloud_print { | 21 namespace cloud_print { |
(...skipping 12 matching lines...) Expand all Loading... |
33 }; | 34 }; |
34 | 35 |
35 const std::string& proxy_id() const { | 36 const std::string& proxy_id() const { |
36 return proxy_id_; | 37 return proxy_id_; |
37 } | 38 } |
38 | 39 |
39 bool delete_on_enum_fail() const { | 40 bool delete_on_enum_fail() const { |
40 return delete_on_enum_fail_; | 41 return delete_on_enum_fail_; |
41 } | 42 } |
42 | 43 |
43 bool connect_new_printers() const { | |
44 return connect_new_printers_; | |
45 }; | |
46 | |
47 bool xmpp_ping_enabled() const { | 44 bool xmpp_ping_enabled() const { |
48 return xmpp_ping_enabled_; | 45 return xmpp_ping_enabled_; |
49 } | 46 } |
50 | 47 |
51 void set_xmpp_ping_enabled(bool enabled) { | |
52 xmpp_ping_enabled_ = enabled; | |
53 } | |
54 | |
55 int xmpp_ping_timeout_sec() const { | 48 int xmpp_ping_timeout_sec() const { |
56 return xmpp_ping_timeout_sec_; | 49 return xmpp_ping_timeout_sec_; |
57 } | 50 } |
58 | 51 |
59 const base::DictionaryValue* print_system_settings() const { | 52 const base::DictionaryValue* print_system_settings() const { |
60 return print_system_settings_.get(); | 53 return print_system_settings_.get(); |
61 }; | 54 }; |
62 | 55 |
63 bool IsPrinterBlacklisted(const std::string& name) const; | 56 bool ShouldConnect(const std::string& printer_name) const; |
| 57 |
| 58 private: |
| 59 friend class ConnectorSettingsTest; |
| 60 FRIEND_TEST_ALL_PREFIXES(ConnectorSettingsTest, SettersTest); |
| 61 |
| 62 void set_xmpp_ping_enabled(bool enabled) { |
| 63 xmpp_ping_enabled_ = enabled; |
| 64 } |
64 | 65 |
65 void SetXmppPingTimeoutSec(int timeout); | 66 void SetXmppPingTimeoutSec(int timeout); |
66 | 67 |
67 private: | |
68 // Cloud Print server url. | 68 // Cloud Print server url. |
69 GURL server_url_; | 69 GURL server_url_; |
70 | 70 |
71 // This is initialized after a successful call to one of the Enable* methods. | 71 // This is initialized after a successful call to one of the Enable* methods. |
72 // It is not cleared in DisableUser. | 72 // It is not cleared in DisableUser. |
73 std::string proxy_id_; | 73 std::string proxy_id_; |
74 | 74 |
75 // If |true| printers that are not found locally will be deleted on GCP | 75 // If |true| printers that are not found locally will be deleted on GCP |
76 // even if the local enumeration failed. | 76 // even if the local enumeration failed. |
77 bool delete_on_enum_fail_; | 77 bool delete_on_enum_fail_; |
78 | 78 |
79 // If true register all new printers in cloud print. | 79 // If true register all new printers in cloud print. |
80 bool connect_new_printers_; | 80 bool connect_new_printers_; |
81 | 81 |
82 // Indicate if XMPP pings are enabled. | 82 // Indicate if XMPP pings are enabled. |
83 bool xmpp_ping_enabled_; | 83 bool xmpp_ping_enabled_; |
84 | 84 |
85 // Indicate timeout between XMPP pings. | 85 // Indicate timeout between XMPP pings. |
86 int xmpp_ping_timeout_sec_; | 86 int xmpp_ping_timeout_sec_; |
87 | 87 |
88 // List of printers which should not be connected. | 88 // Black list if connect_new_printers_ is true, or whitelist if false. |
89 std::set<std::string> printer_blacklist_; | 89 typedef std::set<std::string> Printers; |
| 90 Printers printers_; |
90 | 91 |
91 // Print system settings. | 92 // Print system settings. |
92 scoped_ptr<base::DictionaryValue> print_system_settings_; | 93 scoped_ptr<base::DictionaryValue> print_system_settings_; |
93 | 94 |
94 DISALLOW_COPY_AND_ASSIGN(ConnectorSettings); | 95 DISALLOW_COPY_AND_ASSIGN(ConnectorSettings); |
95 }; | 96 }; |
96 | 97 |
97 } // namespace cloud_print | 98 } // namespace cloud_print |
98 | 99 |
99 #endif // CHROME_SERVICE_CLOUD_PRINT_CONNECTOR_SETTINGS_H_ | 100 #endif // CHROME_SERVICE_CLOUD_PRINT_CONNECTOR_SETTINGS_H_ |
100 | 101 |
OLD | NEW |