Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(104)

Side by Side Diff: chrome/browser/printing/cloud_print/cloud_print_proxy_service.h

Issue 8438020: Cloud print connector policy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments, initialization fix for Windows. Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "base/observer_list.h" 13 #include "base/observer_list.h"
14 #include "base/task.h" 14 #include "base/task.h"
15 #include "chrome/browser/prefs/pref_change_registrar.h"
15 #include "chrome/browser/printing/cloud_print/cloud_print_setup_handler.h" 16 #include "chrome/browser/printing/cloud_print/cloud_print_setup_handler.h"
16 #include "chrome/browser/profiles/profile_keyed_service.h" 17 #include "chrome/browser/profiles/profile_keyed_service.h"
18 #include "content/public/browser/notification_observer.h"
17 19
18 class Profile; 20 class Profile;
21 class ServiceProcessControl;
19 22
20 namespace cloud_print { 23 namespace cloud_print {
21 struct CloudPrintProxyInfo; 24 struct CloudPrintProxyInfo;
22 } // namespace cloud_print 25 } // namespace cloud_print
23 26
24 // Layer between the browser user interface and the cloud print proxy code 27 // Layer between the browser user interface and the cloud print proxy code
25 // running in the service process. 28 // running in the service process.
26 class CloudPrintProxyService 29 class CloudPrintProxyService
27 : public CloudPrintSetupHandlerDelegate, 30 : public CloudPrintSetupHandlerDelegate,
28 public ProfileKeyedService { 31 public ProfileKeyedService,
32 public content::NotificationObserver {
29 public: 33 public:
30 explicit CloudPrintProxyService(Profile* profile); 34 explicit CloudPrintProxyService(Profile* profile);
31 virtual ~CloudPrintProxyService(); 35 virtual ~CloudPrintProxyService();
32 36
33 // Initializes the object. This should be called every time an object of this 37 // Initializes the object. This should be called every time an object of this
34 // class is constructed. 38 // class is constructed.
35 void Initialize(); 39 void Initialize();
36 40
37 // Enables/disables cloud printing for the user 41 // Enables/disables cloud printing for the user
38 virtual void EnableForUser(const std::string& lsid, const std::string& email); 42 virtual void EnableForUser(const std::string& lsid, const std::string& email);
39 virtual void EnableForUserWithRobot(const std::string& robot_auth_code, 43 virtual void EnableForUserWithRobot(const std::string& robot_auth_code,
40 const std::string& robot_email, 44 const std::string& robot_email,
41 const std::string& user_email); 45 const std::string& user_email);
42 virtual void DisableForUser(); 46 virtual void DisableForUser();
43 47
44 // 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
45 // update the browser prefs. 49 // update the browser prefs.
46 void RefreshStatusFromService(); 50 void RefreshStatusFromService();
47 51
48 bool ShowTokenExpiredNotification(); 52 bool ShowTokenExpiredNotification();
49 std::string proxy_id() const { return proxy_id_; } 53 std::string proxy_id() const { return proxy_id_; }
50 54
51 // CloudPrintSetupHandler::Delegate implementation. 55 // CloudPrintSetupHandler::Delegate implementation.
52 virtual void OnCloudPrintSetupClosed(); 56 virtual void OnCloudPrintSetupClosed();
53 57
58 // content::NotificationObserver implementation.
59 virtual void Observe(int type,
60 const content::NotificationSource& source,
61 const content::NotificationDetails& details) OVERRIDE;
62
54 private: 63 private:
55 // NotificationDelegate implementation for the token expired notification. 64 // NotificationDelegate implementation for the token expired notification.
56 class TokenExpiredNotificationDelegate; 65 class TokenExpiredNotificationDelegate;
57 friend class TokenExpiredNotificationDelegate; 66 friend class TokenExpiredNotificationDelegate;
58 67
59 Profile* profile_; 68 Profile* profile_;
60 scoped_refptr<TokenExpiredNotificationDelegate> token_expired_delegate_; 69 scoped_refptr<TokenExpiredNotificationDelegate> token_expired_delegate_;
61 scoped_ptr<CloudPrintSetupHandler> cloud_print_setup_handler_; 70 scoped_ptr<CloudPrintSetupHandler> cloud_print_setup_handler_;
62 std::string proxy_id_; 71 std::string proxy_id_;
63 72
(...skipping 11 matching lines...) Expand all
75 84
76 // Invoke a task that gets run after the service process successfully 85 // Invoke a task that gets run after the service process successfully
77 // launches. The task typically involves sending an IPC to the service 86 // launches. The task typically involves sending an IPC to the service
78 // process. 87 // process.
79 bool InvokeServiceTask(const base::Closure& task); 88 bool InvokeServiceTask(const base::Closure& task);
80 89
81 void OnTokenExpiredNotificationError(); 90 void OnTokenExpiredNotificationError();
82 void OnTokenExpiredNotificationClosed(bool by_user); 91 void OnTokenExpiredNotificationClosed(bool by_user);
83 void OnTokenExpiredNotificationClick(); 92 void OnTokenExpiredNotificationClick();
84 void TokenExpiredNotificationDone(bool keep_alive); 93 void TokenExpiredNotificationDone(bool keep_alive);
94 void ApplyCloudPrintConnectorPolicy();
95
96 // Virtual for testing.
97 virtual ServiceProcessControl* GetServiceProcessControl();
85 98
86 base::WeakPtrFactory<CloudPrintProxyService> weak_factory_; 99 base::WeakPtrFactory<CloudPrintProxyService> weak_factory_;
87 100
101 // For watching for connector enablement policy changes.
102 PrefChangeRegistrar pref_change_registrar_;
103
88 DISALLOW_COPY_AND_ASSIGN(CloudPrintProxyService); 104 DISALLOW_COPY_AND_ASSIGN(CloudPrintProxyService);
89 }; 105 };
90 106
91 #endif // CHROME_BROWSER_PRINTING_CLOUD_PRINT_CLOUD_PRINT_PROXY_SERVICE_H_ 107 #endif // CHROME_BROWSER_PRINTING_CLOUD_PRINT_CLOUD_PRINT_PROXY_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698