1 // Copyright 2013 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_LOCAL_DISCOVERY_CLOUD_PRINT_PRINTER_LIST_H_
6 #define CHROME_BROWSER_LOCAL_DISCOVERY_CLOUD_PRINT_PRINTER_LIST_H_
12 #include "chrome/browser/local_discovery/gcd_base_api_flow.h"
14 namespace local_discovery
{
16 class CloudPrintPrinterList
: public GCDBaseApiFlow::Delegate
{
22 virtual void OnCloudPrintPrinterListReady() = 0;
23 virtual void OnCloudPrintPrinterListUnavailable() = 0;
26 struct PrinterDetails
{
31 std::string display_name
;
32 std::string description
;
33 // TODO(noamsml): std::string user;
36 typedef std::vector
<PrinterDetails
> PrinterList
;
37 typedef PrinterList::const_iterator iterator
;
39 CloudPrintPrinterList(net::URLRequestContextGetter
* request_context
,
40 OAuth2TokenService
* token_service
,
41 const std::string
& account_id
,
43 virtual ~CloudPrintPrinterList();
47 virtual void OnGCDAPIFlowError(GCDBaseApiFlow
* flow
,
48 GCDBaseApiFlow::Status status
) OVERRIDE
;
50 virtual void OnGCDAPIFlowComplete(GCDBaseApiFlow
* flow
,
51 const base::DictionaryValue
* value
)
54 virtual bool GCDIsCloudPrint() OVERRIDE
;
56 const PrinterDetails
* GetDetailsFor(const std::string
& id
);
58 iterator
begin() { return printer_list_
.begin(); }
59 iterator
end() { return printer_list_
.end(); }
61 GCDBaseApiFlow
* GetOAuth2ApiFlowForTests() { return &api_flow_
; }
64 typedef std::map
<std::string
/*ID*/, int /* index in printer_list_ */>
67 bool FillPrinterDetails(const base::DictionaryValue
* printer_value
,
68 PrinterDetails
* printer_details
);
70 scoped_refptr
<net::URLRequestContextGetter
> request_context_
;
71 PrinterIDMap printer_id_map_
;
72 PrinterList printer_list_
;
74 GCDBaseApiFlow api_flow_
;
77 } // namespace local_discovery
79 #endif // CHROME_BROWSER_LOCAL_DISCOVERY_CLOUD_PRINT_PRINTER_LIST_H_