Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/speech/extension_api/tts_engine_extension_api.h" | 5 #include "chrome/browser/speech/extension_api/tts_engine_extension_api.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 227 extensions::ExtensionSystem::Get(profile)->extension_service(); | 227 extensions::ExtensionSystem::Get(profile)->extension_service(); |
| 228 DCHECK(extension_service); | 228 DCHECK(extension_service); |
| 229 extension_service->component_loader() | 229 extension_service->component_loader() |
| 230 ->AddChromeOsSpeechSynthesisExtension(); | 230 ->AddChromeOsSpeechSynthesisExtension(); |
| 231 return true; | 231 return true; |
| 232 #else | 232 #else |
| 233 return false; | 233 return false; |
| 234 #endif | 234 #endif |
| 235 } | 235 } |
| 236 | 236 |
| 237 Profile* TtsExtensionEngine::GetProfile(int render_process_id) { | |
| 238 content::RenderProcessHost* rph = | |
| 239 content::RenderProcessHost::FromID(render_process_id); | |
| 240 if (!rph) // Guard against race conditions on RPH lifetime. | |
| 241 return NULL; | |
| 242 | |
| 243 return Profile::FromBrowserContext(rph->GetBrowserContext()); | |
|
dmazzoni
2014/08/11 07:23:09
Perhaps converting from BrowserContext to Profile
mrunal
2014/08/11 23:25:07
What's wrong with keeping it here? I agree TtsExte
dmazzoni
2014/08/12 06:16:01
What's wrong is that this is an implementation of
| |
| 244 } | |
| 245 | |
| 237 bool ExtensionTtsEngineSendTtsEventFunction::RunSync() { | 246 bool ExtensionTtsEngineSendTtsEventFunction::RunSync() { |
| 238 int utterance_id; | 247 int utterance_id; |
| 239 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &utterance_id)); | 248 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &utterance_id)); |
| 240 | 249 |
| 241 base::DictionaryValue* event; | 250 base::DictionaryValue* event; |
| 242 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(1, &event)); | 251 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(1, &event)); |
| 243 | 252 |
| 244 std::string event_type; | 253 std::string event_type; |
| 245 EXTENSION_FUNCTION_VALIDATE( | 254 EXTENSION_FUNCTION_VALIDATE( |
| 246 event->GetString(constants::kEventTypeKey, &event_type)); | 255 event->GetString(constants::kEventTypeKey, &event_type)); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 298 utterance_id, TTS_EVENT_PAUSE, char_index, std::string()); | 307 utterance_id, TTS_EVENT_PAUSE, char_index, std::string()); |
| 299 } else if (event_type == constants::kEventTypeResume) { | 308 } else if (event_type == constants::kEventTypeResume) { |
| 300 controller->OnTtsEvent( | 309 controller->OnTtsEvent( |
| 301 utterance_id, TTS_EVENT_RESUME, char_index, std::string()); | 310 utterance_id, TTS_EVENT_RESUME, char_index, std::string()); |
| 302 } else { | 311 } else { |
| 303 EXTENSION_FUNCTION_VALIDATE(false); | 312 EXTENSION_FUNCTION_VALIDATE(false); |
| 304 } | 313 } |
| 305 | 314 |
| 306 return true; | 315 return true; |
| 307 } | 316 } |
| OLD | NEW |