| 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" |
| 11 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "chrome/common/chrome_switches.h" | 12 #include "chrome/common/chrome_switches.h" |
| 13 #include "chrome/common/cloud_print/cloud_print_constants.h" |
| 13 #include "chrome/common/cloud_print/cloud_print_proxy_info.h" | 14 #include "chrome/common/cloud_print/cloud_print_proxy_info.h" |
| 14 #include "chrome/common/pref_names.h" | 15 #include "chrome/common/pref_names.h" |
| 15 #include "chrome/service/cloud_print/cloud_print_consts.h" | |
| 16 #include "chrome/service/cloud_print/print_system.h" | 16 #include "chrome/service/cloud_print/print_system.h" |
| 17 #include "chrome/service/service_process.h" | 17 #include "chrome/service/service_process.h" |
| 18 #include "chrome/service/service_process_prefs.h" | 18 #include "chrome/service/service_process_prefs.h" |
| 19 #include "google_apis/gaia/gaia_oauth_client.h" | 19 #include "google_apis/gaia/gaia_oauth_client.h" |
| 20 #include "google_apis/google_api_keys.h" | 20 #include "google_apis/google_api_keys.h" |
| 21 #include "googleurl/src/gurl.h" | 21 #include "googleurl/src/gurl.h" |
| 22 | 22 |
| 23 namespace { | 23 namespace { |
| 24 | 24 |
| 25 void LaunchBrowserProcessWithSwitch(const std::string& switch_string) { | 25 void LaunchBrowserProcessWithSwitch(const std::string& switch_string) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 void ShowTokenExpiredNotificationInBrowser() { | 58 void ShowTokenExpiredNotificationInBrowser() { |
| 59 LaunchBrowserProcessWithSwitch(switches::kNotifyCloudPrintTokenExpired); | 59 LaunchBrowserProcessWithSwitch(switches::kNotifyCloudPrintTokenExpired); |
| 60 } | 60 } |
| 61 | 61 |
| 62 void CheckCloudPrintProxyPolicyInBrowser() { | 62 void CheckCloudPrintProxyPolicyInBrowser() { |
| 63 LaunchBrowserProcessWithSwitch(switches::kCheckCloudPrintConnectorPolicy); | 63 LaunchBrowserProcessWithSwitch(switches::kCheckCloudPrintConnectorPolicy); |
| 64 } | 64 } |
| 65 | 65 |
| 66 } // namespace | 66 } // namespace |
| 67 | 67 |
| 68 namespace cloud_print { |
| 69 |
| 68 CloudPrintProxy::CloudPrintProxy() | 70 CloudPrintProxy::CloudPrintProxy() |
| 69 : service_prefs_(NULL), | 71 : service_prefs_(NULL), |
| 70 client_(NULL), | 72 client_(NULL), |
| 71 enabled_(false) { | 73 enabled_(false) { |
| 72 } | 74 } |
| 73 | 75 |
| 74 CloudPrintProxy::~CloudPrintProxy() { | 76 CloudPrintProxy::~CloudPrintProxy() { |
| 75 DCHECK(CalledOnValidThread()); | 77 DCHECK(CalledOnValidThread()); |
| 76 ShutdownBackend(); | 78 ShutdownBackend(); |
| 77 } | 79 } |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 void CloudPrintProxy::DisableForUser() { | 195 void CloudPrintProxy::DisableForUser() { |
| 194 DCHECK(CalledOnValidThread()); | 196 DCHECK(CalledOnValidThread()); |
| 195 user_email_.clear(); | 197 user_email_.clear(); |
| 196 enabled_ = false; | 198 enabled_ = false; |
| 197 if (client_) { | 199 if (client_) { |
| 198 client_->OnCloudPrintProxyDisabled(true); | 200 client_->OnCloudPrintProxyDisabled(true); |
| 199 } | 201 } |
| 200 ShutdownBackend(); | 202 ShutdownBackend(); |
| 201 } | 203 } |
| 202 | 204 |
| 203 void CloudPrintProxy::GetProxyInfo(cloud_print::CloudPrintProxyInfo* info) { | 205 void CloudPrintProxy::GetProxyInfo(CloudPrintProxyInfo* info) { |
| 204 info->enabled = enabled_; | 206 info->enabled = enabled_; |
| 205 info->email.clear(); | 207 info->email.clear(); |
| 206 if (enabled_) | 208 if (enabled_) |
| 207 info->email = user_email(); | 209 info->email = user_email(); |
| 208 info->proxy_id = settings_.proxy_id(); | 210 info->proxy_id = settings_.proxy_id(); |
| 209 // If the Cloud Print service is not enabled, we may need to read the old | 211 // If the Cloud Print service is not enabled, we may need to read the old |
| 210 // value of proxy_id from prefs. | 212 // value of proxy_id from prefs. |
| 211 if (info->proxy_id.empty()) | 213 if (info->proxy_id.empty()) |
| 212 info->proxy_id = service_prefs_->GetString(prefs::kCloudPrintProxyId, ""); | 214 info->proxy_id = service_prefs_->GetString(prefs::kCloudPrintProxyId, ""); |
| 213 } | 215 } |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 // Finish disabling cloud print for this user. | 278 // Finish disabling cloud print for this user. |
| 277 DisableForUser(); | 279 DisableForUser(); |
| 278 } | 280 } |
| 279 | 281 |
| 280 void CloudPrintProxy::ShutdownBackend() { | 282 void CloudPrintProxy::ShutdownBackend() { |
| 281 DCHECK(CalledOnValidThread()); | 283 DCHECK(CalledOnValidThread()); |
| 282 if (backend_.get()) | 284 if (backend_.get()) |
| 283 backend_->Shutdown(); | 285 backend_->Shutdown(); |
| 284 backend_.reset(); | 286 backend_.reset(); |
| 285 } | 287 } |
| 288 |
| 289 } // namespace cloud_print |
| OLD | NEW |