| 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 "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "chrome/browser/copresence/chrome_whispernet_client.h" | 10 #include "chrome/browser/copresence/chrome_whispernet_client.h" |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 api_messages[m].reset(new api::copresence::Message); | 141 api_messages[m].reset(new api::copresence::Message); |
| 142 api_messages[m]->type = messages[m].type().type(); | 142 api_messages[m]->type = messages[m].type().type(); |
| 143 api_messages[m]->payload.assign(messages[m].payload().begin(), | 143 api_messages[m]->payload.assign(messages[m].payload().begin(), |
| 144 messages[m].payload().end()); | 144 messages[m].payload().end()); |
| 145 DVLOG(2) << "Dispatching message of type " << api_messages[m]->type << ":\n" | 145 DVLOG(2) << "Dispatching message of type " << api_messages[m]->type << ":\n" |
| 146 << messages[m].payload(); | 146 << messages[m].payload(); |
| 147 } | 147 } |
| 148 | 148 |
| 149 // Send the messages to the client app. | 149 // Send the messages to the client app. |
| 150 scoped_ptr<Event> event( | 150 scoped_ptr<Event> event( |
| 151 new Event(OnMessagesReceived::kEventName, | 151 new Event(events::UNKNOWN, OnMessagesReceived::kEventName, |
| 152 OnMessagesReceived::Create(subscription_id, api_messages), | 152 OnMessagesReceived::Create(subscription_id, api_messages), |
| 153 browser_context_)); | 153 browser_context_)); |
| 154 EventRouter::Get(browser_context_) | 154 EventRouter::Get(browser_context_) |
| 155 ->DispatchEventToExtension(app_id, event.Pass()); | 155 ->DispatchEventToExtension(app_id, event.Pass()); |
| 156 DVLOG(2) << "Passed " << api_messages.size() << " messages to app \"" | 156 DVLOG(2) << "Passed " << api_messages.size() << " messages to app \"" |
| 157 << app_id << "\" for subscription \"" << subscription_id << "\""; | 157 << app_id << "\" for subscription \"" << subscription_id << "\""; |
| 158 } | 158 } |
| 159 | 159 |
| 160 void CopresenceService::HandleStatusUpdate( | 160 void CopresenceService::HandleStatusUpdate( |
| 161 copresence::CopresenceStatus status) { | 161 copresence::CopresenceStatus status) { |
| 162 DCHECK_EQ(copresence::AUDIO_FAIL, status); | 162 DCHECK_EQ(copresence::AUDIO_FAIL, status); |
| 163 scoped_ptr<Event> event( | 163 scoped_ptr<Event> event( |
| 164 new Event(OnStatusUpdated::kEventName, | 164 new Event(events::UNKNOWN, OnStatusUpdated::kEventName, |
| 165 OnStatusUpdated::Create(api::copresence::STATUS_AUDIOFAILED), | 165 OnStatusUpdated::Create(api::copresence::STATUS_AUDIOFAILED), |
| 166 browser_context_)); | 166 browser_context_)); |
| 167 EventRouter::Get(browser_context_)->BroadcastEvent(event.Pass()); | 167 EventRouter::Get(browser_context_)->BroadcastEvent(event.Pass()); |
| 168 DVLOG(2) << "Sent Audio Failed status update."; | 168 DVLOG(2) << "Sent Audio Failed status update."; |
| 169 } | 169 } |
| 170 | 170 |
| 171 net::URLRequestContextGetter* CopresenceService::GetRequestContext() const { | 171 net::URLRequestContextGetter* CopresenceService::GetRequestContext() const { |
| 172 return browser_context_->GetRequestContext(); | 172 return browser_context_->GetRequestContext(); |
| 173 } | 173 } |
| 174 | 174 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 scoped_ptr<SetAuthToken::Params> params(SetAuthToken::Params::Create(*args_)); | 294 scoped_ptr<SetAuthToken::Params> params(SetAuthToken::Params::Create(*args_)); |
| 295 EXTENSION_FUNCTION_VALIDATE(params.get()); | 295 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 296 | 296 |
| 297 // The token may be set to empty, to clear it. | 297 // The token may be set to empty, to clear it. |
| 298 CopresenceService::GetFactoryInstance()->Get(browser_context()) | 298 CopresenceService::GetFactoryInstance()->Get(browser_context()) |
| 299 ->set_auth_token(extension_id(), params->token); | 299 ->set_auth_token(extension_id(), params->token); |
| 300 return RespondNow(NoArguments()); | 300 return RespondNow(NoArguments()); |
| 301 } | 301 } |
| 302 | 302 |
| 303 } // namespace extensions | 303 } // namespace extensions |
| OLD | NEW |