Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(279)

Side by Side Diff: chrome/browser/speech/extension_api/tts_engine_extension_api.cc

Issue 10896021: Fix crash caused when speech is generated at Chrome OS startup before ExtensionService is initializ… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 bool GetMatchingExtensionVoice( 92 bool GetMatchingExtensionVoice(
93 Utterance* utterance, 93 Utterance* utterance,
94 const Extension** matching_extension, 94 const Extension** matching_extension,
95 size_t* voice_index) { 95 size_t* voice_index) {
96 // This will only happen during unit testing. Otherwise, an utterance 96 // This will only happen during unit testing. Otherwise, an utterance
97 // will always have an associated profile. 97 // will always have an associated profile.
98 if (!utterance->profile()) 98 if (!utterance->profile())
99 return false; 99 return false;
100 100
101 ExtensionService* service = utterance->profile()->GetExtensionService(); 101 ExtensionService* service = utterance->profile()->GetExtensionService();
102 DCHECK(service); 102
103 // If speech is generated when Chrome OS first starts up, it's possible
104 // the extension service isn't even available.
105 if (!service)
106 return false;
107
103 extensions::EventRouter* event_router = 108 extensions::EventRouter* event_router =
104 utterance->profile()->GetExtensionEventRouter(); 109 utterance->profile()->GetExtensionEventRouter();
105 DCHECK(event_router); 110 DCHECK(event_router);
106 111
107 *matching_extension = NULL; 112 *matching_extension = NULL;
108 *voice_index = -1; 113 *voice_index = -1;
109 const ExtensionSet* extensions = service->extensions(); 114 const ExtensionSet* extensions = service->extensions();
110 ExtensionSet::const_iterator iter; 115 ExtensionSet::const_iterator iter;
111 116
112 // Make two passes: the first time, do strict language matching 117 // Make two passes: the first time, do strict language matching
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 std::string error_message; 287 std::string error_message;
283 event->GetString(constants::kErrorMessageKey, &error_message); 288 event->GetString(constants::kErrorMessageKey, &error_message);
284 controller->OnTtsEvent( 289 controller->OnTtsEvent(
285 utterance_id, TTS_EVENT_ERROR, char_index, error_message); 290 utterance_id, TTS_EVENT_ERROR, char_index, error_message);
286 } else { 291 } else {
287 EXTENSION_FUNCTION_VALIDATE(false); 292 EXTENSION_FUNCTION_VALIDATE(false);
288 } 293 }
289 294
290 return true; 295 return true;
291 } 296 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698