| 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 #include "chrome/browser/extensions/api/copresence/copresence_api.h" | 5 #include "chrome/browser/extensions/api/copresence/copresence_api.h" |
| 6 | 6 |
| 7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "base/memory/linked_ptr.h" | 8 #include "base/memory/linked_ptr.h" |
| 9 #include "chrome/browser/copresence/chrome_whispernet_client.h" | 9 #include "chrome/browser/copresence/chrome_whispernet_client.h" |
| 10 #include "chrome/common/chrome_version_info.h" | 10 #include "chrome/common/chrome_version_info.h" |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 new Event(api::copresence::OnMessagesReceived::kEventName, | 108 new Event(api::copresence::OnMessagesReceived::kEventName, |
| 109 api::copresence::OnMessagesReceived::Create(subscription_id, | 109 api::copresence::OnMessagesReceived::Create(subscription_id, |
| 110 api_messages), | 110 api_messages), |
| 111 browser_context_)); | 111 browser_context_)); |
| 112 EventRouter::Get(browser_context_) | 112 EventRouter::Get(browser_context_) |
| 113 ->DispatchEventToExtension(app_id, event.Pass()); | 113 ->DispatchEventToExtension(app_id, event.Pass()); |
| 114 DVLOG(2) << "Passed " << api_messages.size() << " messages to app \"" | 114 DVLOG(2) << "Passed " << api_messages.size() << " messages to app \"" |
| 115 << app_id << "\" for subscription \"" << subscription_id << "\""; | 115 << app_id << "\" for subscription \"" << subscription_id << "\""; |
| 116 } | 116 } |
| 117 | 117 |
| 118 void CopresenceService::HandleStatusUpdate( |
| 119 copresence::CopresenceStatus status) { |
| 120 scoped_ptr<Event> event( |
| 121 new Event(api::copresence::OnStatusUpdated::kEventName, |
| 122 api::copresence::OnStatusUpdated::Create( |
| 123 api::copresence::STATUS_AUDIOFAILED), |
| 124 browser_context_)); |
| 125 EventRouter::Get(browser_context_)->BroadcastEvent(event.Pass()); |
| 126 DVLOG(2) << "Sent Audio Failed status update."; |
| 127 } |
| 128 |
| 118 net::URLRequestContextGetter* CopresenceService::GetRequestContext() const { | 129 net::URLRequestContextGetter* CopresenceService::GetRequestContext() const { |
| 119 return browser_context_->GetRequestContext(); | 130 return browser_context_->GetRequestContext(); |
| 120 } | 131 } |
| 121 | 132 |
| 122 const std::string CopresenceService::GetPlatformVersionString() const { | 133 const std::string CopresenceService::GetPlatformVersionString() const { |
| 123 return chrome::VersionInfo().CreateVersionString(); | 134 return chrome::VersionInfo().CreateVersionString(); |
| 124 } | 135 } |
| 125 | 136 |
| 126 const std::string CopresenceService::GetAPIKey(const std::string& app_id) | 137 const std::string CopresenceService::GetAPIKey(const std::string& app_id) |
| 127 const { | 138 const { |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 EXTENSION_FUNCTION_VALIDATE(params.get()); | 212 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 202 | 213 |
| 203 // The token may be set to empty, to clear it. | 214 // The token may be set to empty, to clear it. |
| 204 // TODO(ckehoe): Scope the auth token appropriately (crbug/423517). | 215 // TODO(ckehoe): Scope the auth token appropriately (crbug/423517). |
| 205 CopresenceService::GetFactoryInstance()->Get(browser_context()) | 216 CopresenceService::GetFactoryInstance()->Get(browser_context()) |
| 206 ->set_auth_token(params->token); | 217 ->set_auth_token(params->token); |
| 207 return RespondNow(NoArguments()); | 218 return RespondNow(NoArguments()); |
| 208 } | 219 } |
| 209 | 220 |
| 210 } // namespace extensions | 221 } // namespace extensions |
| OLD | NEW |