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 15 matching lines...) Expand all Loading... |
26 struct CloudPrintProxyInfo; | 26 struct CloudPrintProxyInfo; |
27 } // namespace cloud_print | 27 } // namespace cloud_print |
28 | 28 |
29 // Layer between the browser user interface and the cloud print proxy code | 29 // Layer between the browser user interface and the cloud print proxy code |
30 // running in the service process. | 30 // running in the service process. |
31 class CloudPrintProxyService : public KeyedService { | 31 class CloudPrintProxyService : public KeyedService { |
32 public: | 32 public: |
33 explicit CloudPrintProxyService(Profile* profile); | 33 explicit CloudPrintProxyService(Profile* profile); |
34 virtual ~CloudPrintProxyService(); | 34 virtual ~CloudPrintProxyService(); |
35 | 35 |
| 36 typedef base::Callback<void(const std::vector<std::string>&)> |
| 37 PrintersCallback; |
| 38 |
36 // Initializes the object. This should be called every time an object of this | 39 // Initializes the object. This should be called every time an object of this |
37 // class is constructed. | 40 // class is constructed. |
38 void Initialize(); | 41 void Initialize(); |
39 | 42 |
| 43 // Returns list of printer names available for registration. |
| 44 void GetPrinters(const PrintersCallback& callback); |
| 45 |
40 // Enables/disables cloud printing for the user | 46 // Enables/disables cloud printing for the user |
41 virtual void EnableForUserWithRobot( | 47 virtual void EnableForUserWithRobot( |
42 const std::string& robot_auth_code, | 48 const std::string& robot_auth_code, |
43 const std::string& robot_email, | 49 const std::string& robot_email, |
44 const std::string& user_email, | 50 const std::string& user_email, |
45 const base::DictionaryValue& user_settings); | 51 const base::DictionaryValue& user_settings); |
46 virtual void DisableForUser(); | 52 virtual void DisableForUser(); |
47 | 53 |
48 // Query the service process for the status of the cloud print proxy and | 54 // Query the service process for the status of the cloud print proxy and |
49 // update the browser prefs. | 55 // update the browser prefs. |
50 void RefreshStatusFromService(); | 56 void RefreshStatusFromService(); |
51 | 57 |
52 // Disable the service if the policy to do so is set, and once the | 58 // Disable the service if the policy to do so is set, and once the |
53 // disablement is verified, quit the browser. Returns true if the policy is | 59 // disablement is verified, quit the browser. Returns true if the policy is |
54 // not set or the connector was not enabled. | 60 // not set or the connector was not enabled. |
55 bool EnforceCloudPrintConnectorPolicyAndQuit(); | 61 bool EnforceCloudPrintConnectorPolicyAndQuit(); |
56 | 62 |
57 std::string proxy_id() const { return proxy_id_; } | 63 std::string proxy_id() const { return proxy_id_; } |
58 | 64 |
59 // Returns list of printer names available for registration. | |
60 static void GetPrintersAvalibleForRegistration( | |
61 std::vector<std::string>* printers); | |
62 | |
63 private: | 65 private: |
64 // NotificationDelegate implementation for the token expired notification. | 66 // NotificationDelegate implementation for the token expired notification. |
65 class TokenExpiredNotificationDelegate; | 67 class TokenExpiredNotificationDelegate; |
66 friend class TokenExpiredNotificationDelegate; | 68 friend class TokenExpiredNotificationDelegate; |
67 | 69 |
68 // Methods that send an IPC to the service. | 70 // Methods that send an IPC to the service. |
| 71 void GetCloudPrintProxyPrinters(const PrintersCallback& callback); |
69 void RefreshCloudPrintProxyStatus(); | 72 void RefreshCloudPrintProxyStatus(); |
70 void EnableCloudPrintProxyWithRobot( | 73 void EnableCloudPrintProxyWithRobot( |
71 const std::string& robot_auth_code, | 74 const std::string& robot_auth_code, |
72 const std::string& robot_email, | 75 const std::string& robot_email, |
73 const std::string& user_email, | 76 const std::string& user_email, |
74 const base::DictionaryValue* user_preferences); | 77 const base::DictionaryValue* user_preferences); |
75 void DisableCloudPrintProxy(); | 78 void DisableCloudPrintProxy(); |
76 | 79 |
77 // Callback that gets the cloud print proxy info. | 80 // Callback that gets the cloud print proxy info. |
78 void ProxyInfoCallback( | 81 void ProxyInfoCallback( |
(...skipping 20 matching lines...) Expand all Loading... |
99 PrefChangeRegistrar pref_change_registrar_; | 102 PrefChangeRegistrar pref_change_registrar_; |
100 | 103 |
101 // If set, continue trying to disable the connector, and quit the process | 104 // If set, continue trying to disable the connector, and quit the process |
102 // once successful. | 105 // once successful. |
103 bool enforcing_connector_policy_; | 106 bool enforcing_connector_policy_; |
104 | 107 |
105 DISALLOW_COPY_AND_ASSIGN(CloudPrintProxyService); | 108 DISALLOW_COPY_AND_ASSIGN(CloudPrintProxyService); |
106 }; | 109 }; |
107 | 110 |
108 #endif // CHROME_BROWSER_PRINTING_CLOUD_PRINT_CLOUD_PRINT_PROXY_SERVICE_H_ | 111 #endif // CHROME_BROWSER_PRINTING_CLOUD_PRINT_CLOUD_PRINT_PROXY_SERVICE_H_ |
OLD | NEW |