Home | History | Annotate | Download | only in extensions
      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.
      4 
      5 #ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_SCREENLOCK_PRIVATE_API_H_
      6 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_SCREENLOCK_PRIVATE_API_H_
      7 
      8 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h"
      9 #include "chrome/browser/extensions/chrome_extension_function.h"
     10 #include "chromeos/dbus/session_manager_client.h"
     11 
     12 namespace extensions {
     13 
     14 class ScreenlockPrivateGetLockedFunction : public ChromeAsyncExtensionFunction {
     15  public:
     16   DECLARE_EXTENSION_FUNCTION("screenlockPrivate.getLocked",
     17                              SCREENLOCKPRIVATE_GETLOCKED)
     18   ScreenlockPrivateGetLockedFunction();
     19   virtual bool RunImpl() OVERRIDE;
     20  private:
     21   virtual ~ScreenlockPrivateGetLockedFunction();
     22   DISALLOW_COPY_AND_ASSIGN(ScreenlockPrivateGetLockedFunction);
     23 };
     24 
     25 class ScreenlockPrivateSetLockedFunction : public ChromeAsyncExtensionFunction {
     26  public:
     27   DECLARE_EXTENSION_FUNCTION("screenlockPrivate.setLocked",
     28                              SCREENLOCKPRIVATE_SETLOCKED)
     29   ScreenlockPrivateSetLockedFunction();
     30   virtual bool RunImpl() OVERRIDE;
     31  private:
     32   virtual ~ScreenlockPrivateSetLockedFunction();
     33   DISALLOW_COPY_AND_ASSIGN(ScreenlockPrivateSetLockedFunction);
     34 };
     35 
     36 class ScreenlockPrivateShowMessageFunction
     37     : public ChromeAsyncExtensionFunction {
     38  public:
     39   DECLARE_EXTENSION_FUNCTION("screenlockPrivate.showMessage",
     40                              SCREENLOCKPRIVATE_SHOWMESSAGE)
     41   ScreenlockPrivateShowMessageFunction();
     42   virtual bool RunImpl() OVERRIDE;
     43  private:
     44   virtual ~ScreenlockPrivateShowMessageFunction();
     45   DISALLOW_COPY_AND_ASSIGN(ScreenlockPrivateShowMessageFunction );
     46 };
     47 
     48 class ScreenlockPrivateEventRouter
     49     : public extensions::ProfileKeyedAPI,
     50       public chromeos::SessionManagerClient::Observer {
     51  public:
     52   explicit ScreenlockPrivateEventRouter(Profile* profile);
     53   virtual ~ScreenlockPrivateEventRouter();
     54   virtual void ScreenIsLocked() OVERRIDE;
     55   virtual void ScreenIsUnlocked() OVERRIDE;
     56 
     57   // ProfileKeyedAPI
     58   static extensions::ProfileKeyedAPIFactory<ScreenlockPrivateEventRouter>*
     59     GetFactoryInstance();
     60   virtual void Shutdown() OVERRIDE;
     61 
     62  private:
     63   friend class extensions::ProfileKeyedAPIFactory<ScreenlockPrivateEventRouter>;
     64 
     65   // ProfileKeyedAPI
     66   static const char* service_name() {
     67     return "ScreenlockPrivateEventRouter";
     68   }
     69   static const bool kServiceIsNULLWhileTesting = true;
     70   static const bool kServiceRedirectedInIncognito = true;
     71 
     72   void DispatchEvent(const std::string& event_name, base::Value* arg);
     73 
     74   Profile* profile_;
     75   DISALLOW_COPY_AND_ASSIGN(ScreenlockPrivateEventRouter);
     76 };
     77 
     78 }  // namespace extensions
     79 
     80 #endif  // CHROME_BROWSER_CHROMEOS_EXTENSIONS_SCREENLOCK_PRIVATE_API_H_
     81