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

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

Issue 800613002: Scoping auth tokens by app (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removing unnecessary checks for empty app ID Created 6 years 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 // These accessors will always return an object (except during shutdown). 42 // These accessors will always return an object (except during shutdown).
43 // If the object doesn't exist, they will create one first. 43 // If the object doesn't exist, they will create one first.
44 copresence::CopresenceManager* manager(); 44 copresence::CopresenceManager* manager();
45 copresence::WhispernetClient* whispernet_client(); 45 copresence::WhispernetClient* whispernet_client();
46 46
47 // A registry containing the app id's associated with every subscription. 47 // A registry containing the app id's associated with every subscription.
48 SubscriptionToAppMap& apps_by_subscription_id() { 48 SubscriptionToAppMap& apps_by_subscription_id() {
49 return apps_by_subscription_id_; 49 return apps_by_subscription_id_;
50 } 50 }
51 51
52 const std::string auth_token(const std::string& app_id) const;
53
52 void set_api_key(const std::string& app_id, 54 void set_api_key(const std::string& app_id,
53 const std::string& api_key); 55 const std::string& api_key);
54 56
55 std::string auth_token() const { 57 void set_auth_token(const std::string& app_id,
56 return auth_token_; 58 const std::string& token);
57 }
58
59 void set_auth_token(const std::string& token);
60 59
61 // Manager override for testing. 60 // Manager override for testing.
62 void set_manager_for_testing( 61 void set_manager_for_testing(
63 scoped_ptr<copresence::CopresenceManager> manager); 62 scoped_ptr<copresence::CopresenceManager> manager);
64 63
65 // BrowserContextKeyedAPI implementation. 64 // BrowserContextKeyedAPI implementation.
66 static BrowserContextKeyedAPIFactory<CopresenceService>* GetFactoryInstance(); 65 static BrowserContextKeyedAPIFactory<CopresenceService>* GetFactoryInstance();
67 66
68 private: 67 private:
69 friend class BrowserContextKeyedAPIFactory<CopresenceService>; 68 friend class BrowserContextKeyedAPIFactory<CopresenceService>;
70 69
71 // CopresenceDelegate implementation 70 // CopresenceDelegate implementation
72 void HandleMessages(const std::string& app_id, 71 void HandleMessages(const std::string& app_id,
73 const std::string& subscription_id, 72 const std::string& subscription_id,
74 const std::vector<copresence::Message>& message) override; 73 const std::vector<copresence::Message>& message) override;
75 void HandleStatusUpdate(copresence::CopresenceStatus status) override; 74 void HandleStatusUpdate(copresence::CopresenceStatus status) override;
76 net::URLRequestContextGetter* GetRequestContext() const override; 75 net::URLRequestContextGetter* GetRequestContext() const override;
77 const std::string GetPlatformVersionString() const override; 76 const std::string GetPlatformVersionString() const override;
78 const std::string GetAPIKey(const std::string& app_id) const override; 77 const std::string GetAPIKey(const std::string& app_id) const override;
79 copresence::WhispernetClient* GetWhispernetClient() override; 78 copresence::WhispernetClient* GetWhispernetClient() override;
80 gcm::GCMDriver* GetGCMDriver() override; 79 gcm::GCMDriver* GetGCMDriver() override;
81 80
82 // BrowserContextKeyedAPI implementation. 81 // BrowserContextKeyedAPI implementation.
83 static const char* service_name() { return "CopresenceService"; } 82 static const char* service_name() { return "CopresenceService"; }
84 83
85 bool is_shutting_down_; 84 bool is_shutting_down_;
85 content::BrowserContext* const browser_context_;
86
86 std::map<std::string, std::string> apps_by_subscription_id_; 87 std::map<std::string, std::string> apps_by_subscription_id_;
87 88
88 content::BrowserContext* const browser_context_;
89 std::map<std::string, std::string> api_keys_by_app_; 89 std::map<std::string, std::string> api_keys_by_app_;
90 90 std::map<std::string, std::string> auth_tokens_by_app_;
91 // TODO(ckehoe): This is a temporary hack.
92 // Auth tokens from different apps needs to be separated properly.
93 std::string auth_token_;
94 91
95 scoped_ptr<copresence::CopresenceManager> manager_; 92 scoped_ptr<copresence::CopresenceManager> manager_;
96 scoped_ptr<ChromeWhispernetClient> whispernet_client_; 93 scoped_ptr<ChromeWhispernetClient> whispernet_client_;
97 94
98 DISALLOW_COPY_AND_ASSIGN(CopresenceService); 95 DISALLOW_COPY_AND_ASSIGN(CopresenceService);
99 }; 96 };
100 97
101 template <> 98 template <>
102 void BrowserContextKeyedAPIFactory< 99 void BrowserContextKeyedAPIFactory<
103 CopresenceService>::DeclareFactoryDependencies(); 100 CopresenceService>::DeclareFactoryDependencies();
(...skipping 25 matching lines...) Expand all
129 COPRESENCE_SETAUTHTOKEN); 126 COPRESENCE_SETAUTHTOKEN);
130 127
131 protected: 128 protected:
132 virtual ~CopresenceSetAuthTokenFunction() {} 129 virtual ~CopresenceSetAuthTokenFunction() {}
133 ExtensionFunction::ResponseAction Run() override; 130 ExtensionFunction::ResponseAction Run() override;
134 }; 131 };
135 132
136 } // namespace extensions 133 } // namespace extensions
137 134
138 #endif // CHROME_BROWSER_EXTENSIONS_API_COPRESENCE_COPRESENCE_API_H_ 135 #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