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