OLD | NEW |
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 "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
9 #include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h" | 9 #include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h" |
10 #include "chromeos/printing/printer_configuration.h" | 10 #include "chromeos/printing/printer_configuration.h" |
| 11 #include "chromeos/printing/printer_discoverer.h" |
11 #include "ui/shell_dialogs/select_file_dialog.h" | 12 #include "ui/shell_dialogs/select_file_dialog.h" |
12 | 13 |
13 namespace base { | 14 namespace base { |
14 class ListValue; | 15 class ListValue; |
15 } // namespace base | 16 } // namespace base |
16 | 17 |
17 class Profile; | 18 class Profile; |
18 | 19 |
19 namespace chromeos { | 20 namespace chromeos { |
20 namespace settings { | 21 namespace settings { |
21 | 22 |
22 // Chrome OS CUPS printing settings page UI handler. | 23 // Chrome OS CUPS printing settings page UI handler. |
23 class CupsPrintersHandler : public ::settings::SettingsPageUIHandler, | 24 class CupsPrintersHandler : public ::settings::SettingsPageUIHandler, |
24 public ui::SelectFileDialog::Listener { | 25 public ui::SelectFileDialog::Listener, |
| 26 public chromeos::PrinterDiscoverer::Observer { |
25 public: | 27 public: |
26 explicit CupsPrintersHandler(content::WebUI* webui); | 28 explicit CupsPrintersHandler(content::WebUI* webui); |
27 ~CupsPrintersHandler() override; | 29 ~CupsPrintersHandler() override; |
28 | 30 |
29 // SettingsPageUIHandler overrides: | 31 // SettingsPageUIHandler overrides: |
30 void RegisterMessages() override; | 32 void RegisterMessages() override; |
31 void OnJavascriptAllowed() override{}; | 33 void OnJavascriptAllowed() override {} |
32 void OnJavascriptDisallowed() override{}; | 34 void OnJavascriptDisallowed() override {} |
33 | 35 |
34 private: | 36 private: |
35 // Gets all CUPS printers and return it to WebUI. | 37 // Gets all CUPS printers and return it to WebUI. |
36 void HandleGetCupsPrintersList(const base::ListValue* args); | 38 void HandleGetCupsPrintersList(const base::ListValue* args); |
37 void HandleUpdateCupsPrinter(const base::ListValue* args); | 39 void HandleUpdateCupsPrinter(const base::ListValue* args); |
38 void HandleRemoveCupsPrinter(const base::ListValue* args); | 40 void HandleRemoveCupsPrinter(const base::ListValue* args); |
39 void OnRemovedPrinter(const std::string& printer_id, bool success); | |
40 | 41 |
41 void HandleAddCupsPrinter(const base::ListValue* args); | 42 void HandleAddCupsPrinter(const base::ListValue* args); |
42 void OnAddedPrinter(std::unique_ptr<Printer> printer, bool success); | 43 void OnAddedPrinter(std::unique_ptr<Printer> printer, bool success); |
43 void OnAddPrinterError(); | 44 void OnAddPrinterError(); |
44 | 45 |
45 void HandleSelectPPDFile(const base::ListValue* args); | 46 void HandleSelectPPDFile(const base::ListValue* args); |
46 | 47 |
47 // ui::SelectFileDialog::Listener override: | 48 // ui::SelectFileDialog::Listener override: |
48 void FileSelected(const base::FilePath& path, | 49 void FileSelected(const base::FilePath& path, |
49 int index, | 50 int index, |
50 void* params) override; | 51 void* params) override; |
51 | 52 |
| 53 void HandleStartDiscovery(const base::ListValue* args); |
| 54 void HandleStopDiscovery(const base::ListValue* args); |
| 55 |
| 56 // chromeos::PrinterDiscoverer::Observer override: |
| 57 void OnPrintersFound(const std::vector<Printer>& printers) override; |
| 58 void OnDiscoveryDone() override; |
| 59 |
| 60 std::unique_ptr<chromeos::PrinterDiscoverer> printer_discoverer_; |
| 61 |
52 Profile* profile_; | 62 Profile* profile_; |
53 scoped_refptr<ui::SelectFileDialog> select_file_dialog_; | 63 scoped_refptr<ui::SelectFileDialog> select_file_dialog_; |
54 std::string webui_callback_id_; | 64 std::string webui_callback_id_; |
55 | 65 |
56 base::WeakPtrFactory<CupsPrintersHandler> weak_factory_; | 66 base::WeakPtrFactory<CupsPrintersHandler> weak_factory_; |
57 | 67 |
58 DISALLOW_COPY_AND_ASSIGN(CupsPrintersHandler); | 68 DISALLOW_COPY_AND_ASSIGN(CupsPrintersHandler); |
59 }; | 69 }; |
60 | 70 |
61 } // namespace settings | 71 } // namespace settings |
62 } // namespace chromeos | 72 } // namespace chromeos |
63 | 73 |
64 #endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_CUPS_PRINTERS_HANDLER_H_ | 74 #endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_CUPS_PRINTERS_HANDLER_H_ |
OLD | NEW |