Index: chrome/browser/extensions/api/copresence_private/copresence_private_api.cc |
diff --git a/chrome/browser/extensions/api/copresence_private/copresence_private_api.cc b/chrome/browser/extensions/api/copresence_private/copresence_private_api.cc |
index 2dcc52e7d78e5967f86c666d1d3376f8dfbc9d72..72a54491b09840b2ecdb3fb54362de79ea34647d 100644 |
--- a/chrome/browser/extensions/api/copresence_private/copresence_private_api.cc |
+++ b/chrome/browser/extensions/api/copresence_private/copresence_private_api.cc |
@@ -7,27 +7,28 @@ |
#include "base/lazy_instance.h" |
#include "base/stl_util.h" |
#include "chrome/browser/copresence/chrome_whispernet_client.h" |
+#include "chrome/browser/extensions/api/copresence/copresence_api.h" |
#include "chrome/common/extensions/api/copresence_private.h" |
#include "components/copresence/public/whispernet_client.h" |
#include "media/base/audio_bus.h" |
namespace extensions { |
-// This code is only for testing while we don't have the rest of the |
-// CopresenceAPI service which will actually give us the whispernet client. |
-// Once we add that code, both the g_whispernet_client and the |
-// GetWhispernetClient function will go away, to be replaced by the |
-// GetWhispernetClient function that will fetch our active whispernet client |
-// from the CopresenceAPI profile keyed service. |
-copresence::WhispernetClient* g_whispernet_client = NULL; |
+namespace { |
+ |
+copresence::WhispernetClient* GetWhispernetClient( |
+ content::BrowserContext* browser_context) { |
+ extensions::CopresenceService* service = |
+ extensions::CopresenceService::GetFactoryInstance()->Get(browser_context); |
+ return service ? service->whispernet_client() : NULL; |
+} |
+ |
+} // namespace |
// Copresence Private functions. |
copresence::WhispernetClient* CopresencePrivateFunction::GetWhispernetClient() { |
- // This is temporary code, this needs to be replaced by the real |
- // GetWhispernetClient code from c/b/e/api/copresence/copresence_util.h |
- DCHECK(g_whispernet_client); |
- return g_whispernet_client; |
+ return extensions::GetWhispernetClient(browser_context()); |
} |
// CopresenceSendFoundFunction implementation: |
@@ -98,8 +99,4 @@ CopresencePrivateSendInitializedFunction::Run() { |
return RespondNow(NoArguments()); |
} |
-void SetWhispernetClientForTesting(copresence::WhispernetClient* client) { |
- g_whispernet_client = client; |
-} |
- |
} // namespace extensions |