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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 } | 115 } |
116 } | 116 } |
117 if (client_) { | 117 if (client_) { |
118 client_->OnCloudPrintProxyEnabled(true); | 118 client_->OnCloudPrintProxyEnabled(true); |
119 } | 119 } |
120 } | 120 } |
121 | 121 |
122 void CloudPrintProxy::EnableForUserWithRobot( | 122 void CloudPrintProxy::EnableForUserWithRobot( |
123 const std::string& robot_auth_code, | 123 const std::string& robot_auth_code, |
124 const std::string& robot_email, | 124 const std::string& robot_email, |
125 const std::string& user_email) { | 125 const std::string& user_email, |
| 126 bool connect_new_printers, |
| 127 const std::vector<std::string>& printer_blacklist) { |
126 DCHECK(CalledOnValidThread()); | 128 DCHECK(CalledOnValidThread()); |
| 129 |
| 130 ShutdownBackend(); |
| 131 std::string proxy_id( |
| 132 service_prefs_->GetString(prefs::kCloudPrintProxyId, "")); |
| 133 service_prefs_->RemovePref(prefs::kCloudPrintRoot); |
| 134 if (!proxy_id.empty()) { |
| 135 // Keep only proxy id; |
| 136 service_prefs_->SetString(prefs::kCloudPrintProxyId, proxy_id); |
| 137 } |
| 138 service_prefs_->SetBoolean(prefs::kCloudPrintConnectNewPrinters, |
| 139 connect_new_printers); |
| 140 if (!printer_blacklist.empty()) { |
| 141 scoped_ptr<base::ListValue> printers(new base::ListValue()); |
| 142 printers->AppendStrings(printer_blacklist); |
| 143 service_prefs_->SetValue(prefs::kCloudPrintConnectNewPrinters, |
| 144 printers.release()); |
| 145 } |
| 146 service_prefs_->WritePrefs(); |
| 147 |
127 if (!CreateBackend()) | 148 if (!CreateBackend()) |
128 return; | 149 return; |
129 DCHECK(backend_.get()); | 150 DCHECK(backend_.get()); |
130 user_email_ = user_email; | 151 user_email_ = user_email; |
131 backend_->InitializeWithRobotAuthCode(robot_auth_code, robot_email); | 152 backend_->InitializeWithRobotAuthCode(robot_auth_code, robot_email); |
132 if (client_) { | 153 if (client_) { |
133 client_->OnCloudPrintProxyEnabled(true); | 154 client_->OnCloudPrintProxyEnabled(true); |
134 } | 155 } |
135 } | 156 } |
136 | 157 |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 // Finish disabling cloud print for this user. | 276 // Finish disabling cloud print for this user. |
256 DisableForUser(); | 277 DisableForUser(); |
257 } | 278 } |
258 | 279 |
259 void CloudPrintProxy::ShutdownBackend() { | 280 void CloudPrintProxy::ShutdownBackend() { |
260 DCHECK(CalledOnValidThread()); | 281 DCHECK(CalledOnValidThread()); |
261 if (backend_.get()) | 282 if (backend_.get()) |
262 backend_->Shutdown(); | 283 backend_->Shutdown(); |
263 backend_.reset(); | 284 backend_.reset(); |
264 } | 285 } |
OLD | NEW |