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() |
21 : delete_on_enum_fail_(false) { | 21 : delete_on_enum_fail_(false), |
| 22 connect_new_printers_(true) { |
22 } | 23 } |
23 | 24 |
24 ConnectorSettings::~ConnectorSettings() { | 25 ConnectorSettings::~ConnectorSettings() { |
25 } | 26 } |
26 | 27 |
27 void ConnectorSettings::InitFrom(ServiceProcessPrefs* prefs) { | 28 void ConnectorSettings::InitFrom(ServiceProcessPrefs* prefs) { |
28 CopyFrom(ConnectorSettings()); | 29 CopyFrom(ConnectorSettings()); |
29 | 30 |
30 proxy_id_ = prefs->GetString(prefs::kCloudPrintProxyId, ""); | 31 proxy_id_ = prefs->GetString(prefs::kCloudPrintProxyId, ""); |
31 if (proxy_id_.empty()) { | 32 if (proxy_id_.empty()) { |
(...skipping 13 matching lines...) Expand all Loading... |
45 &delete_on_enum_fail_); | 46 &delete_on_enum_fail_); |
46 } | 47 } |
47 | 48 |
48 // Check if there is an override for the cloud print server URL. | 49 // Check if there is an override for the cloud print server URL. |
49 server_url_ = GURL(prefs->GetString(prefs::kCloudPrintServiceURL, "")); | 50 server_url_ = GURL(prefs->GetString(prefs::kCloudPrintServiceURL, "")); |
50 DCHECK(server_url_.is_empty() || server_url_.is_valid()); | 51 DCHECK(server_url_.is_empty() || server_url_.is_valid()); |
51 if (server_url_.is_empty() || !server_url_.is_valid()) { | 52 if (server_url_.is_empty() || !server_url_.is_valid()) { |
52 server_url_ = GURL(kDefaultCloudPrintServerUrl); | 53 server_url_ = GURL(kDefaultCloudPrintServerUrl); |
53 } | 54 } |
54 DCHECK(server_url_.is_valid()); | 55 DCHECK(server_url_.is_valid()); |
| 56 |
| 57 connect_new_printers_ = prefs->GetBoolean( |
| 58 prefs::kCloudPrintConnectNewPrinters, true); |
| 59 const base::ListValue* printers = prefs->GetList( |
| 60 prefs::kCloudPrintPrinterBlacklist); |
| 61 if (printers) { |
| 62 for (size_t i = 0; i < printers->GetSize(); ++i) { |
| 63 std::string printer; |
| 64 if (printers->GetString(i, &printer)) |
| 65 printer_blacklist_.insert(printer); |
| 66 } |
| 67 } |
55 } | 68 } |
56 | 69 |
| 70 bool ConnectorSettings::IsPrinterBlacklisted(const std::string& name) const { |
| 71 return printer_blacklist_.find(name) != printer_blacklist_.end(); |
| 72 }; |
| 73 |
57 void ConnectorSettings::CopyFrom(const ConnectorSettings& source) { | 74 void ConnectorSettings::CopyFrom(const ConnectorSettings& source) { |
58 server_url_ = source.server_url(); | 75 server_url_ = source.server_url(); |
59 proxy_id_ = source.proxy_id(); | 76 proxy_id_ = source.proxy_id(); |
60 delete_on_enum_fail_ = source.delete_on_enum_fail(); | 77 delete_on_enum_fail_ = source.delete_on_enum_fail(); |
| 78 connect_new_printers_ = source.connect_new_printers(); |
| 79 printer_blacklist_ = source.printer_blacklist_; |
61 if (source.print_system_settings()) | 80 if (source.print_system_settings()) |
62 print_system_settings_.reset(source.print_system_settings()->DeepCopy()); | 81 print_system_settings_.reset(source.print_system_settings()->DeepCopy()); |
63 } | 82 } |
64 | 83 |
OLD | NEW |