Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Side by Side Diff: chrome/browser/printing/cloud_print/cloud_print_proxy_service.cc

Issue 11037005: New Cloud Print Private API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/browser/printing/cloud_print/cloud_print_proxy_service.h" 5 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h"
6 6
7 #include <stack> 7 #include <stack>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 if (profile_->GetPrefs()->GetBoolean(prefs::kCloudPrintProxyEnabled)) { 111 if (profile_->GetPrefs()->GetBoolean(prefs::kCloudPrintProxyEnabled)) {
112 InvokeServiceTask( 112 InvokeServiceTask(
113 base::Bind(&CloudPrintProxyService::EnableCloudPrintProxy, 113 base::Bind(&CloudPrintProxyService::EnableCloudPrintProxy,
114 weak_factory_.GetWeakPtr(), lsid, email)); 114 weak_factory_.GetWeakPtr(), lsid, email));
115 } 115 }
116 } 116 }
117 117
118 void CloudPrintProxyService::EnableForUserWithRobot( 118 void CloudPrintProxyService::EnableForUserWithRobot(
119 const std::string& robot_auth_code, 119 const std::string& robot_auth_code,
120 const std::string& robot_email, 120 const std::string& robot_email,
121 const std::string& user_email) { 121 const std::string& user_email,
122 bool connect_new_printers,
123 const std::vector<std::string>& printer_blacklist) {
122 if (profile_->GetPrefs()->GetBoolean(prefs::kCloudPrintProxyEnabled)) { 124 if (profile_->GetPrefs()->GetBoolean(prefs::kCloudPrintProxyEnabled)) {
123 InvokeServiceTask( 125 InvokeServiceTask(
124 base::Bind(&CloudPrintProxyService::EnableCloudPrintProxyWithRobot, 126 base::Bind(&CloudPrintProxyService::EnableCloudPrintProxyWithRobot,
125 weak_factory_.GetWeakPtr(), robot_auth_code, robot_email, 127 weak_factory_.GetWeakPtr(), robot_auth_code, robot_email,
126 user_email)); 128 user_email, connect_new_printers, printer_blacklist));
127 } 129 }
128 } 130 }
129 131
130 void CloudPrintProxyService::DisableForUser() { 132 void CloudPrintProxyService::DisableForUser() {
131 InvokeServiceTask( 133 InvokeServiceTask(
132 base::Bind(&CloudPrintProxyService::DisableCloudPrintProxy, 134 base::Bind(&CloudPrintProxyService::DisableCloudPrintProxy,
133 weak_factory_.GetWeakPtr())); 135 weak_factory_.GetWeakPtr()));
134 } 136 }
135 137
136 bool CloudPrintProxyService::ShowTokenExpiredNotification() { 138 bool CloudPrintProxyService::ShowTokenExpiredNotification() {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 ServiceProcessControl* process_control = GetServiceProcessControl(); 231 ServiceProcessControl* process_control = GetServiceProcessControl();
230 DCHECK(process_control->IsConnected()); 232 DCHECK(process_control->IsConnected());
231 process_control->Send(new ServiceMsg_EnableCloudPrintProxy(lsid)); 233 process_control->Send(new ServiceMsg_EnableCloudPrintProxy(lsid));
232 // Assume the IPC worked. 234 // Assume the IPC worked.
233 profile_->GetPrefs()->SetString(prefs::kCloudPrintEmail, email); 235 profile_->GetPrefs()->SetString(prefs::kCloudPrintEmail, email);
234 } 236 }
235 237
236 void CloudPrintProxyService::EnableCloudPrintProxyWithRobot( 238 void CloudPrintProxyService::EnableCloudPrintProxyWithRobot(
237 const std::string& robot_auth_code, 239 const std::string& robot_auth_code,
238 const std::string& robot_email, 240 const std::string& robot_email,
239 const std::string& user_email) { 241 const std::string& user_email,
242 bool connect_new_printers,
243 const std::vector<std::string>& printer_blacklist) {
240 ServiceProcessControl* process_control = GetServiceProcessControl(); 244 ServiceProcessControl* process_control = GetServiceProcessControl();
241 DCHECK(process_control->IsConnected()); 245 DCHECK(process_control->IsConnected());
242 process_control->Send(new ServiceMsg_EnableCloudPrintProxyWithRobot( 246 process_control->Send(
243 robot_auth_code, 247 new ServiceMsg_EnableCloudPrintProxyWithRobot(
244 robot_email, 248 robot_auth_code, robot_email, user_email, connect_new_printers,
245 user_email)); 249 printer_blacklist));
246 // Assume the IPC worked. 250 // Assume the IPC worked.
247 profile_->GetPrefs()->SetString(prefs::kCloudPrintEmail, user_email); 251 profile_->GetPrefs()->SetString(prefs::kCloudPrintEmail, user_email);
248 } 252 }
249 253
250 void CloudPrintProxyService::DisableCloudPrintProxy() { 254 void CloudPrintProxyService::DisableCloudPrintProxy() {
251 ServiceProcessControl* process_control = GetServiceProcessControl(); 255 ServiceProcessControl* process_control = GetServiceProcessControl();
252 DCHECK(process_control->IsConnected()); 256 DCHECK(process_control->IsConnected());
253 process_control->Send(new ServiceMsg_DisableCloudPrintProxy); 257 process_control->Send(new ServiceMsg_DisableCloudPrintProxy);
254 // Assume the IPC worked. 258 // Assume the IPC worked.
255 profile_->GetPrefs()->SetString(prefs::kCloudPrintEmail, std::string()); 259 profile_->GetPrefs()->SetString(prefs::kCloudPrintEmail, std::string());
256 } 260 }
257 261
258 void CloudPrintProxyService::ProxyInfoCallback( 262 void CloudPrintProxyService::ProxyInfoCallback(
259 const cloud_print::CloudPrintProxyInfo& proxy_info) { 263 const cloud_print::CloudPrintProxyInfo& proxy_info) {
260 proxy_id_ = proxy_info.proxy_id; 264 proxy_id_ = proxy_info.proxy_id;
261 profile_->GetPrefs()->SetString( 265 profile_->GetPrefs()->SetString(
262 prefs::kCloudPrintEmail, 266 prefs::kCloudPrintEmail,
263 proxy_info.enabled ? proxy_info.email : std::string()); 267 proxy_info.enabled ? proxy_info.email : std::string());
264 ApplyCloudPrintConnectorPolicy(); 268 ApplyCloudPrintConnectorPolicy();
265 } 269 }
266 270
267 bool CloudPrintProxyService::InvokeServiceTask(const base::Closure& task) { 271 bool CloudPrintProxyService::InvokeServiceTask(const base::Closure& task) {
268 GetServiceProcessControl()->Launch(task, base::Closure()); 272 GetServiceProcessControl()->Launch(task, base::Closure());
269 return true; 273 return true;
270 } 274 }
271 275
272 ServiceProcessControl* CloudPrintProxyService::GetServiceProcessControl() { 276 ServiceProcessControl* CloudPrintProxyService::GetServiceProcessControl() {
273 return ServiceProcessControl::GetInstance(); 277 return ServiceProcessControl::GetInstance();
274 } 278 }
OLDNEW
« no previous file with comments | « chrome/browser/printing/cloud_print/cloud_print_proxy_service.h ('k') | chrome/common/extensions/api/api.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698