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/cloud_print_proxy.h" | 5 #include "chrome/service/cloud_print/cloud_print_proxy.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/process_util.h" | 10 #include "base/process_util.h" |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 } | 111 } |
112 if (client_) { | 112 if (client_) { |
113 client_->OnCloudPrintProxyEnabled(true); | 113 client_->OnCloudPrintProxyEnabled(true); |
114 } | 114 } |
115 } | 115 } |
116 | 116 |
117 void CloudPrintProxy::EnableForUserWithRobot( | 117 void CloudPrintProxy::EnableForUserWithRobot( |
118 const std::string& robot_auth_code, | 118 const std::string& robot_auth_code, |
119 const std::string& robot_email, | 119 const std::string& robot_email, |
120 const std::string& user_email, | 120 const std::string& user_email, |
121 bool connect_new_printers, | 121 const base::DictionaryValue& user_settings) { |
122 const std::vector<std::string>& printer_blacklist) { | |
123 DCHECK(CalledOnValidThread()); | 122 DCHECK(CalledOnValidThread()); |
124 | 123 |
125 ShutdownBackend(); | 124 ShutdownBackend(); |
126 std::string proxy_id( | 125 std::string proxy_id( |
127 service_prefs_->GetString(prefs::kCloudPrintProxyId, std::string())); | 126 service_prefs_->GetString(prefs::kCloudPrintProxyId, std::string())); |
128 service_prefs_->RemovePref(prefs::kCloudPrintRoot); | 127 service_prefs_->RemovePref(prefs::kCloudPrintRoot); |
129 if (!proxy_id.empty()) { | 128 if (!proxy_id.empty()) { |
130 // Keep only proxy id; | 129 // Keep only proxy id; |
131 service_prefs_->SetString(prefs::kCloudPrintProxyId, proxy_id); | 130 service_prefs_->SetString(prefs::kCloudPrintProxyId, proxy_id); |
132 } | 131 } |
133 service_prefs_->SetBoolean(prefs::kCloudPrintConnectNewPrinters, | 132 service_prefs_->SetValue(prefs::kCloudPrintUserSettings, |
134 connect_new_printers); | 133 user_settings.DeepCopy()); |
135 if (!printer_blacklist.empty()) { | |
136 scoped_ptr<base::ListValue> printers(new base::ListValue()); | |
137 printers->AppendStrings(printer_blacklist); | |
138 service_prefs_->SetValue(prefs::kCloudPrintPrinterBlacklist, | |
139 printers.release()); | |
140 } | |
141 service_prefs_->WritePrefs(); | 134 service_prefs_->WritePrefs(); |
142 | 135 |
143 if (!CreateBackend()) | 136 if (!CreateBackend()) |
144 return; | 137 return; |
145 DCHECK(backend_.get()); | 138 DCHECK(backend_.get()); |
146 user_email_ = user_email; | 139 user_email_ = user_email; |
147 backend_->InitializeWithRobotAuthCode(robot_auth_code, robot_email); | 140 backend_->InitializeWithRobotAuthCode(robot_auth_code, robot_email); |
148 if (client_) { | 141 if (client_) { |
149 client_->OnCloudPrintProxyEnabled(true); | 142 client_->OnCloudPrintProxyEnabled(true); |
150 } | 143 } |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 } | 267 } |
275 | 268 |
276 void CloudPrintProxy::ShutdownBackend() { | 269 void CloudPrintProxy::ShutdownBackend() { |
277 DCHECK(CalledOnValidThread()); | 270 DCHECK(CalledOnValidThread()); |
278 if (backend_.get()) | 271 if (backend_.get()) |
279 backend_->Shutdown(); | 272 backend_->Shutdown(); |
280 backend_.reset(); | 273 backend_.reset(); |
281 } | 274 } |
282 | 275 |
283 } // namespace cloud_print | 276 } // namespace cloud_print |
OLD | NEW |