| 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 #ifndef CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_PROXY_BACKEND_H_ | 5 #ifndef CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_PROXY_BACKEND_H_ |
| 6 #define CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_PROXY_BACKEND_H_ | 6 #define CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_PROXY_BACKEND_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/threading/thread.h" | 11 #include "base/threading/thread.h" |
| 12 #include "chrome/service/cloud_print/connector_settings.h" |
| 12 #include "printing/backend/print_backend.h" | 13 #include "printing/backend/print_backend.h" |
| 13 | 14 |
| 14 class GURL; | |
| 15 | |
| 16 namespace base { | 15 namespace base { |
| 17 class DictionaryValue; | 16 class DictionaryValue; |
| 18 } | 17 } |
| 19 | 18 |
| 20 namespace gaia { | 19 namespace gaia { |
| 21 struct OAuthClientInfo; | 20 struct OAuthClientInfo; |
| 22 } | 21 } |
| 23 | 22 |
| 24 // CloudPrintProxyFrontend is the interface used by CloudPrintProxyBackend to | 23 // CloudPrintProxyFrontend is the interface used by CloudPrintProxyBackend to |
| 25 // communicate with the entity that created it and, presumably, is interested in | 24 // communicate with the entity that created it and, presumably, is interested in |
| (...skipping 23 matching lines...) Expand all Loading... |
| 49 virtual ~CloudPrintProxyFrontend() { | 48 virtual ~CloudPrintProxyFrontend() { |
| 50 } | 49 } |
| 51 private: | 50 private: |
| 52 DISALLOW_COPY_AND_ASSIGN(CloudPrintProxyFrontend); | 51 DISALLOW_COPY_AND_ASSIGN(CloudPrintProxyFrontend); |
| 53 }; | 52 }; |
| 54 | 53 |
| 55 class CloudPrintProxyBackend { | 54 class CloudPrintProxyBackend { |
| 56 public: | 55 public: |
| 57 // It is OK for print_system_settings to be NULL. In this case system should | 56 // It is OK for print_system_settings to be NULL. In this case system should |
| 58 // use system default settings. | 57 // use system default settings. |
| 59 CloudPrintProxyBackend( | 58 CloudPrintProxyBackend(CloudPrintProxyFrontend* frontend, |
| 60 CloudPrintProxyFrontend* frontend, | 59 const ConnectorSettings& settings, |
| 61 const std::string& proxy_id, | 60 const gaia::OAuthClientInfo& oauth_client_info, |
| 62 const GURL& cloud_print_server_url, | 61 bool enable_job_poll); |
| 63 const base::DictionaryValue* print_sys_settings, | |
| 64 const gaia::OAuthClientInfo& oauth_client_info, | |
| 65 bool enable_job_poll); | |
| 66 ~CloudPrintProxyBackend(); | 62 ~CloudPrintProxyBackend(); |
| 67 | 63 |
| 68 // Called when the user enables Google Cloud Print. | 64 // Called when the user enables Google Cloud Print. |
| 69 // |last_robot_refresh_token|, |last_robot_email| and |last_user_email| are | 65 // |last_robot_refresh_token|, |last_robot_email| and |last_user_email| are |
| 70 // the previously persisted credentials if any. We will use this is the passed | 66 // the previously persisted credentials if any. We will use this is the passed |
| 71 // in LSID belongs to the same user as |last_user_email|. | 67 // in LSID belongs to the same user as |last_user_email|. |
| 72 bool InitializeWithLsid(const std::string& lsid, | 68 bool InitializeWithLsid(const std::string& lsid, |
| 73 const std::string& proxy_id, | |
| 74 const std::string& last_robot_refresh_token, | 69 const std::string& last_robot_refresh_token, |
| 75 const std::string& last_robot_email, | 70 const std::string& last_robot_email, |
| 76 const std::string& last_user_email); | 71 const std::string& last_user_email); |
| 77 // Legacy mechanism when we have saved user credentials but no saved robot | 72 // Legacy mechanism when we have saved user credentials but no saved robot |
| 78 // credentials. | 73 // credentials. |
| 79 bool InitializeWithToken(const std::string& cloud_print_token, | 74 bool InitializeWithToken(const std::string& cloud_print_token); |
| 80 const std::string& proxy_id); | |
| 81 // Called when we have saved robot credentials. | 75 // Called when we have saved robot credentials. |
| 82 bool InitializeWithRobotToken(const std::string& robot_oauth_refresh_token, | 76 bool InitializeWithRobotToken(const std::string& robot_oauth_refresh_token, |
| 83 const std::string& robot_email, | 77 const std::string& robot_email); |
| 84 const std::string& proxy_id); | |
| 85 // Called when an external entity passed in the auth code for the robot. | 78 // Called when an external entity passed in the auth code for the robot. |
| 86 bool InitializeWithRobotAuthCode(const std::string& robot_oauth_auth_code, | 79 bool InitializeWithRobotAuthCode(const std::string& robot_oauth_auth_code, |
| 87 const std::string& robot_email, | 80 const std::string& robot_email); |
| 88 const std::string& proxy_id); | |
| 89 void Shutdown(); | 81 void Shutdown(); |
| 90 void RegisterPrinters(const printing::PrinterList& printer_list); | 82 void RegisterPrinters(const printing::PrinterList& printer_list); |
| 91 void UnregisterPrinters(); | 83 void UnregisterPrinters(); |
| 92 | 84 |
| 93 private: | 85 private: |
| 94 // The real guts of SyncBackendHost, to keep the public client API clean. | 86 // The real guts of SyncBackendHost, to keep the public client API clean. |
| 95 class Core; | 87 class Core; |
| 96 // A thread we dedicate for use to perform initialization and | 88 // A thread we dedicate for use to perform initialization and |
| 97 // authentication. | 89 // authentication. |
| 98 base::Thread core_thread_; | 90 base::Thread core_thread_; |
| 99 // Our core, which communicates with AuthWatcher for GAIA authentication and | 91 // Our core, which communicates with AuthWatcher for GAIA authentication and |
| 100 // which contains printer registration code. | 92 // which contains printer registration code. |
| 101 scoped_refptr<Core> core_; | 93 scoped_refptr<Core> core_; |
| 102 // A reference to the MessageLoop used to construct |this|, so we know how | 94 // A reference to the MessageLoop used to construct |this|, so we know how |
| 103 // to safely talk back to the SyncFrontend. | 95 // to safely talk back to the SyncFrontend. |
| 104 MessageLoop* const frontend_loop_; | 96 MessageLoop* const frontend_loop_; |
| 105 // The frontend which is responsible for displaying UI and updating Prefs | 97 // The frontend which is responsible for displaying UI and updating Prefs |
| 106 CloudPrintProxyFrontend* frontend_; | 98 CloudPrintProxyFrontend* frontend_; |
| 107 | 99 |
| 108 friend class base::RefCountedThreadSafe<CloudPrintProxyBackend::Core>; | 100 friend class base::RefCountedThreadSafe<CloudPrintProxyBackend::Core>; |
| 109 | 101 |
| 110 DISALLOW_COPY_AND_ASSIGN(CloudPrintProxyBackend); | 102 DISALLOW_COPY_AND_ASSIGN(CloudPrintProxyBackend); |
| 111 }; | 103 }; |
| 112 | 104 |
| 113 #endif // CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_PROXY_BACKEND_H_ | 105 #endif // CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_PROXY_BACKEND_H_ |
| OLD | NEW |