| 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_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 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 // Initializes the object. This should be called every time an object of this | 35 // Initializes the object. This should be called every time an object of this |
| 36 // class is constructed. | 36 // class is constructed. |
| 37 void Initialize(); | 37 void Initialize(); |
| 38 | 38 |
| 39 // Enables/disables cloud printing for the user | 39 // Enables/disables cloud printing for the user |
| 40 virtual void EnableForUser(const std::string& lsid, const std::string& email); | 40 virtual void EnableForUser(const std::string& lsid, const std::string& email); |
| 41 virtual void EnableForUserWithRobot( | 41 virtual void EnableForUserWithRobot( |
| 42 const std::string& robot_auth_code, | 42 const std::string& robot_auth_code, |
| 43 const std::string& robot_email, | 43 const std::string& robot_email, |
| 44 const std::string& user_email, | 44 const std::string& user_email, |
| 45 bool connect_new_printers, | 45 const base::DictionaryValue& user_settings); |
| 46 const std::vector<std::string>& printer_blacklist); | |
| 47 virtual void DisableForUser(); | 46 virtual void DisableForUser(); |
| 48 | 47 |
| 49 // Query the service process for the status of the cloud print proxy and | 48 // Query the service process for the status of the cloud print proxy and |
| 50 // update the browser prefs. | 49 // update the browser prefs. |
| 51 void RefreshStatusFromService(); | 50 void RefreshStatusFromService(); |
| 52 | 51 |
| 53 // Disable the service if the policy to do so is set, and once the | 52 // Disable the service if the policy to do so is set, and once the |
| 54 // disablement is verified, quit the browser. Returns true if the policy is | 53 // disablement is verified, quit the browser. Returns true if the policy is |
| 55 // not set or the connector was not enabled. | 54 // not set or the connector was not enabled. |
| 56 bool EnforceCloudPrintConnectorPolicyAndQuit(); | 55 bool EnforceCloudPrintConnectorPolicyAndQuit(); |
| 57 | 56 |
| 58 std::string proxy_id() const { return proxy_id_; } | 57 std::string proxy_id() const { return proxy_id_; } |
| 59 | 58 |
| 60 // CloudPrintSetupHandler::Delegate implementation. | 59 // CloudPrintSetupHandler::Delegate implementation. |
| 61 virtual void OnCloudPrintSetupClosed() OVERRIDE; | 60 virtual void OnCloudPrintSetupClosed() OVERRIDE; |
| 62 | 61 |
| 63 // Returns list of printer names available for registration. | 62 // Returns list of printer names available for registration. |
| 64 static void GetPrintersAvalibleForRegistration( | 63 static void GetPrintersAvalibleForRegistration( |
| 65 std::vector<std::string>* printers); | 64 std::vector<std::string>* printers); |
| 66 | 65 |
| 67 private: | 66 private: |
| 68 // NotificationDelegate implementation for the token expired notification. | 67 // NotificationDelegate implementation for the token expired notification. |
| 69 class TokenExpiredNotificationDelegate; | 68 class TokenExpiredNotificationDelegate; |
| 70 friend class TokenExpiredNotificationDelegate; | 69 friend class TokenExpiredNotificationDelegate; |
| 71 | 70 |
| 72 Profile* profile_; | |
| 73 std::string proxy_id_; | |
| 74 | |
| 75 // Methods that send an IPC to the service. | 71 // Methods that send an IPC to the service. |
| 76 void RefreshCloudPrintProxyStatus(); | 72 void RefreshCloudPrintProxyStatus(); |
| 77 void EnableCloudPrintProxy(const std::string& lsid, const std::string& email); | 73 void EnableCloudPrintProxy(const std::string& lsid, const std::string& email); |
| 78 void EnableCloudPrintProxyWithRobot( | 74 void EnableCloudPrintProxyWithRobot( |
| 79 const std::string& robot_auth_code, | 75 const std::string& robot_auth_code, |
| 80 const std::string& robot_email, | 76 const std::string& robot_email, |
| 81 const std::string& user_email, | 77 const std::string& user_email, |
| 82 bool connect_new_printers, | 78 const base::DictionaryValue* user_preferences); |
| 83 const std::vector<std::string>& printer_blacklist); | |
| 84 void DisableCloudPrintProxy(); | 79 void DisableCloudPrintProxy(); |
| 85 | 80 |
| 86 // Callback that gets the cloud print proxy info. | 81 // Callback that gets the cloud print proxy info. |
| 87 void ProxyInfoCallback( | 82 void ProxyInfoCallback( |
| 88 const cloud_print::CloudPrintProxyInfo& proxy_info); | 83 const cloud_print::CloudPrintProxyInfo& proxy_info); |
| 89 | 84 |
| 90 // Invoke a task that gets run after the service process successfully | 85 // Invoke a task that gets run after the service process successfully |
| 91 // launches. The task typically involves sending an IPC to the service | 86 // launches. The task typically involves sending an IPC to the service |
| 92 // process. | 87 // process. |
| 93 bool InvokeServiceTask(const base::Closure& task); | 88 bool InvokeServiceTask(const base::Closure& task); |
| 94 | 89 |
| 95 // Checks the policy. Returns true if nothing needs to be done (the policy is | 90 // Checks the policy. Returns true if nothing needs to be done (the policy is |
| 96 // not set or the connector is not enabled). | 91 // not set or the connector is not enabled). |
| 97 bool ApplyCloudPrintConnectorPolicy(); | 92 bool ApplyCloudPrintConnectorPolicy(); |
| 98 | 93 |
| 94 Profile* profile_; |
| 95 std::string proxy_id_; |
| 96 |
| 99 // Virtual for testing. | 97 // Virtual for testing. |
| 100 virtual ServiceProcessControl* GetServiceProcessControl(); | 98 virtual ServiceProcessControl* GetServiceProcessControl(); |
| 101 | 99 |
| 102 base::WeakPtrFactory<CloudPrintProxyService> weak_factory_; | 100 base::WeakPtrFactory<CloudPrintProxyService> weak_factory_; |
| 103 | 101 |
| 104 // For watching for connector enablement policy changes. | 102 // For watching for connector policy changes. |
| 105 PrefChangeRegistrar pref_change_registrar_; | 103 PrefChangeRegistrar pref_change_registrar_; |
| 106 | 104 |
| 107 // If set, continue trying to disable the connector, and quit the process | 105 // If set, continue trying to disable the connector, and quit the process |
| 108 // once successful. | 106 // once successful. |
| 109 bool enforcing_connector_policy_; | 107 bool enforcing_connector_policy_; |
| 110 | 108 |
| 111 DISALLOW_COPY_AND_ASSIGN(CloudPrintProxyService); | 109 DISALLOW_COPY_AND_ASSIGN(CloudPrintProxyService); |
| 112 }; | 110 }; |
| 113 | 111 |
| 114 #endif // CHROME_BROWSER_PRINTING_CLOUD_PRINT_CLOUD_PRINT_PROXY_SERVICE_H_ | 112 #endif // CHROME_BROWSER_PRINTING_CLOUD_PRINT_CLOUD_PRINT_PROXY_SERVICE_H_ |
| OLD | NEW |