Update broken references to image assets
[chromium-blink-merge.git] / chrome / browser / printing / cloud_print / cloud_print_proxy_service.h
blob0b795081a72a565e40705ec864554247d5f57ec0
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_PRINTING_CLOUD_PRINT_CLOUD_PRINT_PROXY_SERVICE_H_
6 #define CHROME_BROWSER_PRINTING_CLOUD_PRINT_CLOUD_PRINT_PROXY_SERVICE_H_
8 #include <string>
9 #include <vector>
11 #include "base/basictypes.h"
12 #include "base/callback_forward.h"
13 #include "base/memory/weak_ptr.h"
14 #include "base/observer_list.h"
15 #include "base/prefs/pref_change_registrar.h"
16 #include "components/keyed_service/core/keyed_service.h"
18 class Profile;
19 class ServiceProcessControl;
21 namespace base {
22 class DictionaryValue;
23 } // namespace base
25 namespace cloud_print {
26 struct CloudPrintProxyInfo;
27 } // namespace cloud_print
29 // Layer between the browser user interface and the cloud print proxy code
30 // running in the service process.
31 class CloudPrintProxyService : public KeyedService {
32 public:
33 explicit CloudPrintProxyService(Profile* profile);
34 ~CloudPrintProxyService() override;
36 typedef base::Callback<void(const std::vector<std::string>&)>
37 PrintersCallback;
39 // Initializes the object. This should be called every time an object of this
40 // class is constructed.
41 void Initialize();
43 // Returns list of printer names available for registration.
44 void GetPrinters(const PrintersCallback& callback);
46 // Enables/disables cloud printing for the user
47 virtual void EnableForUserWithRobot(
48 const std::string& robot_auth_code,
49 const std::string& robot_email,
50 const std::string& user_email,
51 const base::DictionaryValue& user_settings);
52 virtual void DisableForUser();
54 // Query the service process for the status of the cloud print proxy and
55 // update the browser prefs.
56 void RefreshStatusFromService();
58 std::string proxy_id() const { return proxy_id_; }
60 private:
61 // NotificationDelegate implementation for the token expired notification.
62 class TokenExpiredNotificationDelegate;
63 friend class TokenExpiredNotificationDelegate;
65 // Methods that send an IPC to the service.
66 void GetCloudPrintProxyPrinters(const PrintersCallback& callback);
67 void RefreshCloudPrintProxyStatus();
68 void EnableCloudPrintProxyWithRobot(
69 const std::string& robot_auth_code,
70 const std::string& robot_email,
71 const std::string& user_email,
72 const base::DictionaryValue* user_preferences);
73 void DisableCloudPrintProxy();
75 // Callback that gets the cloud print proxy info.
76 void ProxyInfoCallback(
77 const cloud_print::CloudPrintProxyInfo& proxy_info);
79 // Invoke a task that gets run after the service process successfully
80 // launches. The task typically involves sending an IPC to the service
81 // process.
82 bool InvokeServiceTask(const base::Closure& task);
84 // Checks the policy. Returns true if nothing needs to be done (the policy is
85 // not set or the connector is not enabled).
86 bool ApplyCloudPrintConnectorPolicy();
88 Profile* profile_;
89 std::string proxy_id_;
91 // Virtual for testing.
92 virtual ServiceProcessControl* GetServiceProcessControl();
94 // For watching for connector policy changes.
95 PrefChangeRegistrar pref_change_registrar_;
97 base::WeakPtrFactory<CloudPrintProxyService> weak_factory_;
99 DISALLOW_COPY_AND_ASSIGN(CloudPrintProxyService);
102 #endif // CHROME_BROWSER_PRINTING_CLOUD_PRINT_CLOUD_PRINT_PROXY_SERVICE_H_