| 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 JsonPrefStore; |
| 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 { |
| 24 public: |
| 25 virtual ~Client() {} |
| 26 virtual void OnCloudPrintProxyEnabled() {} |
| 27 virtual void OnCloudPrintProxyDisabled() {} |
| 28 }; |
| 23 CloudPrintProxy(); | 29 CloudPrintProxy(); |
| 24 virtual ~CloudPrintProxy(); | 30 virtual ~CloudPrintProxy(); |
| 25 | 31 |
| 26 // 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 |
| 27 // class is constructed. | 33 // class is constructed. |
| 28 void Initialize(JsonPrefStore* service_prefs); | 34 void Initialize(JsonPrefStore* service_prefs, Client* client); |
| 29 | 35 |
| 30 // Enables/disables cloud printing for the user | 36 // Enables/disables cloud printing for the user |
| 31 virtual void EnableForUser(const std::string& lsid); | 37 virtual void EnableForUser(const std::string& lsid); |
| 32 virtual void DisableForUser(); | 38 virtual void DisableForUser(); |
| 33 | 39 |
| 34 // Notification methods from the backend. Called on UI thread. | 40 // Notification methods from the backend. Called on UI thread. |
| 35 virtual void OnPrinterListAvailable( | 41 virtual void OnPrinterListAvailable( |
| 36 const cloud_print::PrinterList& printer_list); | 42 const cloud_print::PrinterList& printer_list); |
| 37 virtual void OnAuthenticated(const std::string& cloud_print_token, | 43 virtual void OnAuthenticated(const std::string& cloud_print_token, |
| 38 const std::string& cloud_print_xmpp_token, | 44 const std::string& cloud_print_xmpp_token, |
| 39 const std::string& email); | 45 const std::string& email); |
| 40 | 46 |
| 41 protected: | 47 protected: |
| 42 void Shutdown(); | 48 void Shutdown(); |
| 43 | 49 |
| 44 // Our asynchronous backend to communicate with sync components living on | 50 // Our asynchronous backend to communicate with sync components living on |
| 45 // other threads. | 51 // other threads. |
| 46 scoped_ptr<CloudPrintProxyBackend> backend_; | 52 scoped_ptr<CloudPrintProxyBackend> backend_; |
| 47 // This class does not own this. It is guaranteed to remain valid for the | 53 // This class does not own this. It is guaranteed to remain valid for the |
| 48 // lifetime of this class. | 54 // lifetime of this class. |
| 49 JsonPrefStore* service_prefs_; | 55 JsonPrefStore* service_prefs_; |
| 56 // This class does not own this. If non-NULL, It is guaranteed to remain |
| 57 // valid for the lifetime of this class. |
| 58 Client* client_; |
| 50 | 59 |
| 51 DISALLOW_COPY_AND_ASSIGN(CloudPrintProxy); | 60 DISALLOW_COPY_AND_ASSIGN(CloudPrintProxy); |
| 52 }; | 61 }; |
| 53 | 62 |
| 54 #endif // CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_PROXY_H_ | 63 #endif // CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_PROXY_H_ |
| 55 | 64 |
| OLD | NEW |