| 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 <memory> |    8 #include <memory> | 
|    9 #include <string> |    9 #include <string> | 
|   10 #include <vector> |   10 #include <vector> | 
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   42   void OnJavascriptAllowed() override {} |   42   void OnJavascriptAllowed() override {} | 
|   43   void OnJavascriptDisallowed() override {} |   43   void OnJavascriptDisallowed() override {} | 
|   44  |   44  | 
|   45  private: |   45  private: | 
|   46   // Gets all CUPS printers and return it to WebUI. |   46   // Gets all CUPS printers and return it to WebUI. | 
|   47   void HandleGetCupsPrintersList(const base::ListValue* args); |   47   void HandleGetCupsPrintersList(const base::ListValue* args); | 
|   48   void HandleUpdateCupsPrinter(const base::ListValue* args); |   48   void HandleUpdateCupsPrinter(const base::ListValue* args); | 
|   49   void HandleRemoveCupsPrinter(const base::ListValue* args); |   49   void HandleRemoveCupsPrinter(const base::ListValue* args); | 
|   50  |   50  | 
|   51   void HandleAddCupsPrinter(const base::ListValue* args); |   51   void HandleAddCupsPrinter(const base::ListValue* args); | 
|   52   void OnAddedPrinter(std::unique_ptr<Printer> printer, bool success); |   52   void OnAddedPrinter(std::unique_ptr<Printer> printer, int32_t result); | 
|   53   void OnAddPrinterError(); |   53   void OnAddPrinterError(); | 
|   54  |   54  | 
|   55   // Get a list of all manufacturers for which we have at least one model of |   55   // Get a list of all manufacturers for which we have at least one model of | 
|   56   // printer supported.  Takes one argument, the callback id for the result. |   56   // printer supported.  Takes one argument, the callback id for the result. | 
|   57   // The callback will be invoked with {success: <boolean>, models: |   57   // The callback will be invoked with {success: <boolean>, models: | 
|   58   // <Array<string>>}. |   58   // <Array<string>>}. | 
|   59   void HandleGetCupsPrinterManufacturers(const base::ListValue* args); |   59   void HandleGetCupsPrinterManufacturers(const base::ListValue* args); | 
|   60  |   60  | 
|   61   // Given a manufacturer, get a list of all models of printers for which we can |   61   // Given a manufacturer, get a list of all models of printers for which we can | 
|   62   // get drivers.  Takes two arguments - the callback id and the manufacturer |   62   // get drivers.  Takes two arguments - the callback id and the manufacturer | 
|   63   // name for which we want to list models.  The callback will be called with |   63   // name for which we want to list models.  The callback will be called with | 
|   64   // {success: <boolean>, models: Array<string>}. |   64   // {success: <boolean>, models: Array<string>}. | 
|   65   void HandleGetCupsPrinterModels(const base::ListValue* args); |   65   void HandleGetCupsPrinterModels(const base::ListValue* args); | 
|   66  |   66  | 
|   67   void HandleSelectPPDFile(const base::ListValue* args); |   67   void HandleSelectPPDFile(const base::ListValue* args); | 
|   68  |   68  | 
|   69   // PpdProvider callback handlers. |   69   // PpdProvider callback handlers. | 
|   70   void QueryAvailableManufacturersDone( |   70   void ResolveManufacturersDone( | 
|   71       const std::string& js_callback, |   71       const std::string& js_callback, | 
|   72       chromeos::printing::PpdProvider::CallbackResultCode result_code, |   72       chromeos::printing::PpdProvider::CallbackResultCode result_code, | 
|   73       const chromeos::printing::PpdProvider::AvailablePrintersMap& available); |   73       const std::vector<std::string>& available); | 
|   74   void QueryAvailableModelsDone( |   74   void ResolvePrintersDone( | 
|   75       const std::string& js_callback, |   75       const std::string& js_callback, | 
|   76       const std::string& manufacturer, |  | 
|   77       chromeos::printing::PpdProvider::CallbackResultCode result_code, |   76       chromeos::printing::PpdProvider::CallbackResultCode result_code, | 
|   78       const chromeos::printing::PpdProvider::AvailablePrintersMap& available); |   77       const std::vector<std::string>& available); | 
|   79  |   78  | 
|   80   // ui::SelectFileDialog::Listener override: |   79   // ui::SelectFileDialog::Listener override: | 
|   81   void FileSelected(const base::FilePath& path, |   80   void FileSelected(const base::FilePath& path, | 
|   82                     int index, |   81                     int index, | 
|   83                     void* params) override; |   82                     void* params) override; | 
|   84  |   83  | 
|   85   void HandleStartDiscovery(const base::ListValue* args); |   84   void HandleStartDiscovery(const base::ListValue* args); | 
|   86   void HandleStopDiscovery(const base::ListValue* args); |   85   void HandleStopDiscovery(const base::ListValue* args); | 
|   87  |   86  | 
|   88   // chromeos::PrinterDiscoverer::Observer override: |   87   // chromeos::PrinterDiscoverer::Observer override: | 
|   89   void OnPrintersFound(const std::vector<Printer>& printers) override; |   88   void OnPrintersFound(const std::vector<Printer>& printers) override; | 
|   90   void OnDiscoveryDone() override; |   89   void OnDiscoveryDone() override; | 
|   91  |   90  | 
|   92   // Invokes debugd to add the printer to CUPS.  If |ipp_everywhere| is true, |   91   // Invokes debugd to add the printer to CUPS.  If |ipp_everywhere| is true, | 
|   93   // automatic configuration will be attempted  and |ppd_path| is ignored. |   92   // automatic configuration will be attempted  and |ppd_path| is ignored. | 
|   94   // |ppd_path| is the path to a Postscript Printer Description file that will |   93   // |ppd_path| is the path to a Postscript Printer Description file that will | 
|   95   // be used to configure the printer capabilities.  This file must be in |   94   // be used to configure the printer capabilities.  This file must be in | 
|   96   // Downloads or the PPD Cache. |   95   // Downloads or the PPD Cache. | 
|   97   void AddPrinterToCups(std::unique_ptr<Printer> printer, |   96   void AddPrinterToCups(std::unique_ptr<Printer> printer, | 
|   98                         const base::FilePath& ppd_path, |   97                         const base::FilePath& ppd_path, | 
|   99                         bool ipp_everywhere); |   98                         bool ipp_everywhere); | 
|  100  |   99  | 
|  101   // Callback for PpdProvider::ResolveCallback. |  100   // Callback for PpdProvider::ResolveCallback. | 
|  102   void OnPPDResolved(std::unique_ptr<Printer> printer, |  101   void ResolvePpdDone(std::unique_ptr<Printer> printer, | 
|  103                      printing::PpdProvider::CallbackResultCode result, |  102                       printing::PpdProvider::CallbackResultCode result, | 
|  104                      base::FilePath ppd_path); |  103                       const std::string& ppd_contents); | 
|  105  |  104  | 
|  106   std::unique_ptr<chromeos::PrinterDiscoverer> printer_discoverer_; |  105   std::unique_ptr<chromeos::PrinterDiscoverer> printer_discoverer_; | 
|  107   std::unique_ptr<chromeos::printing::PpdProvider> ppd_provider_; |  106   scoped_refptr<chromeos::printing::PpdProvider> ppd_provider_; | 
|  108  |  107  | 
|  109   Profile* profile_; |  108   Profile* profile_; | 
|  110   scoped_refptr<ui::SelectFileDialog> select_file_dialog_; |  109   scoped_refptr<ui::SelectFileDialog> select_file_dialog_; | 
|  111   std::string webui_callback_id_; |  110   std::string webui_callback_id_; | 
|  112  |  111  | 
|  113   base::WeakPtrFactory<CupsPrintersHandler> weak_factory_; |  112   base::WeakPtrFactory<CupsPrintersHandler> weak_factory_; | 
|  114  |  113  | 
|  115   DISALLOW_COPY_AND_ASSIGN(CupsPrintersHandler); |  114   DISALLOW_COPY_AND_ASSIGN(CupsPrintersHandler); | 
|  116 }; |  115 }; | 
|  117  |  116  | 
|  118 }  // namespace settings |  117 }  // namespace settings | 
|  119 }  // namespace chromeos |  118 }  // namespace chromeos | 
|  120  |  119  | 
|  121 #endif  // CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_CUPS_PRINTERS_HANDLER_H_ |  120 #endif  // CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_CUPS_PRINTERS_HANDLER_H_ | 
| OLD | NEW |