| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "core/page/SpeechInput.h" | 32 #include "core/speech/SpeechInput.h" |
| 33 | 33 |
| 34 #if ENABLE(INPUT_SPEECH) | 34 #if ENABLE(INPUT_SPEECH) |
| 35 | 35 |
| 36 #include "core/page/SpeechInputClient.h" | 36 #include "core/speech/SpeechInputClient.h" |
| 37 #include "core/page/SpeechInputListener.h" | 37 #include "core/speech/SpeechInputListener.h" |
| 38 #include "wtf/PassOwnPtr.h" | 38 #include "wtf/PassOwnPtr.h" |
| 39 | 39 |
| 40 namespace WebCore { | 40 namespace WebCore { |
| 41 | 41 |
| 42 SpeechInput::SpeechInput(SpeechInputClient* client) | 42 SpeechInput::SpeechInput(SpeechInputClient* client) |
| 43 : m_client(client) | 43 : m_client(client) |
| 44 , m_nextListenerId(1) | 44 , m_nextListenerId(1) |
| 45 { | 45 { |
| 46 m_client->setListener(this); | 46 m_client->setListener(this); |
| 47 } | 47 } |
| 48 | 48 |
| 49 SpeechInput::~SpeechInput() | 49 SpeechInput::~SpeechInput() |
| 50 { | 50 { |
| 51 m_client->setListener(0); | 51 m_client->setListener(0); |
| 52 } | 52 } |
| 53 | 53 |
| 54 PassOwnPtr<SpeechInput> SpeechInput::create(SpeechInputClient* client) | 54 PassOwnPtr<SpeechInput> SpeechInput::create(SpeechInputClient* client) |
| 55 { | 55 { |
| 56 return adoptPtr(new SpeechInput(client)); | 56 return adoptPtr(new SpeechInput(client)); |
| 57 } | 57 } |
| 58 | 58 |
| 59 int SpeechInput::registerListener(SpeechInputListener* listener) | 59 int SpeechInput::registerListener(SpeechInputListener* listener) |
| 60 { | 60 { |
| 61 #if defined(DEBUG) | 61 #if defined(DEBUG) |
| 62 // Check if already present. | 62 // Check if already present. |
| 63 for (HashMap<int, SpeechInputListener*>::iterator it = m_listeners.begin();
it != m_listeners.end(); ++it) | 63 for (HashMap<int, SpeechInputListener*>::iterator it = m_listeners.begin();
it != m_listeners.end(); ++it) |
| 64 ASSERT(it->value != listener); | 64 ASSERT(it->value != listener); |
| 65 #endif | 65 #endif |
| 66 | 66 |
| 67 m_listeners.add(m_nextListenerId, listener); | 67 m_listeners.add(m_nextListenerId, listener); |
| 68 return m_nextListenerId++; | 68 return m_nextListenerId++; |
| 69 } | 69 } |
| 70 | 70 |
| 71 void SpeechInput::unregisterListener(int listenerId) | 71 void SpeechInput::unregisterListener(int listenerId) |
| 72 { | 72 { |
| 73 if (m_listeners.contains(listenerId)) | 73 if (m_listeners.contains(listenerId)) |
| 74 m_listeners.remove(listenerId); | 74 m_listeners.remove(listenerId); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 } | 122 } |
| 123 | 123 |
| 124 void provideSpeechInputTo(Page* page, SpeechInputClient* client) | 124 void provideSpeechInputTo(Page* page, SpeechInputClient* client) |
| 125 { | 125 { |
| 126 SpeechInput::provideTo(page, SpeechInput::supplementName(), SpeechInput::cre
ate(client)); | 126 SpeechInput::provideTo(page, SpeechInput::supplementName(), SpeechInput::cre
ate(client)); |
| 127 } | 127 } |
| 128 | 128 |
| 129 } // namespace WebCore | 129 } // namespace WebCore |
| 130 | 130 |
| 131 #endif // ENABLE(INPUT_SPEECH) | 131 #endif // ENABLE(INPUT_SPEECH) |
| OLD | NEW |