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