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

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

Issue 2898383002: [Extensions] Make Event::restrict_to_browser_context const. (Closed)
Patch Set: sync @tott Created 3 years, 6 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_extension_api.h" 5 #include "chrome/browser/speech/extension_api/tts_extension_api.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 details->SetString(constants::kEventTypeKey, event_type_string); 133 details->SetString(constants::kEventTypeKey, event_type_string);
134 if (event_type == TTS_EVENT_ERROR) { 134 if (event_type == TTS_EVENT_ERROR) {
135 details->SetString(constants::kErrorMessageKey, error_message); 135 details->SetString(constants::kErrorMessageKey, error_message);
136 } 136 }
137 details->SetInteger(constants::kSrcIdKey, utterance->src_id()); 137 details->SetInteger(constants::kSrcIdKey, utterance->src_id());
138 details->SetBoolean(constants::kIsFinalEventKey, utterance->finished()); 138 details->SetBoolean(constants::kIsFinalEventKey, utterance->finished());
139 139
140 std::unique_ptr<base::ListValue> arguments(new base::ListValue()); 140 std::unique_ptr<base::ListValue> arguments(new base::ListValue());
141 arguments->Append(std::move(details)); 141 arguments->Append(std::move(details));
142 142
143 std::unique_ptr<extensions::Event> event( 143 auto event = base::MakeUnique<extensions::Event>(
144 new extensions::Event(::extensions::events::TTS_ON_EVENT, 144 ::extensions::events::TTS_ON_EVENT, ::events::kOnEvent,
145 ::events::kOnEvent, std::move(arguments))); 145 std::move(arguments), utterance->browser_context());
146 event->restrict_to_browser_context = utterance->browser_context();
147 event->event_url = utterance->src_url(); 146 event->event_url = utterance->src_url();
148 extensions::EventRouter::Get(utterance->browser_context()) 147 extensions::EventRouter::Get(utterance->browser_context())
149 ->DispatchEventToExtension(src_extension_id_, std::move(event)); 148 ->DispatchEventToExtension(src_extension_id_, std::move(event));
150 149
151 if (utterance->finished()) 150 if (utterance->finished())
152 delete this; 151 delete this;
153 } 152 }
154 153
155 bool TtsSpeakFunction::RunAsync() { 154 bool TtsSpeakFunction::RunAsync() {
156 std::string text; 155 std::string text;
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 368
370 static base::LazyInstance< 369 static base::LazyInstance<
371 BrowserContextKeyedAPIFactory<TtsAPI>>::DestructorAtExit g_factory = 370 BrowserContextKeyedAPIFactory<TtsAPI>>::DestructorAtExit g_factory =
372 LAZY_INSTANCE_INITIALIZER; 371 LAZY_INSTANCE_INITIALIZER;
373 372
374 BrowserContextKeyedAPIFactory<TtsAPI>* TtsAPI::GetFactoryInstance() { 373 BrowserContextKeyedAPIFactory<TtsAPI>* TtsAPI::GetFactoryInstance() {
375 return g_factory.Pointer(); 374 return g_factory.Pointer();
376 } 375 }
377 376
378 } // namespace extensions 377 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/speech/extension_api/tts_engine_extension_api.cc ('k') | chrome/browser/ui/ash/chrome_keyboard_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698