OLD | NEW |
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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 namespace extensions { | 81 namespace extensions { |
82 | 82 |
83 // One of these is constructed for each utterance, and deleted | 83 // One of these is constructed for each utterance, and deleted |
84 // when the utterance gets any final event. | 84 // when the utterance gets any final event. |
85 class TtsExtensionEventHandler | 85 class TtsExtensionEventHandler |
86 : public UtteranceEventDelegate, | 86 : public UtteranceEventDelegate, |
87 public base::SupportsWeakPtr<TtsExtensionEventHandler> { | 87 public base::SupportsWeakPtr<TtsExtensionEventHandler> { |
88 public: | 88 public: |
89 explicit TtsExtensionEventHandler(const std::string& src_extension_id); | 89 explicit TtsExtensionEventHandler(const std::string& src_extension_id); |
90 | 90 |
91 virtual void OnTtsEvent(Utterance* utterance, | 91 void OnTtsEvent(Utterance* utterance, |
92 TtsEventType event_type, | 92 TtsEventType event_type, |
93 int char_index, | 93 int char_index, |
94 const std::string& error_message) override; | 94 const std::string& error_message) override; |
95 | 95 |
96 private: | 96 private: |
97 // The extension ID of the extension that called speak() and should | 97 // The extension ID of the extension that called speak() and should |
98 // receive events. | 98 // receive events. |
99 std::string src_extension_id_; | 99 std::string src_extension_id_; |
100 }; | 100 }; |
101 | 101 |
102 TtsExtensionEventHandler::TtsExtensionEventHandler( | 102 TtsExtensionEventHandler::TtsExtensionEventHandler( |
103 const std::string& src_extension_id) | 103 const std::string& src_extension_id) |
104 : src_extension_id_(src_extension_id) { | 104 : src_extension_id_(src_extension_id) { |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 } | 371 } |
372 | 372 |
373 static base::LazyInstance<BrowserContextKeyedAPIFactory<TtsAPI> > g_factory = | 373 static base::LazyInstance<BrowserContextKeyedAPIFactory<TtsAPI> > g_factory = |
374 LAZY_INSTANCE_INITIALIZER; | 374 LAZY_INSTANCE_INITIALIZER; |
375 | 375 |
376 BrowserContextKeyedAPIFactory<TtsAPI>* TtsAPI::GetFactoryInstance() { | 376 BrowserContextKeyedAPIFactory<TtsAPI>* TtsAPI::GetFactoryInstance() { |
377 return g_factory.Pointer(); | 377 return g_factory.Pointer(); |
378 } | 378 } |
379 | 379 |
380 } // namespace extensions | 380 } // namespace extensions |
OLD | NEW |