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 #include "chrome/service/cloud_print/connector_settings.h" | 5 #include "chrome/service/cloud_print/connector_settings.h" |
6 | 6 |
7 #include "base/values.h" | 7 #include "base/values.h" |
8 #include "chrome/common/cloud_print/cloud_print_constants.h" | 8 #include "chrome/common/cloud_print/cloud_print_constants.h" |
9 #include "chrome/common/pref_names.h" | 9 #include "chrome/common/pref_names.h" |
10 #include "chrome/service/cloud_print/print_system.h" | 10 #include "chrome/service/cloud_print/print_system.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 xmpp_ping_enabled_(false), | 25 xmpp_ping_enabled_(false), |
26 xmpp_ping_timeout_sec_(kDefaultXmppPingTimeoutSecs) { | 26 xmpp_ping_timeout_sec_(kDefaultXmppPingTimeoutSecs) { |
27 } | 27 } |
28 | 28 |
29 ConnectorSettings::~ConnectorSettings() { | 29 ConnectorSettings::~ConnectorSettings() { |
30 } | 30 } |
31 | 31 |
32 void ConnectorSettings::InitFrom(ServiceProcessPrefs* prefs) { | 32 void ConnectorSettings::InitFrom(ServiceProcessPrefs* prefs) { |
33 CopyFrom(ConnectorSettings()); | 33 CopyFrom(ConnectorSettings()); |
34 | 34 |
35 proxy_id_ = prefs->GetString(prefs::kCloudPrintProxyId, ""); | 35 proxy_id_ = prefs->GetString(prefs::kCloudPrintProxyId, std::string()); |
36 if (proxy_id_.empty()) { | 36 if (proxy_id_.empty()) { |
37 proxy_id_ = PrintSystem::GenerateProxyId(); | 37 proxy_id_ = PrintSystem::GenerateProxyId(); |
38 prefs->SetString(prefs::kCloudPrintProxyId, proxy_id_); | 38 prefs->SetString(prefs::kCloudPrintProxyId, proxy_id_); |
39 prefs->WritePrefs(); | 39 prefs->WritePrefs(); |
40 } | 40 } |
41 | 41 |
42 // Getting print system specific settings from the preferences. | 42 // Getting print system specific settings from the preferences. |
43 const base::DictionaryValue* print_system_settings = | 43 const base::DictionaryValue* print_system_settings = |
44 prefs->GetDictionary(prefs::kCloudPrintPrintSystemSettings); | 44 prefs->GetDictionary(prefs::kCloudPrintPrintSystemSettings); |
45 if (print_system_settings) { | 45 if (print_system_settings) { |
46 print_system_settings_.reset(print_system_settings->DeepCopy()); | 46 print_system_settings_.reset(print_system_settings->DeepCopy()); |
47 // TODO(vitalybuka) : Consider to rename and move out option from | 47 // TODO(vitalybuka) : Consider to rename and move out option from |
48 // print_system_settings. | 48 // print_system_settings. |
49 print_system_settings_->GetBoolean(kDeleteOnEnumFail, | 49 print_system_settings_->GetBoolean(kDeleteOnEnumFail, |
50 &delete_on_enum_fail_); | 50 &delete_on_enum_fail_); |
51 } | 51 } |
52 | 52 |
53 // Check if there is an override for the cloud print server URL. | 53 // Check if there is an override for the cloud print server URL. |
54 server_url_ = GURL(prefs->GetString(prefs::kCloudPrintServiceURL, "")); | 54 server_url_ = |
| 55 GURL(prefs->GetString(prefs::kCloudPrintServiceURL, std::string())); |
55 DCHECK(server_url_.is_empty() || server_url_.is_valid()); | 56 DCHECK(server_url_.is_empty() || server_url_.is_valid()); |
56 if (server_url_.is_empty() || !server_url_.is_valid()) { | 57 if (server_url_.is_empty() || !server_url_.is_valid()) { |
57 server_url_ = GURL(kDefaultCloudPrintServerUrl); | 58 server_url_ = GURL(kDefaultCloudPrintServerUrl); |
58 } | 59 } |
59 DCHECK(server_url_.is_valid()); | 60 DCHECK(server_url_.is_valid()); |
60 | 61 |
61 connect_new_printers_ = prefs->GetBoolean( | 62 connect_new_printers_ = prefs->GetBoolean( |
62 prefs::kCloudPrintConnectNewPrinters, true); | 63 prefs::kCloudPrintConnectNewPrinters, true); |
63 | 64 |
64 xmpp_ping_enabled_ = prefs->GetBoolean( | 65 xmpp_ping_enabled_ = prefs->GetBoolean( |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 void ConnectorSettings::SetXmppPingTimeoutSec(int timeout) { | 98 void ConnectorSettings::SetXmppPingTimeoutSec(int timeout) { |
98 xmpp_ping_timeout_sec_ = timeout; | 99 xmpp_ping_timeout_sec_ = timeout; |
99 if (xmpp_ping_timeout_sec_ < kMinimumXmppPingTimeoutSecs) { | 100 if (xmpp_ping_timeout_sec_ < kMinimumXmppPingTimeoutSecs) { |
100 LOG(WARNING) << | 101 LOG(WARNING) << |
101 "CP_CONNECTOR: XMPP ping timeout is less then minimal value"; | 102 "CP_CONNECTOR: XMPP ping timeout is less then minimal value"; |
102 xmpp_ping_timeout_sec_ = kMinimumXmppPingTimeoutSecs; | 103 xmpp_ping_timeout_sec_ = kMinimumXmppPingTimeoutSecs; |
103 } | 104 } |
104 } | 105 } |
105 | 106 |
106 } // namespace cloud_print | 107 } // namespace cloud_print |
OLD | NEW |