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

Side by Side Diff: chrome/browser/extensions/api/copresence/copresence_api.h

Issue 469883002: Using API key specified from js (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing API build Created 6 years, 4 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/api/copresence/copresence_api.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_API_COPRESENCE_COPRESENCE_API_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_COPRESENCE_COPRESENCE_API_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_COPRESENCE_COPRESENCE_API_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_COPRESENCE_COPRESENCE_API_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 25 matching lines...) Expand all
36 // These accessors will always return an object. If the object doesn't exist, 36 // These accessors will always return an object. If the object doesn't exist,
37 // they will create one first. 37 // they will create one first.
38 copresence::CopresenceClient* client(); 38 copresence::CopresenceClient* client();
39 copresence::WhispernetClient* whispernet_client(); 39 copresence::WhispernetClient* whispernet_client();
40 40
41 // A registry containing the app id's associated with every subscription. 41 // A registry containing the app id's associated with every subscription.
42 SubscriptionToAppMap& apps_by_subscription_id() { 42 SubscriptionToAppMap& apps_by_subscription_id() {
43 return apps_by_subscription_id_; 43 return apps_by_subscription_id_;
44 } 44 }
45 45
46 void set_api_key(const std::string& api_key) { api_key_ = api_key; }
47
46 // BrowserContextKeyedAPI implementation. 48 // BrowserContextKeyedAPI implementation.
47 static BrowserContextKeyedAPIFactory<CopresenceService>* GetFactoryInstance(); 49 static BrowserContextKeyedAPIFactory<CopresenceService>* GetFactoryInstance();
48 50
49 private: 51 private:
50 friend class BrowserContextKeyedAPIFactory<CopresenceService>; 52 friend class BrowserContextKeyedAPIFactory<CopresenceService>;
51 53
52 // CopresenceClientDelegate overrides: 54 // CopresenceClientDelegate overrides:
53 virtual void HandleMessages( 55 virtual void HandleMessages(
54 const std::string& app_id, 56 const std::string& app_id,
55 const std::string& subscription_id, 57 const std::string& subscription_id,
56 const std::vector<copresence::Message>& message) OVERRIDE; 58 const std::vector<copresence::Message>& message) OVERRIDE;
57 virtual net::URLRequestContextGetter* GetRequestContext() const OVERRIDE; 59 virtual net::URLRequestContextGetter* GetRequestContext() const OVERRIDE;
58 virtual const std::string GetPlatformVersionString() const OVERRIDE; 60 virtual const std::string GetPlatformVersionString() const OVERRIDE;
61 virtual const std::string GetAPIKey() const OVERRIDE;
59 virtual copresence::WhispernetClient* GetWhispernetClient() OVERRIDE; 62 virtual copresence::WhispernetClient* GetWhispernetClient() OVERRIDE;
60 63
61 // BrowserContextKeyedAPI implementation. 64 // BrowserContextKeyedAPI implementation.
62 static const char* service_name() { return "CopresenceService"; } 65 static const char* service_name() { return "CopresenceService"; }
63 66
64 bool is_shutting_down_; 67 bool is_shutting_down_;
65 std::map<std::string, std::string> apps_by_subscription_id_; 68 std::map<std::string, std::string> apps_by_subscription_id_;
66 69
67 content::BrowserContext* const browser_context_; 70 content::BrowserContext* const browser_context_;
71 std::string api_key_;
72
68 scoped_ptr<copresence::CopresenceClient> client_; 73 scoped_ptr<copresence::CopresenceClient> client_;
69 scoped_ptr<copresence::WhispernetClient> whispernet_client_; 74 scoped_ptr<copresence::WhispernetClient> whispernet_client_;
70 75
71 DISALLOW_COPY_AND_ASSIGN(CopresenceService); 76 DISALLOW_COPY_AND_ASSIGN(CopresenceService);
72 }; 77 };
73 78
74 template <> 79 template <>
75 void BrowserContextKeyedAPIFactory< 80 void BrowserContextKeyedAPIFactory<
76 CopresenceService>::DeclareFactoryDependencies(); 81 CopresenceService>::DeclareFactoryDependencies();
77 82
(...skipping 14 matching lines...) Expand all
92 DECLARE_EXTENSION_FUNCTION("copresence.setApiKey", COPRESENCE_SETAPIKEY); 97 DECLARE_EXTENSION_FUNCTION("copresence.setApiKey", COPRESENCE_SETAPIKEY);
93 98
94 protected: 99 protected:
95 virtual ~CopresenceSetApiKeyFunction() {} 100 virtual ~CopresenceSetApiKeyFunction() {}
96 virtual ExtensionFunction::ResponseAction Run() OVERRIDE; 101 virtual ExtensionFunction::ResponseAction Run() OVERRIDE;
97 }; 102 };
98 103
99 } // namespace extensions 104 } // namespace extensions
100 105
101 #endif // CHROME_BROWSER_EXTENSIONS_API_COPRESENCE_COPRESENCE_API_H_ 106 #endif // CHROME_BROWSER_EXTENSIONS_API_COPRESENCE_COPRESENCE_API_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/api/copresence/copresence_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698