| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #ifndef CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_PROXY_H_ | 5 #ifndef CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_PROXY_H_ |
| 6 #define CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_PROXY_H_ | 6 #define CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_PROXY_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/non_thread_safe.h" | 12 #include "base/non_thread_safe.h" |
| 13 #include "base/scoped_ptr.h" | 13 #include "base/scoped_ptr.h" |
| 14 #include "chrome/service/cloud_print/cloud_print_proxy_backend.h" | 14 #include "chrome/service/cloud_print/cloud_print_proxy_backend.h" |
| 15 | 15 |
| 16 class JsonPrefStore; | 16 class ServiceProcessPrefs; |
| 17 | 17 |
| 18 // CloudPrintProxy is the layer between the service process UI thread | 18 // CloudPrintProxy is the layer between the service process UI thread |
| 19 // and the cloud print proxy backend. | 19 // and the cloud print proxy backend. |
| 20 class CloudPrintProxy : public CloudPrintProxyFrontend, | 20 class CloudPrintProxy : public CloudPrintProxyFrontend, |
| 21 public NonThreadSafe { | 21 public NonThreadSafe { |
| 22 public: | 22 public: |
| 23 class Client { | 23 class Client { |
| 24 public: | 24 public: |
| 25 virtual ~Client() {} | 25 virtual ~Client() {} |
| 26 virtual void OnCloudPrintProxyEnabled() {} | 26 virtual void OnCloudPrintProxyEnabled() {} |
| 27 virtual void OnCloudPrintProxyDisabled() {} | 27 virtual void OnCloudPrintProxyDisabled() {} |
| 28 }; | 28 }; |
| 29 CloudPrintProxy(); | 29 CloudPrintProxy(); |
| 30 virtual ~CloudPrintProxy(); | 30 virtual ~CloudPrintProxy(); |
| 31 | 31 |
| 32 // Initializes the object. This should be called every time an object of this | 32 // Initializes the object. This should be called every time an object of this |
| 33 // class is constructed. | 33 // class is constructed. |
| 34 void Initialize(JsonPrefStore* service_prefs, Client* client); | 34 void Initialize(ServiceProcessPrefs* service_prefs, Client* client); |
| 35 | 35 |
| 36 // Enables/disables cloud printing for the user | 36 // Enables/disables cloud printing for the user |
| 37 void EnableForUser(const std::string& lsid); | 37 void EnableForUser(const std::string& lsid); |
| 38 void DisableForUser(); | 38 void DisableForUser(); |
| 39 // Returns the enabled stata of the proxy. If enabled, the email address used | 39 // Returns the enabled stata of the proxy. If enabled, the email address used |
| 40 // for authentication is also returned in the optional |email| argument. | 40 // for authentication is also returned in the optional |email| argument. |
| 41 bool IsEnabled(std::string* email) const; | 41 bool IsEnabled(std::string* email) const; |
| 42 | 42 |
| 43 const std::string& cloud_print_email() const { | 43 const std::string& cloud_print_email() const { |
| 44 return cloud_print_email_; | 44 return cloud_print_email_; |
| 45 } | 45 } |
| 46 | 46 |
| 47 // Notification methods from the backend. Called on UI thread. | 47 // Notification methods from the backend. Called on UI thread. |
| 48 virtual void OnPrinterListAvailable( | 48 virtual void OnPrinterListAvailable( |
| 49 const printing::PrinterList& printer_list); | 49 const printing::PrinterList& printer_list); |
| 50 virtual void OnAuthenticated(const std::string& cloud_print_token, | 50 virtual void OnAuthenticated(const std::string& cloud_print_token, |
| 51 const std::string& cloud_print_xmpp_token, | 51 const std::string& cloud_print_xmpp_token, |
| 52 const std::string& email); | 52 const std::string& email); |
| 53 virtual void OnAuthenticationFailed(); | 53 virtual void OnAuthenticationFailed(); |
| 54 | 54 |
| 55 protected: | 55 protected: |
| 56 void Shutdown(); | 56 void Shutdown(); |
| 57 | 57 |
| 58 // Our asynchronous backend to communicate with sync components living on | 58 // Our asynchronous backend to communicate with sync components living on |
| 59 // other threads. | 59 // other threads. |
| 60 scoped_ptr<CloudPrintProxyBackend> backend_; | 60 scoped_ptr<CloudPrintProxyBackend> backend_; |
| 61 // This class does not own this. It is guaranteed to remain valid for the | 61 // This class does not own this. It is guaranteed to remain valid for the |
| 62 // lifetime of this class. | 62 // lifetime of this class. |
| 63 JsonPrefStore* service_prefs_; | 63 ServiceProcessPrefs* service_prefs_; |
| 64 // This class does not own this. If non-NULL, It is guaranteed to remain | 64 // This class does not own this. If non-NULL, It is guaranteed to remain |
| 65 // valid for the lifetime of this class. | 65 // valid for the lifetime of this class. |
| 66 Client* client_; | 66 Client* client_; |
| 67 // The email address of the account used to authenticate to the Cloud Print | 67 // The email address of the account used to authenticate to the Cloud Print |
| 68 // service. | 68 // service. |
| 69 std::string cloud_print_email_; | 69 std::string cloud_print_email_; |
| 70 | 70 |
| 71 DISALLOW_COPY_AND_ASSIGN(CloudPrintProxy); | 71 DISALLOW_COPY_AND_ASSIGN(CloudPrintProxy); |
| 72 }; | 72 }; |
| 73 | 73 |
| 74 #endif // CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_PROXY_H_ | 74 #endif // CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_PROXY_H_ |
| OLD | NEW |