| 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 <memory> |
| 9 #include <string> | 10 #include <string> |
| 10 #include <vector> | 11 #include <vector> |
| 11 | 12 |
| 12 #include "base/macros.h" | 13 #include "base/macros.h" |
| 13 #include "base/memory/scoped_ptr.h" | |
| 14 #include "chrome/browser/extensions/api/copresence/copresence_translations.h" | 14 #include "chrome/browser/extensions/api/copresence/copresence_translations.h" |
| 15 #include "chrome/browser/extensions/chrome_extension_function.h" | 15 #include "chrome/browser/extensions/chrome_extension_function.h" |
| 16 #include "chrome/common/extensions/api/copresence.h" | 16 #include "chrome/common/extensions/api/copresence.h" |
| 17 #include "components/copresence/public/copresence_delegate.h" | 17 #include "components/copresence/public/copresence_delegate.h" |
| 18 #include "extensions/browser/browser_context_keyed_api_factory.h" | 18 #include "extensions/browser/browser_context_keyed_api_factory.h" |
| 19 | 19 |
| 20 class ChromeWhispernetClient; | 20 class ChromeWhispernetClient; |
| 21 | 21 |
| 22 namespace audio_modem { | 22 namespace audio_modem { |
| 23 class WhispernetClient; | 23 class WhispernetClient; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 std::unique_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 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 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 |
| 104 std::map<std::string, std::string> apps_by_subscription_id_; | 104 std::map<std::string, std::string> apps_by_subscription_id_; |
| 105 | 105 |
| 106 std::map<std::string, std::string> api_keys_by_app_; | 106 std::map<std::string, std::string> api_keys_by_app_; |
| 107 std::map<std::string, std::string> auth_tokens_by_app_; | 107 std::map<std::string, std::string> auth_tokens_by_app_; |
| 108 | 108 |
| 109 scoped_ptr<audio_modem::WhispernetClient> whispernet_client_; | 109 std::unique_ptr<audio_modem::WhispernetClient> whispernet_client_; |
| 110 scoped_ptr<copresence::CopresenceManager> manager_; | 110 std::unique_ptr<copresence::CopresenceManager> manager_; |
| 111 | 111 |
| 112 DISALLOW_COPY_AND_ASSIGN(CopresenceService); | 112 DISALLOW_COPY_AND_ASSIGN(CopresenceService); |
| 113 }; | 113 }; |
| 114 | 114 |
| 115 template <> | 115 template <> |
| 116 void BrowserContextKeyedAPIFactory< | 116 void BrowserContextKeyedAPIFactory< |
| 117 CopresenceService>::DeclareFactoryDependencies(); | 117 CopresenceService>::DeclareFactoryDependencies(); |
| 118 | 118 |
| 119 class CopresenceExecuteFunction : public ChromeUIThreadExtensionFunction { | 119 class CopresenceExecuteFunction : public ChromeUIThreadExtensionFunction { |
| 120 public: | 120 public: |
| (...skipping 23 matching lines...) Expand all 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 |