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

Side by Side Diff: chrome/service/cloud_print/cloud_print_connector.h

Issue 10966052: Added options to disable specific printers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 months 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
« no previous file with comments | « chrome/common/pref_names.cc ('k') | chrome/service/cloud_print/cloud_print_connector.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_SERVICE_CLOUD_PRINT_CLOUD_PRINT_CONNECTOR_H_ 5 #ifndef CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_CONNECTOR_H_
6 #define CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_CONNECTOR_H_ 6 #define CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_CONNECTOR_H_
7 7
8 #include <list> 8 #include <list>
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
11 11
12 #include "base/threading/thread.h" 12 #include "base/threading/thread.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "chrome/service/cloud_print/connector_settings.h" 14 #include "chrome/service/cloud_print/connector_settings.h"
15 #include "chrome/service/cloud_print/print_system.h" 15 #include "chrome/service/cloud_print/print_system.h"
16 #include "chrome/service/cloud_print/printer_job_handler.h" 16 #include "chrome/service/cloud_print/printer_job_handler.h"
17 17
18 // CloudPrintConnector handles top printer management tasks. 18 // CloudPrintConnector handles top printer management tasks.
19 // - Matching local and cloud printers 19 // - Matching local and cloud printers
20 // - Registration of local printers 20 // - Registration of local printers
21 // - Deleting cloud printers 21 // - Deleting cloud printers
22 // All tasks are posted to the common queue (PendingTasks) and executed 22 // All tasks are posted to the common queue (PendingTasks) and executed
23 // one-by-one in FIFO order. 23 // one-by-one in FIFO order.
24 // CloudPrintConnector will notify client over Client interface. 24 // CloudPrintConnector will notify client over Client interface.
25 class CloudPrintConnector 25 class CloudPrintConnector
26 : public base::RefCountedThreadSafe<CloudPrintConnector>, 26 : public base::RefCountedThreadSafe<CloudPrintConnector>,
27 public cloud_print::PrintServerWatcherDelegate, 27 private cloud_print::PrintServerWatcherDelegate,
28 public PrinterJobHandlerDelegate, 28 private PrinterJobHandlerDelegate,
29 public CloudPrintURLFetcherDelegate { 29 private CloudPrintURLFetcherDelegate {
30 public: 30 public:
31 class Client { 31 class Client {
32 public: 32 public:
33 virtual void OnAuthFailed() = 0; 33 virtual void OnAuthFailed() = 0;
34 protected: 34 protected:
35 virtual ~Client() {} 35 virtual ~Client() {}
36 }; 36 };
37 37
38 CloudPrintConnector(Client* client, const ConnectorSettings& settings); 38 CloudPrintConnector(Client* client, const ConnectorSettings& settings);
39 39
40 bool Start(); 40 bool Start();
41 void Stop(); 41 void Stop();
42 bool IsRunning(); 42 bool IsRunning();
43 43
44 // Return list of printer ids registered with CloudPrint. 44 // Return list of printer ids registered with CloudPrint.
45 void GetPrinterIds(std::list<std::string>* printer_ids); 45 void GetPrinterIds(std::list<std::string>* printer_ids);
46 46
47 // Register printer from the list.
48 void RegisterPrinters(const printing::PrinterList& printers);
49
50 // Check for jobs for specific printer. If printer id is empty 47 // Check for jobs for specific printer. If printer id is empty
51 // jobs will be checked for all available printers. 48 // jobs will be checked for all available printers.
52 void CheckForJobs(const std::string& reason, const std::string& printer_id); 49 void CheckForJobs(const std::string& reason, const std::string& printer_id);
53 50
54 // cloud_print::PrintServerWatcherDelegate implementation
55 virtual void OnPrinterAdded() OVERRIDE;
56 // PrinterJobHandler::Delegate implementation
57 virtual void OnPrinterDeleted(const std::string& printer_name) OVERRIDE;
58 virtual void OnAuthError() OVERRIDE;
59
60 // CloudPrintURLFetcher::Delegate implementation.
61 virtual CloudPrintURLFetcher::ResponseAction HandleRawData(
62 const net::URLFetcher* source,
63 const GURL& url,
64 const std::string& data) OVERRIDE;
65 virtual CloudPrintURLFetcher::ResponseAction HandleJSONData(
66 const net::URLFetcher* source,
67 const GURL& url,
68 base::DictionaryValue* json_data,
69 bool succeeded) OVERRIDE;
70 virtual CloudPrintURLFetcher::ResponseAction OnRequestAuthError() OVERRIDE;
71 virtual std::string GetAuthHeader() OVERRIDE;
72
73 private: 51 private:
74 friend class base::RefCountedThreadSafe<CloudPrintConnector>; 52 friend class base::RefCountedThreadSafe<CloudPrintConnector>;
75 53
76 // Prototype for a response handler. 54 // Prototype for a response handler.
77 typedef CloudPrintURLFetcher::ResponseAction 55 typedef CloudPrintURLFetcher::ResponseAction
78 (CloudPrintConnector::*ResponseHandler)( 56 (CloudPrintConnector::*ResponseHandler)(
79 const net::URLFetcher* source, 57 const net::URLFetcher* source,
80 const GURL& url, 58 const GURL& url,
81 DictionaryValue* json_data, 59 DictionaryValue* json_data,
82 bool succeeded); 60 bool succeeded);
(...skipping 10 matching lines...) Expand all
93 PendingTaskType type; 71 PendingTaskType type;
94 // Optional members, depending on type. 72 // Optional members, depending on type.
95 std::string printer_id; // For pending delete. 73 std::string printer_id; // For pending delete.
96 printing::PrinterBasicInfo printer_info; // For pending registration. 74 printing::PrinterBasicInfo printer_info; // For pending registration.
97 75
98 PendingTask() : type(PENDING_PRINTERS_NONE) {} 76 PendingTask() : type(PENDING_PRINTERS_NONE) {}
99 ~PendingTask() {} 77 ~PendingTask() {}
100 }; 78 };
101 79
102 virtual ~CloudPrintConnector(); 80 virtual ~CloudPrintConnector();
81 // cloud_print::PrintServerWatcherDelegate implementation
82 virtual void OnPrinterAdded() OVERRIDE;
83 // PrinterJobHandler::Delegate implementation
84 virtual void OnPrinterDeleted(const std::string& printer_name) OVERRIDE;
85 virtual void OnAuthError() OVERRIDE;
86
87 // CloudPrintURLFetcher::Delegate implementation.
88 virtual CloudPrintURLFetcher::ResponseAction HandleRawData(
89 const net::URLFetcher* source,
90 const GURL& url,
91 const std::string& data) OVERRIDE;
92 virtual CloudPrintURLFetcher::ResponseAction HandleJSONData(
93 const net::URLFetcher* source,
94 const GURL& url,
95 base::DictionaryValue* json_data,
96 bool succeeded) OVERRIDE;
97 virtual CloudPrintURLFetcher::ResponseAction OnRequestAuthError() OVERRIDE;
98 virtual std::string GetAuthHeader() OVERRIDE;
103 99
104 // Begin response handlers 100 // Begin response handlers
105 CloudPrintURLFetcher::ResponseAction HandlePrinterListResponse( 101 CloudPrintURLFetcher::ResponseAction HandlePrinterListResponse(
106 const net::URLFetcher* source, 102 const net::URLFetcher* source,
107 const GURL& url, 103 const GURL& url,
108 DictionaryValue* json_data, 104 DictionaryValue* json_data,
109 bool succeeded); 105 bool succeeded);
110 106
111 CloudPrintURLFetcher::ResponseAction HandlePrinterDeleteResponse( 107 CloudPrintURLFetcher::ResponseAction HandlePrinterDeleteResponse(
112 const net::URLFetcher* source, 108 const net::URLFetcher* source,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 void ContinuePendingTaskProcessing(); 144 void ContinuePendingTaskProcessing();
149 void OnPrintersAvailable(); 145 void OnPrintersAvailable();
150 void OnPrinterRegister(const printing::PrinterBasicInfo& info); 146 void OnPrinterRegister(const printing::PrinterBasicInfo& info);
151 void OnPrinterDelete(const std::string& name); 147 void OnPrinterDelete(const std::string& name);
152 148
153 void OnReceivePrinterCaps( 149 void OnReceivePrinterCaps(
154 bool succeeded, 150 bool succeeded,
155 const std::string& printer_name, 151 const std::string& printer_name,
156 const printing::PrinterCapsAndDefaults& caps_and_defaults); 152 const printing::PrinterCapsAndDefaults& caps_and_defaults);
157 153
154 // Register printer from the list.
155 void RegisterPrinters(const printing::PrinterList& printers);
156
158 bool IsSamePrinter(const std::string& name1, const std::string& name2) const; 157 bool IsSamePrinter(const std::string& name1, const std::string& name2) const;
159 bool InitPrintSystem(); 158 bool InitPrintSystem();
160 159
161 // CloudPrintConnector client. 160 // CloudPrintConnector client.
162 Client* client_; 161 Client* client_;
163 // Connector settings. 162 // Connector settings.
164 ConnectorSettings settings_; 163 ConnectorSettings settings_;
165 // Pointer to current print system. 164 // Pointer to current print system.
166 scoped_refptr<cloud_print::PrintSystem> print_system_; 165 scoped_refptr<cloud_print::PrintSystem> print_system_;
167 // Watcher for print system updates. 166 // Watcher for print system updates.
(...skipping 10 matching lines...) Expand all
178 // The CloudPrintURLFetcher instance for the current request. 177 // The CloudPrintURLFetcher instance for the current request.
179 scoped_refptr<CloudPrintURLFetcher> request_; 178 scoped_refptr<CloudPrintURLFetcher> request_;
180 // The CloudPrintURLFetcher instance for the user message request. 179 // The CloudPrintURLFetcher instance for the user message request.
181 scoped_refptr<CloudPrintURLFetcher> user_message_request_; 180 scoped_refptr<CloudPrintURLFetcher> user_message_request_;
182 181
183 DISALLOW_COPY_AND_ASSIGN(CloudPrintConnector); 182 DISALLOW_COPY_AND_ASSIGN(CloudPrintConnector);
184 }; 183 };
185 184
186 #endif // CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_CONNECTOR_H_ 185 #endif // CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_CONNECTOR_H_
187 186
OLDNEW
« no previous file with comments | « chrome/common/pref_names.cc ('k') | chrome/service/cloud_print/cloud_print_connector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698