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

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

Issue 257333002: Drive extension functions from ExtensionFunction::Run. The (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase, fix test Created 6 years, 7 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
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 <string> 7 #include <string>
8 8
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 new extensions::Event(events::kOnEvent, arguments.Pass())); 128 new extensions::Event(events::kOnEvent, arguments.Pass()));
129 event->restrict_to_browser_context = utterance->profile(); 129 event->restrict_to_browser_context = utterance->profile();
130 event->event_url = utterance->src_url(); 130 event->event_url = utterance->src_url();
131 extensions::EventRouter::Get(utterance->profile()) 131 extensions::EventRouter::Get(utterance->profile())
132 ->DispatchEventToExtension(utterance->src_extension_id(), event.Pass()); 132 ->DispatchEventToExtension(utterance->src_extension_id(), event.Pass());
133 133
134 if (utterance->finished()) 134 if (utterance->finished())
135 delete this; 135 delete this;
136 } 136 }
137 137
138 bool TtsSpeakFunction::RunImpl() { 138 bool TtsSpeakFunction::RunAsync() {
139 std::string text; 139 std::string text;
140 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &text)); 140 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &text));
141 if (text.size() > 32768) { 141 if (text.size() > 32768) {
142 error_ = constants::kErrorUtteranceTooLong; 142 error_ = constants::kErrorUtteranceTooLong;
143 return false; 143 return false;
144 } 144 }
145 145
146 scoped_ptr<base::DictionaryValue> options(new base::DictionaryValue()); 146 scoped_ptr<base::DictionaryValue> options(new base::DictionaryValue());
147 if (args_->GetSize() >= 2) { 147 if (args_->GetSize() >= 2) {
148 base::DictionaryValue* temp_options = NULL; 148 base::DictionaryValue* temp_options = NULL;
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 } 356 }
357 357
358 static base::LazyInstance<BrowserContextKeyedAPIFactory<TtsAPI> > g_factory = 358 static base::LazyInstance<BrowserContextKeyedAPIFactory<TtsAPI> > g_factory =
359 LAZY_INSTANCE_INITIALIZER; 359 LAZY_INSTANCE_INITIALIZER;
360 360
361 BrowserContextKeyedAPIFactory<TtsAPI>* TtsAPI::GetFactoryInstance() { 361 BrowserContextKeyedAPIFactory<TtsAPI>* TtsAPI::GetFactoryInstance() {
362 return g_factory.Pointer(); 362 return g_factory.Pointer();
363 } 363 }
364 364
365 } // namespace extensions 365 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698