Chromium Code Reviews| Index: chrome/browser/speech/tts_message_filter.cc |
| diff --git a/chrome/browser/spellchecker/spellcheck_message_filter.cc b/chrome/browser/speech/tts_message_filter.cc |
| similarity index 68% |
| copy from chrome/browser/spellchecker/spellcheck_message_filter.cc |
| copy to chrome/browser/speech/tts_message_filter.cc |
| index dd328a53252f518a8e549ebef23b7548f4911573..7e55151c5cec288ae51f34c88f85d698b6bd44cd 100644 |
| --- a/chrome/browser/spellchecker/spellcheck_message_filter.cc |
| +++ b/chrome/browser/speech/tts_message_filter.cc |
| @@ -1,26 +1,18 @@ |
| -// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
|
tommi (sloooow) - chröme
2013/03/07 13:04:46
I think that a decision was made to not change the
hans
2013/03/09 14:19:52
something is weird here.. it seems this is a new f
|
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#include "chrome/browser/spellchecker/spellcheck_message_filter.h" |
| +#include "chrome/browser/speech/tts_message_filter.h" |
| #include "base/bind.h" |
| -#include "base/prefs/pref_service.h" |
| #include "chrome/browser/profiles/profile.h" |
| -#include "chrome/browser/spellchecker/spellcheck_factory.h" |
| -#include "chrome/browser/spellchecker/spellcheck_host_metrics.h" |
| -#include "chrome/browser/spellchecker/spellcheck_service.h" |
| -#include "chrome/browser/spellchecker/spelling_service_client.h" |
| -#include "chrome/common/pref_names.h" |
| -#include "chrome/common/spellcheck_messages.h" |
| +#include "chrome/common/spellcheck_messages.h" ///////////// |
|
tommi (sloooow) - chröme
2013/03/07 13:04:46
remove ///////?
|
| #include "content/public/browser/render_process_host.h" |
| -#include "net/url_request/url_fetcher.h" |
| using content::BrowserThread; |
| -SpellCheckMessageFilter::SpellCheckMessageFilter(int render_process_id) |
| - : render_process_id_(render_process_id), |
| - client_(new SpellingServiceClient) |
| +TtsMessageFilter::TtsMessageFilter(int render_process_id) |
| + : render_process_id_(render_process_id) |
| #if !defined(OS_MACOSX) |
| , |
| route_id_(0), |
| @@ -29,7 +21,7 @@ SpellCheckMessageFilter::SpellCheckMessageFilter(int render_process_id) |
| { |
| } |
| -void SpellCheckMessageFilter::OverrideThreadForMessage( |
| +void TtsMessageFilter::OverrideThreadForMessage( |
| const IPC::Message& message, BrowserThread::ID* thread) { |
| if (message.type() == SpellCheckHostMsg_RequestDictionary::ID || |
|
hans
2013/03/09 14:19:52
what's up with all the SpellCheck stuff here? am I
dmazzoni
2013/03/19 17:30:22
Sorry, my mistake - I switched implementation stra
|
| message.type() == SpellCheckHostMsg_NotifyChecked::ID) |
| @@ -40,10 +32,10 @@ void SpellCheckMessageFilter::OverrideThreadForMessage( |
| #endif |
| } |
| -bool SpellCheckMessageFilter::OnMessageReceived(const IPC::Message& message, |
| +bool TtsMessageFilter::OnMessageReceived(const IPC::Message& message, |
| bool* message_was_ok) { |
| bool handled = true; |
| - IPC_BEGIN_MESSAGE_MAP_EX(SpellCheckMessageFilter, message, *message_was_ok) |
| + IPC_BEGIN_MESSAGE_MAP_EX(TtsMessageFilter, message, *message_was_ok) |
| IPC_MESSAGE_HANDLER(SpellCheckHostMsg_RequestDictionary, |
|
hans
2013/03/09 14:19:52
again with the spellcheck.. i'm not sure i underst
|
| OnSpellCheckerRequestDictionary) |
| IPC_MESSAGE_HANDLER(SpellCheckHostMsg_NotifyChecked, |
| @@ -57,9 +49,9 @@ bool SpellCheckMessageFilter::OnMessageReceived(const IPC::Message& message, |
| return handled; |
| } |
| -SpellCheckMessageFilter::~SpellCheckMessageFilter() {} |
| +TtsMessageFilter::~TtsMessageFilter() {} |
| -void SpellCheckMessageFilter::OnSpellCheckerRequestDictionary() { |
| +void TtsMessageFilter::OnSpellCheckerRequestDictionary() { |
| content::RenderProcessHost* host = |
| content::RenderProcessHost::FromID(render_process_id_); |
| if (!host) |
| @@ -81,7 +73,7 @@ void SpellCheckMessageFilter::OnSpellCheckerRequestDictionary() { |
| // than once if we get requests from different renderers. |
| } |
| -void SpellCheckMessageFilter::OnNotifyChecked(const string16& word, |
| +void TtsMessageFilter::OnNotifyChecked(const string16& word, |
| bool misspelled) { |
| content::RenderProcessHost* host = |
| content::RenderProcessHost::FromID(render_process_id_); |
| @@ -97,19 +89,28 @@ void SpellCheckMessageFilter::OnNotifyChecked(const string16& word, |
| } |
| #if !defined(OS_MACOSX) |
| -void SpellCheckMessageFilter::OnCallSpellingService( |
| +void TtsMessageFilter::OnCallSpellingService( |
| int route_id, |
| int identifier, |
| int document_tag, |
| const string16& text) { |
| DCHECK(!text.empty()); |
| DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| + if (!CallSpellingService(route_id, identifier, document_tag, text)) { |
| + std::vector<SpellCheckResult> results; |
| + Send(new SpellCheckMsg_RespondSpellingService(route_id, |
| + identifier, |
| + document_tag, |
| + false, |
| + text, |
| + results)); |
| + return; |
| + } |
| route_id_ = route_id; |
| identifier_ = identifier; |
| - CallSpellingService(document_tag, text); |
| } |
| -void SpellCheckMessageFilter::OnTextCheckComplete( |
| +void TtsMessageFilter::OnTextCheckComplete( |
| int tag, |
| bool success, |
| const string16& text, |
| @@ -120,21 +121,25 @@ void SpellCheckMessageFilter::OnTextCheckComplete( |
| success, |
| text, |
| results)); |
| + client_.reset(); |
| } |
| -// CallSpellingService always executes the callback OnTextCheckComplete. |
| -// (Which, in turn, sends a SpellCheckMsg_RespondSpellingService) |
| -void SpellCheckMessageFilter::CallSpellingService(int document_tag, |
| - const string16& text) { |
| - Profile* profile = NULL; |
| +bool TtsMessageFilter::CallSpellingService( |
| + int route_id, |
| + int identifier, |
| + int document_tag, |
| + const string16& text) { |
| content::RenderProcessHost* host = |
| content::RenderProcessHost::FromID(render_process_id_); |
| - if (host) |
| - profile = Profile::FromBrowserContext(host->GetBrowserContext()); |
| - |
| - client_->RequestTextCheck( |
| + if (!host) |
| + return false; |
| + Profile* profile = Profile::FromBrowserContext(host->GetBrowserContext()); |
|
tommi (sloooow) - chröme
2013/03/07 13:04:46
I seem to recall FromBrowserContext return NULL in
|
| + if (!profile->GetPrefs()->GetBoolean(prefs::kSpellCheckUseSpellingService)) |
| + return false; |
| + client_.reset(new SpellingServiceClient); |
| + return client_->RequestTextCheck( |
| profile, SpellingServiceClient::SPELLCHECK, text, |
| - base::Bind(&SpellCheckMessageFilter::OnTextCheckComplete, |
| + base::Bind(&TtsMessageFilter::OnTextCheckComplete, |
| base::Unretained(this), document_tag)); |
| } |
| #endif |