b6234c067e24de0fc85742dccc7c18ab41ae1b89
[platform/framework/web/crosswalk.git] / src / chrome / browser / extensions / signin / gaia_auth_extension_loader.h
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_EXTENSIONS_SIGNIN_GAIA_AUTH_EXTENSION_LOADER_H_
6 #define CHROME_BROWSER_EXTENSIONS_SIGNIN_GAIA_AUTH_EXTENSION_LOADER_H_
7
8 #include "base/memory/scoped_ptr.h"
9 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h"
10
11 class Profile;
12
13 namespace extensions {
14
15 // Manages and registers the gaia auth extension with the extension system.
16 class GaiaAuthExtensionLoader : public ProfileKeyedAPI {
17  public:
18   explicit GaiaAuthExtensionLoader(Profile* profile);
19   virtual ~GaiaAuthExtensionLoader();
20
21   // Load the gaia auth extension if the extension is not loaded yet.
22   void LoadIfNeeded();
23   // Unload the gaia auth extension if no pending reference.
24   void UnloadIfNeeded();
25
26   static GaiaAuthExtensionLoader* Get(Profile* profile);
27
28   // ProfileKeyedAPI implementation.
29   static ProfileKeyedAPIFactory<GaiaAuthExtensionLoader>* GetFactoryInstance();
30
31  private:
32   friend class ProfileKeyedAPIFactory<GaiaAuthExtensionLoader>;
33
34   // ProfileKeyedAPI implementation.
35   static const char* service_name() {
36     return "GaiaAuthExtensionLoader";
37   }
38   static const bool kServiceRedirectedInIncognito = true;
39
40   Profile* profile_;
41   int load_count_;
42
43   DISALLOW_COPY_AND_ASSIGN(GaiaAuthExtensionLoader);
44 };
45
46 } // namespace extensions
47
48 #endif  // CHROME_BROWSER_EXTENSIONS_SIGNIN_GAIA_AUTH_EXTENSION_LOADER_H_