Home | History | Annotate | Download | only in cloud_print_private
      1 // Copyright (c) 2012 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_EXTENSIONS_API_CLOUD_PRINT_PRIVATE_CLOUD_PRINT_PRIVATE_API_H_
      6 #define CHROME_BROWSER_EXTENSIONS_API_CLOUD_PRINT_PRIVATE_CLOUD_PRINT_PRIVATE_API_H_
      7 
      8 #include <string>
      9 #include <vector>
     10 
     11 #include "chrome/browser/extensions/chrome_extension_function.h"
     12 
     13 namespace extensions {
     14 
     15 namespace api {
     16 namespace cloud_print_private {
     17 
     18 struct UserSettings;
     19 
     20 }  // namespace cloud_print_private
     21 }  // namespace api
     22 
     23 
     24 // For use only in tests.
     25 class CloudPrintTestsDelegate {
     26  public:
     27   CloudPrintTestsDelegate();
     28   virtual ~CloudPrintTestsDelegate();
     29 
     30   virtual void SetupConnector(
     31       const std::string& user_email,
     32       const std::string& robot_email,
     33       const std::string& credentials,
     34       const api::cloud_print_private::UserSettings& user_settings) = 0;
     35 
     36   virtual std::string GetHostName() = 0;
     37 
     38   virtual std::string GetClientId() = 0;
     39 
     40   virtual std::vector<std::string> GetPrinters() = 0;
     41 
     42   static CloudPrintTestsDelegate* instance();
     43 
     44  private:
     45   // Points to single instance of this class during testing.
     46   static CloudPrintTestsDelegate* instance_;
     47 };
     48 
     49 class CloudPrintPrivateSetupConnectorFunction
     50     : public ChromeAsyncExtensionFunction {
     51  public:
     52   DECLARE_EXTENSION_FUNCTION("cloudPrintPrivate.setupConnector",
     53                              CLOUDPRINTPRIVATE_SETUPCONNECTOR)
     54 
     55   CloudPrintPrivateSetupConnectorFunction();
     56 
     57  protected:
     58   virtual ~CloudPrintPrivateSetupConnectorFunction();
     59 
     60   // ExtensionFunction:
     61   virtual bool RunAsync() OVERRIDE;
     62 };
     63 
     64 class CloudPrintPrivateGetHostNameFunction
     65     : public ChromeAsyncExtensionFunction {
     66  public:
     67   DECLARE_EXTENSION_FUNCTION("cloudPrintPrivate.getHostName",
     68                              CLOUDPRINTPRIVATE_GETHOSTNAME)
     69 
     70   CloudPrintPrivateGetHostNameFunction();
     71 
     72  protected:
     73   virtual ~CloudPrintPrivateGetHostNameFunction();
     74 
     75   // ExtensionFunction:
     76   virtual bool RunAsync() OVERRIDE;
     77 };
     78 
     79 class CloudPrintPrivateGetPrintersFunction
     80     : public ChromeAsyncExtensionFunction {
     81  public:
     82   DECLARE_EXTENSION_FUNCTION("cloudPrintPrivate.getPrinters",
     83                              CLOUDPRINTPRIVATE_GETPRINTERS)
     84 
     85   CloudPrintPrivateGetPrintersFunction();
     86 
     87  protected:
     88   virtual ~CloudPrintPrivateGetPrintersFunction();
     89 
     90  private:
     91   void SendResults(const std::vector<std::string>& printers);
     92 
     93   // ExtensionFunction:
     94   virtual bool RunAsync() OVERRIDE;
     95 };
     96 
     97 class CloudPrintPrivateGetClientIdFunction
     98     : public ChromeAsyncExtensionFunction {
     99  public:
    100   DECLARE_EXTENSION_FUNCTION("cloudPrintPrivate.getClientId",
    101                              CLOUDPRINTPRIVATE_GETCLIENTID);
    102 
    103   CloudPrintPrivateGetClientIdFunction();
    104 
    105  protected:
    106   virtual ~CloudPrintPrivateGetClientIdFunction();
    107 
    108   // ExtensionFunction:
    109   virtual bool RunAsync() OVERRIDE;
    110 };
    111 
    112 }  // namespace extensions
    113 
    114 #endif  // CHROME_BROWSER_EXTENSIONS_API_CLOUD_PRINT_PRIVATE_CLOUD_PRINT_PRIVATE_API_H_
    115