Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(32)

Side by Side Diff: chrome/browser/extensions/signin/gaia_auth_extension_loader.h

Issue 902493003: cros: Pass gaia_auth init params via postMessage. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/extensions/signin/gaia_auth_extension_loader.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_EXTENSIONS_SIGNIN_GAIA_AUTH_EXTENSION_LOADER_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_SIGNIN_GAIA_AUTH_EXTENSION_LOADER_H_
6 #define CHROME_BROWSER_EXTENSIONS_SIGNIN_GAIA_AUTH_EXTENSION_LOADER_H_ 6 #define CHROME_BROWSER_EXTENSIONS_SIGNIN_GAIA_AUTH_EXTENSION_LOADER_H_
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include <map>
9 #include <string>
10
9 #include "extensions/browser/browser_context_keyed_api_factory.h" 11 #include "extensions/browser/browser_context_keyed_api_factory.h"
10 12
11 namespace content { 13 namespace content {
12 class BrowserContext; 14 class BrowserContext;
13 } 15 }
14 16
15 namespace extensions { 17 namespace extensions {
16 18
17 const char kGaiaAuthExtensionId[] = "mfffpogegjflfpflabcdkioaeobkgjik"; 19 const char kGaiaAuthExtensionId[] = "mfffpogegjflfpflabcdkioaeobkgjik";
18 const char kGaiaAuthExtensionOrigin[] = 20 const char kGaiaAuthExtensionOrigin[] =
19 "chrome-extension://mfffpogegjflfpflabcdkioaeobkgjik"; 21 "chrome-extension://mfffpogegjflfpflabcdkioaeobkgjik";
20 22
21 // Manages and registers the gaia auth extension with the extension system. 23 // Manages and registers the gaia auth extension with the extension system.
22 class GaiaAuthExtensionLoader : public BrowserContextKeyedAPI { 24 class GaiaAuthExtensionLoader : public BrowserContextKeyedAPI {
23 public: 25 public:
24 explicit GaiaAuthExtensionLoader(content::BrowserContext* context); 26 explicit GaiaAuthExtensionLoader(content::BrowserContext* context);
25 ~GaiaAuthExtensionLoader() override; 27 ~GaiaAuthExtensionLoader() override;
26 28
27 // Load the gaia auth extension if the extension is not loaded yet. 29 // Load the gaia auth extension if the extension is not loaded yet.
28 void LoadIfNeeded(); 30 void LoadIfNeeded();
29 // Unload the gaia auth extension if no pending reference. 31 // Unload the gaia auth extension if no pending reference.
30 void UnloadIfNeeded(); 32 void UnloadIfNeeded();
31 33
34 // Add a string data for gaia_auth extension. Returns an Id that
Yoyo Zhou 2015/02/04 23:24:15 nit: this is called "gaia auth" rather than "gaia_
xiyuan 2015/02/05 03:57:41 Done.
35 // could be used get the data. All strings are cleared when gaia auth
Yoyo Zhou 2015/02/04 23:24:16 nit: used to
xiyuan 2015/02/05 03:57:41 Done.
36 // is unloaded.
37 int AddData(const std::string& data);
38
39 // Get data for the given id. Returns true if the data is found and
Yoyo Zhou 2015/02/04 23:24:16 Be consistent here ("ID")
xiyuan 2015/02/05 03:57:41 Done.
40 // its value is copied to |data|. Otherwise, returns false.
41 bool GetData(int data_id, std::string* data);
42
32 static GaiaAuthExtensionLoader* Get(content::BrowserContext* context); 43 static GaiaAuthExtensionLoader* Get(content::BrowserContext* context);
33 44
34 // BrowserContextKeyedAPI implementation. 45 // BrowserContextKeyedAPI implementation.
35 static BrowserContextKeyedAPIFactory<GaiaAuthExtensionLoader>* 46 static BrowserContextKeyedAPIFactory<GaiaAuthExtensionLoader>*
36 GetFactoryInstance(); 47 GetFactoryInstance();
37 48
38 private: 49 private:
39 friend class BrowserContextKeyedAPIFactory<GaiaAuthExtensionLoader>; 50 friend class BrowserContextKeyedAPIFactory<GaiaAuthExtensionLoader>;
40 51
41 // KeyedService overrides: 52 // KeyedService overrides:
42 void Shutdown() override; 53 void Shutdown() override;
43 54
44 // BrowserContextKeyedAPI implementation. 55 // BrowserContextKeyedAPI implementation.
45 static const char* service_name() { 56 static const char* service_name() {
46 return "GaiaAuthExtensionLoader"; 57 return "GaiaAuthExtensionLoader";
47 } 58 }
48 static const bool kServiceRedirectedInIncognito = true; 59 static const bool kServiceRedirectedInIncognito = true;
49 60
50 content::BrowserContext* browser_context_; 61 content::BrowserContext* browser_context_;
51 int load_count_; 62 int load_count_;
52 63
64 int last_data_id_;
65 std::map<int, std::string> data_;
66
53 DISALLOW_COPY_AND_ASSIGN(GaiaAuthExtensionLoader); 67 DISALLOW_COPY_AND_ASSIGN(GaiaAuthExtensionLoader);
Yoyo Zhou 2015/02/04 23:24:16 #include "base/macros.h" for this
xiyuan 2015/02/05 03:57:41 Done.
54 }; 68 };
55 69
56 } // namespace extensions 70 } // namespace extensions
57 71
58 #endif // CHROME_BROWSER_EXTENSIONS_SIGNIN_GAIA_AUTH_EXTENSION_LOADER_H_ 72 #endif // CHROME_BROWSER_EXTENSIONS_SIGNIN_GAIA_AUTH_EXTENSION_LOADER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/signin/gaia_auth_extension_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698