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

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

Issue 1566047: First cut of Cloud Print Proxy implementation. The code is not enabled for no... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Final review changes Created 10 years, 8 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
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2010 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.
4
5 #ifndef CHROME_BROWSER_PRINTING_CLOUD_PRINT_PRINTER_INFO_H_
6 #define CHROME_BROWSER_PRINTING_CLOUD_PRINT_PRINTER_INFO_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/file_path.h"
12
13 // This is the interface for platform-specific code for cloud print
14 namespace cloud_print {
15
16 typedef int PlatformJobId;
17
18 struct PrinterBasicInfo {
19 std::string printer_name;
20 std::string printer_description;
21 int printer_status;
22 PrinterBasicInfo() : printer_status(0) {
23 }
24 };
25
26 typedef std::vector<PrinterBasicInfo> PrinterList;
27
28 struct PrinterCapsAndDefaults {
29 std::string printer_capabilities;
30 std::string caps_mime_type;
31 std::string printer_defaults;
32 std::string defaults_mime_type;
33 };
34
35 enum PrintJobStatus {
36 PRINT_JOB_STATUS_INVALID,
37 PRINT_JOB_STATUS_IN_PROGRESS,
38 PRINT_JOB_STATUS_ERROR,
39 PRINT_JOB_STATUS_COMPLETED
40 };
41
42 struct PrintJobDetails {
43 PrintJobStatus status;
44 int platform_status_flags;
45 std::string status_message;
46 int total_pages;
47 int pages_printed;
48 PrintJobDetails() : status(PRINT_JOB_STATUS_INVALID),
49 platform_status_flags(0), total_pages(0),
50 pages_printed(0) {
51 }
52 void Clear() {
53 status = PRINT_JOB_STATUS_INVALID;
54 platform_status_flags = 0;
55 status_message.clear();
56 total_pages = 0;
57 pages_printed = 0;
58 }
59 bool operator ==(const PrintJobDetails& other) const {
60 return (status == other.status) &&
61 (platform_status_flags == other.platform_status_flags) &&
62 (status_message == other.status_message) &&
63 (total_pages == other.total_pages) &&
64 (pages_printed == other.pages_printed);
65 }
66 bool operator !=(const PrintJobDetails& other) const {
67 return !(*this == other);
68 }
69 };
70
71 // Enumerates the list of installed local and network printers.
72 void EnumeratePrinters(PrinterList* printer_list);
73 // Gets the capabilities and defaults for a specific printer.
74 bool GetPrinterCapsAndDefaults(const std::string& printer_name,
75 PrinterCapsAndDefaults* printer_info);
76 bool ValidatePrintTicket(const std::string& printer_name,
77 const std::string& print_ticket_data);
78 std::string GenerateProxyId();
79 bool SpoolPrintJob(const std::string& print_ticket,
80 const FilePath& print_data_file_path,
81 const std::string& print_data_mime_type,
82 const std::string& printer_name,
83 const std::string& job_title,
84 PlatformJobId* job_id_ret);
85
86 bool GetJobDetails(const std::string& printer_name,
87 PlatformJobId job_id,
88 PrintJobDetails *job_details);
89 bool IsValidPrinter(const std::string& printer_name);
90
91 // A class that watches changes to a printer or a print server.
92 // The set of notifications are very coarse-grained (even though the Windows
93 // API allows for listening to fine-grained details about a printer, this class
94 // does not support that level of fine-grained control.
95 class PrinterChangeNotifier {
96 public:
97 class Delegate {
98 public:
99 virtual void OnPrinterAdded() = 0;
100 virtual void OnPrinterDeleted() = 0;
101 virtual void OnPrinterChanged() = 0;
102 virtual void OnJobChanged() = 0;
103 };
104 PrinterChangeNotifier();
105 ~PrinterChangeNotifier();
106 bool StartWatching(const std::string& printer_name, Delegate* delegate);
107 bool StopWatching();
108 bool GetCurrentPrinterInfo(PrinterBasicInfo* printer_info);
109 private:
110 // Internal state maintained by the PrinterChangeNotifier class.
111 class NotificationState;
112 NotificationState* state_;
113 DISALLOW_COPY_AND_ASSIGN(PrinterChangeNotifier);
114 };
115
116 // This typedef is to workaround the issue with certain versions of
117 // Visual Studio where it gets confused between multiple Delegate
118 // classes and gives a C2500 error. (I saw this error on the try bots -
119 // the workaround was not needed for my machine).
120 typedef PrinterChangeNotifier::Delegate PrinterChangeNotifierDelegate;
121
122 } // namespace cloud_print
123
124 #endif // CHROME_BROWSER_PRINTING_CLOUD_PRINT_PRINTER_INFO_H_
125
OLDNEW
« no previous file with comments | « chrome/browser/printing/cloud_print/job_status_updater.cc ('k') | chrome/browser/printing/cloud_print/printer_info_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698