| OLD | NEW |
| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 | 49 |
| 50 // These accessors will always return an object (except during shutdown). | 50 // These accessors will always return an object (except during shutdown). |
| 51 // If the object doesn't exist, they will create one first. | 51 // If the object doesn't exist, they will create one first. |
| 52 copresence::CopresenceManager* manager(); | 52 copresence::CopresenceManager* manager(); |
| 53 | 53 |
| 54 // A registry containing the app id's associated with every subscription. | 54 // A registry containing the app id's associated with every subscription. |
| 55 SubscriptionToAppMap& apps_by_subscription_id() { | 55 SubscriptionToAppMap& apps_by_subscription_id() { |
| 56 return apps_by_subscription_id_; | 56 return apps_by_subscription_id_; |
| 57 } | 57 } |
| 58 | 58 |
| 59 const std::string auth_token(const std::string& app_id) const; | 59 std::string auth_token(const std::string& app_id) const; |
| 60 | 60 |
| 61 void set_api_key(const std::string& app_id, | 61 void set_api_key(const std::string& app_id, |
| 62 const std::string& api_key); | 62 const std::string& api_key); |
| 63 | 63 |
| 64 void set_auth_token(const std::string& app_id, | 64 void set_auth_token(const std::string& app_id, |
| 65 const std::string& token); | 65 const std::string& token); |
| 66 | 66 |
| 67 // Delete all current copresence data, including stored device IDs. | 67 // Delete all current copresence data, including stored device IDs. |
| 68 void ResetState(); | 68 void ResetState(); |
| 69 | 69 |
| 70 // Manager override for testing. | 70 // Manager override for testing. |
| 71 void set_manager_for_testing( | 71 void set_manager_for_testing( |
| 72 scoped_ptr<copresence::CopresenceManager> manager); | 72 scoped_ptr<copresence::CopresenceManager> manager); |
| 73 | 73 |
| 74 // Registers the preference for saving our device IDs. | 74 // Registers the preference for saving our device IDs. |
| 75 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 75 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
| 76 | 76 |
| 77 // BrowserContextKeyedAPI implementation. | 77 // BrowserContextKeyedAPI implementation. |
| 78 static BrowserContextKeyedAPIFactory<CopresenceService>* GetFactoryInstance(); | 78 static BrowserContextKeyedAPIFactory<CopresenceService>* GetFactoryInstance(); |
| 79 | 79 |
| 80 private: | 80 private: |
| 81 friend class BrowserContextKeyedAPIFactory<CopresenceService>; | 81 friend class BrowserContextKeyedAPIFactory<CopresenceService>; |
| 82 | 82 |
| 83 // CopresenceDelegate implementation | 83 // CopresenceDelegate implementation |
| 84 void HandleMessages(const std::string& app_id, | 84 void HandleMessages(const std::string& app_id, |
| 85 const std::string& subscription_id, | 85 const std::string& subscription_id, |
| 86 const std::vector<copresence::Message>& message) override; | 86 const std::vector<copresence::Message>& message) override; |
| 87 void HandleStatusUpdate(copresence::CopresenceStatus status) override; | 87 void HandleStatusUpdate(copresence::CopresenceStatus status) override; |
| 88 net::URLRequestContextGetter* GetRequestContext() const override; | 88 net::URLRequestContextGetter* GetRequestContext() const override; |
| 89 const std::string GetPlatformVersionString() const override; | 89 std::string GetPlatformVersionString() const override; |
| 90 const std::string GetAPIKey(const std::string& app_id) const override; | 90 std::string GetAPIKey(const std::string& app_id) const override; |
| 91 audio_modem::WhispernetClient* GetWhispernetClient() override; | 91 audio_modem::WhispernetClient* GetWhispernetClient() override; |
| 92 gcm::GCMDriver* GetGCMDriver() override; | 92 gcm::GCMDriver* GetGCMDriver() override; |
| 93 const std::string GetDeviceId(bool authenticated) override; | 93 std::string GetDeviceId(bool authenticated) override; |
| 94 void SaveDeviceId(bool authenticated, const std::string& device_id) override; | 94 void SaveDeviceId(bool authenticated, const std::string& device_id) override; |
| 95 | 95 |
| 96 // BrowserContextKeyedAPI implementation. | 96 // BrowserContextKeyedAPI implementation. |
| 97 static const char* service_name() { return "CopresenceService"; } | 97 static const char* service_name() { return "CopresenceService"; } |
| 98 | 98 |
| 99 PrefService* GetPrefService(); | 99 PrefService* GetPrefService(); |
| 100 | 100 |
| 101 bool is_shutting_down_; | 101 bool is_shutting_down_; |
| 102 content::BrowserContext* const browser_context_; | 102 content::BrowserContext* const browser_context_; |
| 103 | 103 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 COPRESENCE_SETAUTHTOKEN); | 144 COPRESENCE_SETAUTHTOKEN); |
| 145 | 145 |
| 146 protected: | 146 protected: |
| 147 ~CopresenceSetAuthTokenFunction() override {} | 147 ~CopresenceSetAuthTokenFunction() override {} |
| 148 ExtensionFunction::ResponseAction Run() override; | 148 ExtensionFunction::ResponseAction Run() override; |
| 149 }; | 149 }; |
| 150 | 150 |
| 151 } // namespace extensions | 151 } // namespace extensions |
| 152 | 152 |
| 153 #endif // CHROME_BROWSER_EXTENSIONS_API_COPRESENCE_COPRESENCE_API_H_ | 153 #endif // CHROME_BROWSER_EXTENSIONS_API_COPRESENCE_COPRESENCE_API_H_ |
| OLD | NEW |