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

Side by Side Diff: chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.h

Issue 2468063003: Initial hookup of PpdProvider. (Closed)
Patch Set: Fix callback name bug. Created 4 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
« no previous file with comments | « no previous file | chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_UI_WEBUI_SETTINGS_CHROMEOS_CUPS_PRINTERS_HANDLER_H_ 5 #ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_CUPS_PRINTERS_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_CUPS_PRINTERS_HANDLER_H_ 6 #define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_CUPS_PRINTERS_HANDLER_H_
7 7
8 #include <memory>
9 #include <string>
10 #include <vector>
11
8 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
9 #include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h" 13 #include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
14 #include "chromeos/printing/ppd_provider.h"
10 #include "chromeos/printing/printer_configuration.h" 15 #include "chromeos/printing/printer_configuration.h"
11 #include "chromeos/printing/printer_discoverer.h" 16 #include "chromeos/printing/printer_discoverer.h"
12 #include "ui/shell_dialogs/select_file_dialog.h" 17 #include "ui/shell_dialogs/select_file_dialog.h"
13 18
14 namespace base { 19 namespace base {
15 class ListValue; 20 class ListValue;
16 } // namespace base 21 } // namespace base
17 22
18 class Profile; 23 class Profile;
19 24
20 namespace chromeos { 25 namespace chromeos {
26 namespace printing {
27 class PpdProvider;
28 }
21 namespace settings { 29 namespace settings {
22 30
23 // Chrome OS CUPS printing settings page UI handler. 31 // Chrome OS CUPS printing settings page UI handler.
24 class CupsPrintersHandler : public ::settings::SettingsPageUIHandler, 32 class CupsPrintersHandler : public ::settings::SettingsPageUIHandler,
25 public ui::SelectFileDialog::Listener, 33 public ui::SelectFileDialog::Listener,
26 public chromeos::PrinterDiscoverer::Observer { 34 public chromeos::PrinterDiscoverer::Observer {
27 public: 35 public:
28 explicit CupsPrintersHandler(content::WebUI* webui); 36 explicit CupsPrintersHandler(content::WebUI* webui);
29 ~CupsPrintersHandler() override; 37 ~CupsPrintersHandler() override;
30 38
31 // SettingsPageUIHandler overrides: 39 // SettingsPageUIHandler overrides:
32 void RegisterMessages() override; 40 void RegisterMessages() override;
33 void OnJavascriptAllowed() override {} 41 void OnJavascriptAllowed() override {}
34 void OnJavascriptDisallowed() override {} 42 void OnJavascriptDisallowed() override {}
35 43
36 private: 44 private:
37 // Gets all CUPS printers and return it to WebUI. 45 // Gets all CUPS printers and return it to WebUI.
38 void HandleGetCupsPrintersList(const base::ListValue* args); 46 void HandleGetCupsPrintersList(const base::ListValue* args);
39 void HandleUpdateCupsPrinter(const base::ListValue* args); 47 void HandleUpdateCupsPrinter(const base::ListValue* args);
40 void HandleRemoveCupsPrinter(const base::ListValue* args); 48 void HandleRemoveCupsPrinter(const base::ListValue* args);
41 49
42 void HandleAddCupsPrinter(const base::ListValue* args); 50 void HandleAddCupsPrinter(const base::ListValue* args);
43 void OnAddedPrinter(std::unique_ptr<Printer> printer, bool success); 51 void OnAddedPrinter(std::unique_ptr<Printer> printer, bool success);
44 void OnAddPrinterError(); 52 void OnAddPrinterError();
45 53
54 // Get a list of all manufacturers for which we have at least one
55 // model of printer supported. Takes no arguments, invokes
56 // 'on-manufacturer-list-ready' with an Array<string> with the
57 // result, or on-manufacturer-list-error with no arguments on error.
xdai1 2016/11/02 21:52:32 nit: 'on-manufacturer-list-error'
Carlson 2016/11/02 22:32:49 Removed
58 void HandleGetCupsPrinterManufacturers(const base::ListValue* args);
59
60 // Given a manufacturer, get a list of all models of printers for which
61 // we can get drivers. Takes a single manufacturer string argument.
62 // invokes
xdai1 2016/11/02 21:52:32 nit: no line break here.
Carlson 2016/11/02 22:32:49 Done.
63 // 'on-model-list-ready' with an Array<string> with the
64 // result, or on-model-list-error with no arguments on error.
xdai1 2016/11/02 21:52:32 nit: 'on-model-list-error'
Carlson 2016/11/02 22:32:49 Removed
65 // on-model-list-ready is guaranteed to get at least one model.
66 void HandleGetCupsPrinterModels(const base::ListValue* args);
67
46 void HandleSelectPPDFile(const base::ListValue* args); 68 void HandleSelectPPDFile(const base::ListValue* args);
47 69
70 // PpdProvider callback handlers.
71 void QueryAvailableManufacturersDone(
72 chromeos::printing::PpdProvider::CallbackResultCode result_code,
73 const chromeos::printing::PpdProvider::AvailablePrintersMap& available);
74 void QueryAvailableModelsDone(
75 const std::string manufacturer,
76 chromeos::printing::PpdProvider::CallbackResultCode result_code,
77 const chromeos::printing::PpdProvider::AvailablePrintersMap& available);
78
48 // ui::SelectFileDialog::Listener override: 79 // ui::SelectFileDialog::Listener override:
49 void FileSelected(const base::FilePath& path, 80 void FileSelected(const base::FilePath& path,
50 int index, 81 int index,
51 void* params) override; 82 void* params) override;
52 83
53 void HandleStartDiscovery(const base::ListValue* args); 84 void HandleStartDiscovery(const base::ListValue* args);
54 void HandleStopDiscovery(const base::ListValue* args); 85 void HandleStopDiscovery(const base::ListValue* args);
55 86
56 // chromeos::PrinterDiscoverer::Observer override: 87 // chromeos::PrinterDiscoverer::Observer override:
57 void OnPrintersFound(const std::vector<Printer>& printers) override; 88 void OnPrintersFound(const std::vector<Printer>& printers) override;
58 void OnDiscoveryDone() override; 89 void OnDiscoveryDone() override;
59 90
60 std::unique_ptr<chromeos::PrinterDiscoverer> printer_discoverer_; 91 std::unique_ptr<chromeos::PrinterDiscoverer> printer_discoverer_;
92 std::unique_ptr<chromeos::printing::PpdProvider> ppd_provider_;
61 93
62 Profile* profile_; 94 Profile* profile_;
63 scoped_refptr<ui::SelectFileDialog> select_file_dialog_; 95 scoped_refptr<ui::SelectFileDialog> select_file_dialog_;
64 std::string webui_callback_id_; 96 std::string webui_callback_id_;
65 97
66 base::WeakPtrFactory<CupsPrintersHandler> weak_factory_; 98 base::WeakPtrFactory<CupsPrintersHandler> weak_factory_;
67 99
68 DISALLOW_COPY_AND_ASSIGN(CupsPrintersHandler); 100 DISALLOW_COPY_AND_ASSIGN(CupsPrintersHandler);
69 }; 101 };
70 102
71 } // namespace settings 103 } // namespace settings
72 } // namespace chromeos 104 } // namespace chromeos
73 105
74 #endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_CUPS_PRINTERS_HANDLER_H_ 106 #endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_CUPS_PRINTERS_HANDLER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698