Commit e5dbc82e authored by dmazzoni's avatar dmazzoni Committed by Commit bot

Get rid of src_extension_id from TtsController.

TtsController doesn't need to know about it.

BUG=347045

Review URL: https://codereview.chromium.org/625503002

Cr-Commit-Position: refs/heads/master@{#300538}
parent ba10dbe7
......@@ -86,12 +86,24 @@ class TtsExtensionEventHandler
: public UtteranceEventDelegate,
public base::SupportsWeakPtr<TtsExtensionEventHandler> {
public:
explicit TtsExtensionEventHandler(const std::string& src_extension_id);
virtual void OnTtsEvent(Utterance* utterance,
TtsEventType event_type,
int char_index,
const std::string& error_message) override;
private:
// The extension ID of the extension that called speak() and should
// receive events.
std::string src_extension_id_;
};
TtsExtensionEventHandler::TtsExtensionEventHandler(
const std::string& src_extension_id)
: src_extension_id_(src_extension_id) {
}
void TtsExtensionEventHandler::OnTtsEvent(Utterance* utterance,
TtsEventType event_type,
int char_index,
......@@ -130,7 +142,7 @@ void TtsExtensionEventHandler::OnTtsEvent(Utterance* utterance,
event->restrict_to_browser_context = utterance->browser_context();
event->event_url = utterance->src_url();
extensions::EventRouter::Get(utterance->browser_context())
->DispatchEventToExtension(utterance->src_extension_id(), event.Pass());
->DispatchEventToExtension(src_extension_id_, event.Pass());
if (utterance->finished())
delete this;
......@@ -267,7 +279,6 @@ bool TtsSpeakFunction::RunAsync() {
Utterance* utterance = new Utterance(GetProfile());
utterance->set_text(text);
utterance->set_voice_name(voice_name);
utterance->set_src_extension_id(extension_id());
utterance->set_src_id(src_id);
utterance->set_src_url(source_url());
utterance->set_lang(lang);
......@@ -279,7 +290,7 @@ bool TtsSpeakFunction::RunAsync() {
utterance->set_extension_id(voice_extension_id);
utterance->set_options(options.get());
utterance->set_event_delegate(
(new TtsExtensionEventHandler())->AsWeakPtr());
(new TtsExtensionEventHandler(extension_id()))->AsWeakPtr());
TtsController* controller = TtsController::GetInstance();
controller->SpeakOrEnqueue(utterance);
......
......@@ -151,11 +151,6 @@ class Utterance {
void set_options(const base::Value* options);
const base::Value* options() const { return options_.get(); }
void set_src_extension_id(const std::string& src_extension_id) {
src_extension_id_ = src_extension_id;
}
const std::string& src_extension_id() { return src_extension_id_; }
void set_src_id(int src_id) { src_id_ = src_id; }
int src_id() { return src_id_; }
......@@ -242,10 +237,6 @@ class Utterance {
// other than the ones we explicitly parse, below.
scoped_ptr<base::Value> options_;
// The extension ID of the extension that called speak() and should
// receive events.
std::string src_extension_id_;
// The source extension's ID of this utterance, so that it can associate
// events with the appropriate callback.
int src_id_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment