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.
5 #ifndef CHROME_BROWSER_EXTENSIONS_SIGNIN_GAIA_AUTH_EXTENSION_LOADER_H_
6 #define CHROME_BROWSER_EXTENSIONS_SIGNIN_GAIA_AUTH_EXTENSION_LOADER_H_
11 #include "base/macros.h"
12 #include "extensions/browser/browser_context_keyed_api_factory.h"
18 namespace extensions
{
20 const char kGaiaAuthExtensionId
[] = "mfffpogegjflfpflabcdkioaeobkgjik";
21 const char kGaiaAuthExtensionOrigin
[] =
22 "chrome-extension://mfffpogegjflfpflabcdkioaeobkgjik";
24 // Manages and registers the gaia auth extension with the extension system.
25 class GaiaAuthExtensionLoader
: public BrowserContextKeyedAPI
{
27 explicit GaiaAuthExtensionLoader(content::BrowserContext
* context
);
28 ~GaiaAuthExtensionLoader() override
;
30 // Load the gaia auth extension if the extension is not loaded yet.
32 // Unload the gaia auth extension if no pending reference.
33 void UnloadIfNeeded();
35 // Add a string data for gaia auth extension. Returns an ID that
36 // could be used to get the data. All strings are cleared when gaia auth
38 int AddData(const std::string
& data
);
40 // Get data for the given ID. Returns true if the data is found and
41 // its value is copied to |data|. Otherwise, returns false.
42 bool GetData(int data_id
, std::string
* data
);
44 static GaiaAuthExtensionLoader
* Get(content::BrowserContext
* context
);
46 // BrowserContextKeyedAPI implementation.
47 static BrowserContextKeyedAPIFactory
<GaiaAuthExtensionLoader
>*
51 friend class BrowserContextKeyedAPIFactory
<GaiaAuthExtensionLoader
>;
53 // KeyedService overrides:
54 void Shutdown() override
;
56 // BrowserContextKeyedAPI implementation.
57 static const char* service_name() {
58 return "GaiaAuthExtensionLoader";
60 static const bool kServiceRedirectedInIncognito
= true;
62 content::BrowserContext
* browser_context_
;
66 std::map
<int, std::string
> data_
;
68 DISALLOW_COPY_AND_ASSIGN(GaiaAuthExtensionLoader
);
71 } // namespace extensions
73 #endif // CHROME_BROWSER_EXTENSIONS_SIGNIN_GAIA_AUTH_EXTENSION_LOADER_H_