Switch global error menu icon to vectorized MD asset
[chromium-blink-merge.git] / chrome / browser / extensions / signin / gaia_auth_extension_loader.h
blobb16b9dab276002eb6aea286c8fb56bdc5604b161
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_
8 #include <map>
9 #include <string>
11 #include "base/macros.h"
12 #include "base/memory/weak_ptr.h"
13 #include "extensions/browser/browser_context_keyed_api_factory.h"
15 namespace content {
16 class BrowserContext;
19 namespace extensions {
21 const char kGaiaAuthExtensionId[] = "mfffpogegjflfpflabcdkioaeobkgjik";
22 const char kGaiaAuthExtensionOrigin[] =
23 "chrome-extension://mfffpogegjflfpflabcdkioaeobkgjik";
25 // Manages and registers the gaia auth extension with the extension system.
26 class GaiaAuthExtensionLoader : public BrowserContextKeyedAPI {
27 public:
28 explicit GaiaAuthExtensionLoader(content::BrowserContext* context);
29 ~GaiaAuthExtensionLoader() override;
31 // Load the gaia auth extension if the extension is not loaded yet.
32 void LoadIfNeeded();
33 // Unload the gaia auth extension if no pending reference.
34 void UnloadIfNeeded();
35 void UnloadIfNeededAsync();
37 // Add a string data for gaia auth extension. Returns an ID that
38 // could be used to get the data. All strings are cleared when gaia auth
39 // is unloaded.
40 int AddData(const std::string& data);
42 // Get data for the given ID. Returns true if the data is found and
43 // its value is copied to |data|. Otherwise, returns false.
44 bool GetData(int data_id, std::string* data);
46 static GaiaAuthExtensionLoader* Get(content::BrowserContext* context);
48 // BrowserContextKeyedAPI implementation.
49 static BrowserContextKeyedAPIFactory<GaiaAuthExtensionLoader>*
50 GetFactoryInstance();
52 private:
53 friend class BrowserContextKeyedAPIFactory<GaiaAuthExtensionLoader>;
55 // KeyedService overrides:
56 void Shutdown() override;
58 // BrowserContextKeyedAPI implementation.
59 static const char* service_name() {
60 return "GaiaAuthExtensionLoader";
62 static const bool kServiceRedirectedInIncognito = true;
64 content::BrowserContext* browser_context_;
65 int load_count_;
67 int last_data_id_;
68 std::map<int, std::string> data_;
70 base::WeakPtrFactory<GaiaAuthExtensionLoader> weak_ptr_factory_;
72 DISALLOW_COPY_AND_ASSIGN(GaiaAuthExtensionLoader);
75 } // namespace extensions
77 #endif // CHROME_BROWSER_EXTENSIONS_SIGNIN_GAIA_AUTH_EXTENSION_LOADER_H_