| 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_BROWSER_PRINTING_CLOUD_PRINT_CLOUD_PRINT_PROXY_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_PRINTING_CLOUD_PRINT_CLOUD_PRINT_PROXY_SERVICE_H_ |
| 6 #define CHROME_BROWSER_PRINTING_CLOUD_PRINT_CLOUD_PRINT_PROXY_SERVICE_H_ | 6 #define CHROME_BROWSER_PRINTING_CLOUD_PRINT_CLOUD_PRINT_PROXY_SERVICE_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/observer_list.h" | 12 #include "base/observer_list.h" |
| 13 #include "base/ref_counted.h" | 13 #include "base/ref_counted.h" |
| 14 #include "chrome/browser/printing/cloud_print/cloud_print_setup_flow.h" | 14 #include "chrome/browser/printing/cloud_print/cloud_print_setup_handler.h" |
| 15 | 15 |
| 16 class Profile; | 16 class Profile; |
| 17 | 17 |
| 18 // Layer between the browser user interface and the cloud print proxy code | 18 // Layer between the browser user interface and the cloud print proxy code |
| 19 // running in the service process. | 19 // running in the service process. |
| 20 class CloudPrintProxyService | 20 class CloudPrintProxyService |
| 21 : public CloudPrintSetupFlow::Delegate, | 21 : public CloudPrintSetupHandler::Delegate, |
| 22 public base::RefCountedThreadSafe<CloudPrintProxyService> { | 22 public base::RefCountedThreadSafe<CloudPrintProxyService> { |
| 23 public: | 23 public: |
| 24 explicit CloudPrintProxyService(Profile* profile); | 24 explicit CloudPrintProxyService(Profile* profile); |
| 25 virtual ~CloudPrintProxyService(); | 25 virtual ~CloudPrintProxyService(); |
| 26 | 26 |
| 27 // Initializes the object. This should be called every time an object of this | 27 // Initializes the object. This should be called every time an object of this |
| 28 // class is constructed. | 28 // class is constructed. |
| 29 void Initialize(); | 29 void Initialize(); |
| 30 | 30 |
| 31 // Enables/disables cloud printing for the user | 31 // Enables/disables cloud printing for the user |
| 32 virtual void EnableForUser(const std::string& lsid, const std::string& email); | 32 virtual void EnableForUser(const std::string& lsid, const std::string& email); |
| 33 virtual void DisableForUser(); | 33 virtual void DisableForUser(); |
| 34 | 34 |
| 35 // Query the service process for the status of the cloud print proxy and | 35 // Query the service process for the status of the cloud print proxy and |
| 36 // update the browser prefs. | 36 // update the browser prefs. |
| 37 void RefreshStatusFromService(); | 37 void RefreshStatusFromService(); |
| 38 | 38 |
| 39 bool ShowTokenExpiredNotification(); | 39 bool ShowTokenExpiredNotification(); |
| 40 | 40 |
| 41 // CloudPrintSetupFlow::Delegate implementation. | 41 // CloudPrintSetupHandler::Delegate implementation. |
| 42 virtual void OnDialogClosed(); | 42 virtual void OnCloudPrintSetupClosed(); |
| 43 | 43 |
| 44 private: | 44 private: |
| 45 // NotificationDelegate implementation for the token expired notification. | 45 // NotificationDelegate implementation for the token expired notification. |
| 46 class TokenExpiredNotificationDelegate; | 46 class TokenExpiredNotificationDelegate; |
| 47 friend class TokenExpiredNotificationDelegate; | 47 friend class TokenExpiredNotificationDelegate; |
| 48 | 48 |
| 49 Profile* profile_; | 49 Profile* profile_; |
| 50 scoped_refptr<TokenExpiredNotificationDelegate> token_expired_delegate_; | 50 scoped_refptr<TokenExpiredNotificationDelegate> token_expired_delegate_; |
| 51 scoped_ptr<CloudPrintSetupHandler> cloud_print_setup_handler_; |
| 51 | 52 |
| 52 // Methods that send an IPC to the service. | 53 // Methods that send an IPC to the service. |
| 53 void RefreshCloudPrintProxyStatus(); | 54 void RefreshCloudPrintProxyStatus(); |
| 54 void EnableCloudPrintProxy(const std::string& lsid, const std::string& email); | 55 void EnableCloudPrintProxy(const std::string& lsid, const std::string& email); |
| 55 void DisableCloudPrintProxy(); | 56 void DisableCloudPrintProxy(); |
| 56 | 57 |
| 57 // Callback that gets the cloud print proxy status. | 58 // Callback that gets the cloud print proxy status. |
| 58 void StatusCallback(bool enabled, std::string email); | 59 void StatusCallback(bool enabled, std::string email); |
| 59 // Invoke a task that gets run after the service process successfully | 60 // Invoke a task that gets run after the service process successfully |
| 60 // launches. The task typically involves sending an IPC to the service | 61 // launches. The task typically involves sending an IPC to the service |
| 61 // process. | 62 // process. |
| 62 bool InvokeServiceTask(Task* task); | 63 bool InvokeServiceTask(Task* task); |
| 63 | 64 |
| 64 void OnTokenExpiredNotificationError(); | 65 void OnTokenExpiredNotificationError(); |
| 65 void OnTokenExpiredNotificationClosed(bool by_user); | 66 void OnTokenExpiredNotificationClosed(bool by_user); |
| 66 void OnTokenExpiredNotificationClick(); | 67 void OnTokenExpiredNotificationClick(); |
| 67 void TokenExpiredNotificationDone(bool keep_alive); | 68 void TokenExpiredNotificationDone(bool keep_alive); |
| 68 | 69 |
| 69 | |
| 70 DISALLOW_COPY_AND_ASSIGN(CloudPrintProxyService); | 70 DISALLOW_COPY_AND_ASSIGN(CloudPrintProxyService); |
| 71 }; | 71 }; |
| 72 | 72 |
| 73 #endif // CHROME_BROWSER_PRINTING_CLOUD_PRINT_CLOUD_PRINT_PROXY_SERVICE_H_ | 73 #endif // CHROME_BROWSER_PRINTING_CLOUD_PRINT_CLOUD_PRINT_PROXY_SERVICE_H_ |
| OLD | NEW |