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

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

Issue 1201063002: Set up the infrastructure for Extension event metrics. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebaaaaase Created 5 years, 5 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
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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 if (!options->HasKey(constants::kLangKey)) 187 if (!options->HasKey(constants::kLangKey))
188 options->SetString(constants::kLangKey, voice.lang); 188 options->SetString(constants::kLangKey, voice.lang);
189 189
190 args->Append(options.release()); 190 args->Append(options.release());
191 args->AppendInteger(utterance->id()); 191 args->AppendInteger(utterance->id());
192 192
193 std::string json; 193 std::string json;
194 base::JSONWriter::Write(*args, &json); 194 base::JSONWriter::Write(*args, &json);
195 195
196 scoped_ptr<extensions::Event> event(new extensions::Event( 196 scoped_ptr<extensions::Event> event(new extensions::Event(
197 tts_engine_events::kOnSpeak, args.Pass())); 197 extensions::events::UNKNOWN, tts_engine_events::kOnSpeak, args.Pass()));
198 Profile* profile = Profile::FromBrowserContext(utterance->browser_context()); 198 Profile* profile = Profile::FromBrowserContext(utterance->browser_context());
199 event->restrict_to_browser_context = profile; 199 event->restrict_to_browser_context = profile;
200 EventRouter::Get(profile) 200 EventRouter::Get(profile)
201 ->DispatchEventToExtension(utterance->extension_id(), event.Pass()); 201 ->DispatchEventToExtension(utterance->extension_id(), event.Pass());
202 } 202 }
203 203
204 void TtsExtensionEngine::Stop(Utterance* utterance) { 204 void TtsExtensionEngine::Stop(Utterance* utterance) {
205 scoped_ptr<base::ListValue> args(new base::ListValue()); 205 scoped_ptr<base::ListValue> args(new base::ListValue());
206 scoped_ptr<extensions::Event> event(new extensions::Event( 206 scoped_ptr<extensions::Event> event(new extensions::Event(
207 tts_engine_events::kOnStop, args.Pass())); 207 extensions::events::UNKNOWN, tts_engine_events::kOnStop, args.Pass()));
208 Profile* profile = Profile::FromBrowserContext(utterance->browser_context()); 208 Profile* profile = Profile::FromBrowserContext(utterance->browser_context());
209 event->restrict_to_browser_context = profile; 209 event->restrict_to_browser_context = profile;
210 EventRouter::Get(profile) 210 EventRouter::Get(profile)
211 ->DispatchEventToExtension(utterance->extension_id(), event.Pass()); 211 ->DispatchEventToExtension(utterance->extension_id(), event.Pass());
212 } 212 }
213 213
214 void TtsExtensionEngine::Pause(Utterance* utterance) { 214 void TtsExtensionEngine::Pause(Utterance* utterance) {
215 scoped_ptr<base::ListValue> args(new base::ListValue()); 215 scoped_ptr<base::ListValue> args(new base::ListValue());
216 scoped_ptr<extensions::Event> event(new extensions::Event( 216 scoped_ptr<extensions::Event> event(new extensions::Event(
217 tts_engine_events::kOnPause, args.Pass())); 217 extensions::events::UNKNOWN, tts_engine_events::kOnPause, args.Pass()));
218 Profile* profile = Profile::FromBrowserContext(utterance->browser_context()); 218 Profile* profile = Profile::FromBrowserContext(utterance->browser_context());
219 event->restrict_to_browser_context = profile; 219 event->restrict_to_browser_context = profile;
220 EventRouter* event_router = EventRouter::Get(profile); 220 EventRouter* event_router = EventRouter::Get(profile);
221 std::string id = utterance->extension_id(); 221 std::string id = utterance->extension_id();
222 event_router->DispatchEventToExtension(id, event.Pass()); 222 event_router->DispatchEventToExtension(id, event.Pass());
223 WarnIfMissingPauseOrResumeListener(profile, event_router, id); 223 WarnIfMissingPauseOrResumeListener(profile, event_router, id);
224 } 224 }
225 225
226 void TtsExtensionEngine::Resume(Utterance* utterance) { 226 void TtsExtensionEngine::Resume(Utterance* utterance) {
227 scoped_ptr<base::ListValue> args(new base::ListValue()); 227 scoped_ptr<base::ListValue> args(new base::ListValue());
228 scoped_ptr<extensions::Event> event(new extensions::Event( 228 scoped_ptr<extensions::Event> event(new extensions::Event(
229 tts_engine_events::kOnResume, args.Pass())); 229 extensions::events::UNKNOWN, tts_engine_events::kOnResume, args.Pass()));
230 Profile* profile = Profile::FromBrowserContext(utterance->browser_context()); 230 Profile* profile = Profile::FromBrowserContext(utterance->browser_context());
231 event->restrict_to_browser_context = profile; 231 event->restrict_to_browser_context = profile;
232 EventRouter* event_router = EventRouter::Get(profile); 232 EventRouter* event_router = EventRouter::Get(profile);
233 std::string id = utterance->extension_id(); 233 std::string id = utterance->extension_id();
234 event_router->DispatchEventToExtension(id, event.Pass()); 234 event_router->DispatchEventToExtension(id, event.Pass());
235 WarnIfMissingPauseOrResumeListener(profile, event_router, id); 235 WarnIfMissingPauseOrResumeListener(profile, event_router, id);
236 } 236 }
237 237
238 bool TtsExtensionEngine::LoadBuiltInTtsExtension( 238 bool TtsExtensionEngine::LoadBuiltInTtsExtension(
239 content::BrowserContext* browser_context) { 239 content::BrowserContext* browser_context) {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 utterance_id, TTS_EVENT_PAUSE, char_index, std::string()); 321 utterance_id, TTS_EVENT_PAUSE, char_index, std::string());
322 } else if (event_type == constants::kEventTypeResume) { 322 } else if (event_type == constants::kEventTypeResume) {
323 controller->OnTtsEvent( 323 controller->OnTtsEvent(
324 utterance_id, TTS_EVENT_RESUME, char_index, std::string()); 324 utterance_id, TTS_EVENT_RESUME, char_index, std::string());
325 } else { 325 } else {
326 EXTENSION_FUNCTION_VALIDATE(false); 326 EXTENSION_FUNCTION_VALIDATE(false);
327 } 327 }
328 328
329 return true; 329 return true;
330 } 330 }
OLDNEW
« no previous file with comments | « chrome/browser/signin/easy_unlock_service_regular.cc ('k') | chrome/browser/speech/extension_api/tts_extension_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698