| 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_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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/thread.h" | 11 #include "base/thread.h" |
| 12 #include "chrome/service/cloud_print/print_system.h" | |
| 13 #include "chrome/common/net/url_fetcher.h" | 12 #include "chrome/common/net/url_fetcher.h" |
| 14 #include "googleurl/src/gurl.h" | 13 #include "googleurl/src/gurl.h" |
| 14 #include "printing/backend/print_backend.h" |
| 15 | 15 |
| 16 class CloudPrintProxyService; | 16 class CloudPrintProxyService; |
| 17 class DictionaryValue; | 17 class DictionaryValue; |
| 18 | 18 |
| 19 // CloudPrintProxyFrontend is the interface used by CloudPrintProxyBackend to | 19 // CloudPrintProxyFrontend is the interface used by CloudPrintProxyBackend to |
| 20 // communicate with the entity that created it and, presumably, is interested in | 20 // communicate with the entity that created it and, presumably, is interested in |
| 21 // cloud print proxy related activity. | 21 // cloud print proxy related activity. |
| 22 // NOTE: All methods will be invoked by a CloudPrintProxyBackend on the same | 22 // NOTE: All methods will be invoked by a CloudPrintProxyBackend on the same |
| 23 // thread used to create that CloudPrintProxyBackend. | 23 // thread used to create that CloudPrintProxyBackend. |
| 24 class CloudPrintProxyFrontend { | 24 class CloudPrintProxyFrontend { |
| 25 public: | 25 public: |
| 26 CloudPrintProxyFrontend() {} | 26 CloudPrintProxyFrontend() {} |
| 27 | 27 |
| 28 // There is a list of printers available that can be registered. | 28 // There is a list of printers available that can be registered. |
| 29 virtual void OnPrinterListAvailable( | 29 virtual void OnPrinterListAvailable( |
| 30 const cloud_print::PrinterList& printer_list) = 0; | 30 const printing::PrinterList& printer_list) = 0; |
| 31 // We successfully authenticated with the cloud print server. This callback | 31 // We successfully authenticated with the cloud print server. This callback |
| 32 // allows the frontend to persist the tokens. | 32 // allows the frontend to persist the tokens. |
| 33 virtual void OnAuthenticated(const std::string& cloud_print_token, | 33 virtual void OnAuthenticated(const std::string& cloud_print_token, |
| 34 const std::string& cloud_print_xmpp_token, | 34 const std::string& cloud_print_xmpp_token, |
| 35 const std::string& email) = 0; | 35 const std::string& email) = 0; |
| 36 // We have invalid/expired credentials. | 36 // We have invalid/expired credentials. |
| 37 virtual void OnAuthenticationFailed() = 0; | 37 virtual void OnAuthenticationFailed() = 0; |
| 38 | 38 |
| 39 protected: | 39 protected: |
| 40 // Don't delete through SyncFrontend interface. | 40 // Don't delete through SyncFrontend interface. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 52 const GURL& cloud_print_server_url, | 52 const GURL& cloud_print_server_url, |
| 53 const DictionaryValue* print_sys_settings); | 53 const DictionaryValue* print_sys_settings); |
| 54 ~CloudPrintProxyBackend(); | 54 ~CloudPrintProxyBackend(); |
| 55 | 55 |
| 56 bool InitializeWithLsid(const std::string& lsid, const std::string& proxy_id); | 56 bool InitializeWithLsid(const std::string& lsid, const std::string& proxy_id); |
| 57 bool InitializeWithToken(const std::string cloud_print_token, | 57 bool InitializeWithToken(const std::string cloud_print_token, |
| 58 const std::string cloud_print_xmpp_token, | 58 const std::string cloud_print_xmpp_token, |
| 59 const std::string email, | 59 const std::string email, |
| 60 const std::string& proxy_id); | 60 const std::string& proxy_id); |
| 61 void Shutdown(); | 61 void Shutdown(); |
| 62 void RegisterPrinters(const cloud_print::PrinterList& printer_list); | 62 void RegisterPrinters(const printing::PrinterList& printer_list); |
| 63 | 63 |
| 64 private: | 64 private: |
| 65 // The real guts of SyncBackendHost, to keep the public client API clean. | 65 // The real guts of SyncBackendHost, to keep the public client API clean. |
| 66 class Core; | 66 class Core; |
| 67 // A thread we dedicate for use to perform initialization and | 67 // A thread we dedicate for use to perform initialization and |
| 68 // authentication. | 68 // authentication. |
| 69 base::Thread core_thread_; | 69 base::Thread core_thread_; |
| 70 // Our core, which communicates with AuthWatcher for GAIA authentication and | 70 // Our core, which communicates with AuthWatcher for GAIA authentication and |
| 71 // which contains printer registration code. | 71 // which contains printer registration code. |
| 72 scoped_refptr<Core> core_; | 72 scoped_refptr<Core> core_; |
| 73 // A reference to the MessageLoop used to construct |this|, so we know how | 73 // A reference to the MessageLoop used to construct |this|, so we know how |
| 74 // to safely talk back to the SyncFrontend. | 74 // to safely talk back to the SyncFrontend. |
| 75 MessageLoop* const frontend_loop_; | 75 MessageLoop* const frontend_loop_; |
| 76 // The frontend which is responsible for displaying UI and updating Prefs | 76 // The frontend which is responsible for displaying UI and updating Prefs |
| 77 CloudPrintProxyFrontend* frontend_; | 77 CloudPrintProxyFrontend* frontend_; |
| 78 | 78 |
| 79 friend class base::RefCountedThreadSafe<CloudPrintProxyBackend::Core>; | 79 friend class base::RefCountedThreadSafe<CloudPrintProxyBackend::Core>; |
| 80 | 80 |
| 81 DISALLOW_COPY_AND_ASSIGN(CloudPrintProxyBackend); | 81 DISALLOW_COPY_AND_ASSIGN(CloudPrintProxyBackend); |
| 82 }; | 82 }; |
| 83 | 83 |
| 84 #endif // CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_PROXY_BACKEND_H_ | 84 #endif // CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_PROXY_BACKEND_H_ |
| 85 | |
| OLD | NEW |