Chromium Code Reviews| 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/pref_names.h" | 8 #include "chrome/common/pref_names.h" |
| 9 #include "chrome/service/cloud_print/cloud_print_consts.h" | 9 #include "chrome/service/cloud_print/cloud_print_consts.h" |
| 10 #include "chrome/service/cloud_print/print_system.h" | 10 #include "chrome/service/cloud_print/print_system.h" |
| 11 #include "chrome/service/service_process_prefs.h" | 11 #include "chrome/service/service_process_prefs.h" |
| 12 | 12 |
| 13 namespace { | 13 namespace { |
| 14 | 14 |
| 15 const char kDefaultCloudPrintServerUrl[] = "https://www.google.com/cloudprint"; | 15 const char kDefaultCloudPrintServerUrl[] = "https://www.google.com/cloudprint"; |
| 16 const char kDeleteOnEnumFail[] = "delete_on_enum_fail"; | 16 const char kDeleteOnEnumFail[] = "delete_on_enum_fail"; |
| 17 | 17 |
| 18 } // namespace | 18 } // namespace |
| 19 | 19 |
| 20 ConnectorSettings::ConnectorSettings() | 20 ConnectorSettings::ConnectorSettings() |
|
Vitaly Buka (NO REVIEWS)
2012/10/22 20:52:53
pleas update connector_settings_unittest.cc
gene
2012/10/22 21:44:12
Done.
| |
| 21 : delete_on_enum_fail_(false), | 21 : delete_on_enum_fail_(false), |
| 22 connect_new_printers_(true) { | 22 connect_new_printers_(true), |
|
Vitaly Buka (NO REVIEWS)
2012/10/22 20:52:53
xmpp_ping_enabled_ is not initialized
gene
2012/10/22 21:44:12
Done.
| |
| 23 xmpp_ping_timeout_sec_(kDefaultXmppPingTimeoutSecs) { | |
| 23 } | 24 } |
| 24 | 25 |
| 25 ConnectorSettings::~ConnectorSettings() { | 26 ConnectorSettings::~ConnectorSettings() { |
| 26 } | 27 } |
| 27 | 28 |
| 28 void ConnectorSettings::InitFrom(ServiceProcessPrefs* prefs) { | 29 void ConnectorSettings::InitFrom(ServiceProcessPrefs* prefs) { |
| 29 CopyFrom(ConnectorSettings()); | 30 CopyFrom(ConnectorSettings()); |
| 30 | 31 |
| 31 proxy_id_ = prefs->GetString(prefs::kCloudPrintProxyId, ""); | 32 proxy_id_ = prefs->GetString(prefs::kCloudPrintProxyId, ""); |
| 32 if (proxy_id_.empty()) { | 33 if (proxy_id_.empty()) { |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 49 // Check if there is an override for the cloud print server URL. | 50 // Check if there is an override for the cloud print server URL. |
| 50 server_url_ = GURL(prefs->GetString(prefs::kCloudPrintServiceURL, "")); | 51 server_url_ = GURL(prefs->GetString(prefs::kCloudPrintServiceURL, "")); |
| 51 DCHECK(server_url_.is_empty() || server_url_.is_valid()); | 52 DCHECK(server_url_.is_empty() || server_url_.is_valid()); |
| 52 if (server_url_.is_empty() || !server_url_.is_valid()) { | 53 if (server_url_.is_empty() || !server_url_.is_valid()) { |
| 53 server_url_ = GURL(kDefaultCloudPrintServerUrl); | 54 server_url_ = GURL(kDefaultCloudPrintServerUrl); |
| 54 } | 55 } |
| 55 DCHECK(server_url_.is_valid()); | 56 DCHECK(server_url_.is_valid()); |
| 56 | 57 |
| 57 connect_new_printers_ = prefs->GetBoolean( | 58 connect_new_printers_ = prefs->GetBoolean( |
| 58 prefs::kCloudPrintConnectNewPrinters, true); | 59 prefs::kCloudPrintConnectNewPrinters, true); |
| 60 | |
| 61 xmpp_ping_enabled_ = prefs->GetBoolean( | |
| 62 prefs::kCloudPrintXmppPingEnabled, false); | |
| 63 xmpp_ping_timeout_sec_ = prefs->GetInt( | |
| 64 prefs::kCloudPrintXmppPingTimeout, kDefaultXmppPingTimeoutSecs); | |
| 65 | |
| 59 const base::ListValue* printers = prefs->GetList( | 66 const base::ListValue* printers = prefs->GetList( |
| 60 prefs::kCloudPrintPrinterBlacklist); | 67 prefs::kCloudPrintPrinterBlacklist); |
| 61 if (printers) { | 68 if (printers) { |
| 62 for (size_t i = 0; i < printers->GetSize(); ++i) { | 69 for (size_t i = 0; i < printers->GetSize(); ++i) { |
| 63 std::string printer; | 70 std::string printer; |
| 64 if (printers->GetString(i, &printer)) | 71 if (printers->GetString(i, &printer)) |
| 65 printer_blacklist_.insert(printer); | 72 printer_blacklist_.insert(printer); |
| 66 } | 73 } |
| 67 } | 74 } |
| 68 } | 75 } |
| 69 | 76 |
| 70 bool ConnectorSettings::IsPrinterBlacklisted(const std::string& name) const { | 77 bool ConnectorSettings::IsPrinterBlacklisted(const std::string& name) const { |
| 71 return printer_blacklist_.find(name) != printer_blacklist_.end(); | 78 return printer_blacklist_.find(name) != printer_blacklist_.end(); |
| 72 }; | 79 }; |
| 73 | 80 |
| 74 void ConnectorSettings::CopyFrom(const ConnectorSettings& source) { | 81 void ConnectorSettings::CopyFrom(const ConnectorSettings& source) { |
| 75 server_url_ = source.server_url(); | 82 server_url_ = source.server_url(); |
| 76 proxy_id_ = source.proxy_id(); | 83 proxy_id_ = source.proxy_id(); |
| 77 delete_on_enum_fail_ = source.delete_on_enum_fail(); | 84 delete_on_enum_fail_ = source.delete_on_enum_fail(); |
|
Vitaly Buka (NO REVIEWS)
2012/10/22 20:52:53
xmpp_ping_enabled_ is not copied
That's why i'd j
gene
2012/10/22 21:44:12
Done.
| |
| 78 connect_new_printers_ = source.connect_new_printers(); | 85 connect_new_printers_ = source.connect_new_printers(); |
| 86 xmpp_ping_timeout_sec_ = source.xmpp_ping_timeout_sec_; | |
| 79 printer_blacklist_ = source.printer_blacklist_; | 87 printer_blacklist_ = source.printer_blacklist_; |
| 80 if (source.print_system_settings()) | 88 if (source.print_system_settings()) |
| 81 print_system_settings_.reset(source.print_system_settings()->DeepCopy()); | 89 print_system_settings_.reset(source.print_system_settings()->DeepCopy()); |
| 82 } | 90 } |
| 83 | 91 |
| OLD | NEW |