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

Unified Diff: chrome/browser/extensions/api/copresence/copresence_api.h

Issue 671573003: Adding support for authenticated copresence calls (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Registering separately for authenticated calls Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/copresence/copresence_api.h
diff --git a/chrome/browser/extensions/api/copresence/copresence_api.h b/chrome/browser/extensions/api/copresence/copresence_api.h
index 6cf87a9afae5542a79104ba0fa5f46196960ce6c..7682f312d4cf1adcba9828d82451852e44d9e78d 100644
--- a/chrome/browser/extensions/api/copresence/copresence_api.h
+++ b/chrome/browser/extensions/api/copresence/copresence_api.h
@@ -45,7 +45,9 @@ class CopresenceService : public BrowserContextKeyedAPI,
return apps_by_subscription_id_;
}
- void set_api_key(const std::string& api_key) { api_key_ = api_key; }
+ void set_api_key(const std::string& app_id,
+ const std::string& api_key);
+ void set_auth_token(const std::string& token);
// Manager override for testing.
void set_manager_for_testing(
@@ -63,7 +65,8 @@ class CopresenceService : public BrowserContextKeyedAPI,
const std::vector<copresence::Message>& message) override;
net::URLRequestContextGetter* GetRequestContext() const override;
const std::string GetPlatformVersionString() const override;
- const std::string GetAPIKey() const override;
+ const std::string GetAPIKey(const std::string& app_id) const override;
+ const std::string GetAuthToken() const override;
copresence::WhispernetClient* GetWhispernetClient() override;
// BrowserContextKeyedAPI implementation.
@@ -73,7 +76,11 @@ class CopresenceService : public BrowserContextKeyedAPI,
std::map<std::string, std::string> apps_by_subscription_id_;
content::BrowserContext* const browser_context_;
- std::string api_key_;
+ std::map<std::string, std::string> api_keys_by_app_;
+
+ // TODO(ckehoe): This is a temporary hack.
+ // Auth tokens from different apps needs to be separated properly.
+ std::string auth_token_;
scoped_ptr<copresence::CopresenceManager> manager_;
scoped_ptr<ChromeWhispernetClient> whispernet_client_;
@@ -106,6 +113,16 @@ class CopresenceSetApiKeyFunction : public ChromeUIThreadExtensionFunction {
ExtensionFunction::ResponseAction Run() override;
};
+class CopresenceSetAuthTokenFunction : public ChromeUIThreadExtensionFunction {
+ public:
+ DECLARE_EXTENSION_FUNCTION("copresence.setAuthToken",
+ COPRESENCE_SETAUTHTOKEN);
+
+ protected:
+ virtual ~CopresenceSetAuthTokenFunction() {}
+ virtual ExtensionFunction::ResponseAction Run() override;
+};
+
} // namespace extensions
#endif // CHROME_BROWSER_EXTENSIONS_API_COPRESENCE_COPRESENCE_API_H_

Powered by Google App Engine
This is Rietveld 408576698