a0a8df9487787d962da1093eac0fb9389475fcef
[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 "extensions/browser/browser_context_keyed_api_factory.h"
10
11 namespace content {
12 class BrowserContext;
13 }
14
15 namespace extensions {
16
17 // Manages and registers the gaia auth extension with the extension system.
18 class GaiaAuthExtensionLoader : public BrowserContextKeyedAPI {
19  public:
20   explicit GaiaAuthExtensionLoader(content::BrowserContext* context);
21   virtual ~GaiaAuthExtensionLoader();
22
23   // Load the gaia auth extension if the extension is not loaded yet.
24   void LoadIfNeeded();
25   // Unload the gaia auth extension if no pending reference.
26   void UnloadIfNeeded();
27
28   static GaiaAuthExtensionLoader* Get(content::BrowserContext* context);
29
30   // BrowserContextKeyedAPI implementation.
31   static BrowserContextKeyedAPIFactory<GaiaAuthExtensionLoader>*
32       GetFactoryInstance();
33
34  private:
35   friend class BrowserContextKeyedAPIFactory<GaiaAuthExtensionLoader>;
36
37   // KeyedService overrides:
38   virtual void Shutdown() OVERRIDE;
39
40   // BrowserContextKeyedAPI implementation.
41   static const char* service_name() {
42     return "GaiaAuthExtensionLoader";
43   }
44   static const bool kServiceRedirectedInIncognito = true;
45
46   content::BrowserContext* browser_context_;
47   int load_count_;
48
49   DISALLOW_COPY_AND_ASSIGN(GaiaAuthExtensionLoader);
50 };
51
52 } // namespace extensions
53
54 #endif  // CHROME_BROWSER_EXTENSIONS_SIGNIN_GAIA_AUTH_EXTENSION_LOADER_H_