| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/spellcheck_message_filter.h" | 5 #include "chrome/browser/spellcheck_message_filter.h" |
| 6 | 6 |
| 7 #include "chrome/browser/prefs/pref_service.h" | 7 #include "chrome/browser/prefs/pref_service.h" |
| 8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/browser/spellcheck_host.h" | 9 #include "chrome/browser/spellcheck_host.h" |
| 10 #include "chrome/browser/spellcheck_host_metrics.h" | 10 #include "chrome/browser/spellcheck_host_metrics.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 int document_tag, | 87 int document_tag, |
| 88 const string16& text) { | 88 const string16& text) { |
| 89 SpellCheckerPlatform::RequestTextCheck( | 89 SpellCheckerPlatform::RequestTextCheck( |
| 90 route_id, identifier, document_tag, text, this); | 90 route_id, identifier, document_tag, text, this); |
| 91 } | 91 } |
| 92 | 92 |
| 93 void SpellCheckMessageFilter::OnSpellCheckerRequestDictionary() { | 93 void SpellCheckMessageFilter::OnSpellCheckerRequestDictionary() { |
| 94 RenderProcessHost* host = RenderProcessHost::FromID(render_process_id_); | 94 RenderProcessHost* host = RenderProcessHost::FromID(render_process_id_); |
| 95 if (!host) | 95 if (!host) |
| 96 return; // Teardown. | 96 return; // Teardown. |
| 97 Profile* profile = Profile::FromBrowserContext(host->browser_context()); | 97 Profile* profile = host->profile(); |
| 98 // The renderer has requested that we initialize its spellchecker. This should | 98 // The renderer has requested that we initialize its spellchecker. This should |
| 99 // generally only be called once per session, as after the first call, all | 99 // generally only be called once per session, as after the first call, all |
| 100 // future renderers will be passed the initialization information on startup | 100 // future renderers will be passed the initialization information on startup |
| 101 // (or when the dictionary changes in some way). | 101 // (or when the dictionary changes in some way). |
| 102 if (profile->GetSpellCheckHost()) { | 102 if (profile->GetSpellCheckHost()) { |
| 103 // The spellchecker initialization already started and finished; just send | 103 // The spellchecker initialization already started and finished; just send |
| 104 // it to the renderer. | 104 // it to the renderer. |
| 105 profile->GetSpellCheckHost()->InitForRenderer(host); | 105 profile->GetSpellCheckHost()->InitForRenderer(host); |
| 106 } else { | 106 } else { |
| 107 // We may have gotten multiple requests from different renderers. We don't | 107 // We may have gotten multiple requests from different renderers. We don't |
| 108 // want to initialize multiple times in this case, so we set |force| to | 108 // want to initialize multiple times in this case, so we set |force| to |
| 109 // false. | 109 // false. |
| 110 profile->ReinitializeSpellCheckHost(false); | 110 profile->ReinitializeSpellCheckHost(false); |
| 111 } | 111 } |
| 112 } | 112 } |
| 113 | 113 |
| 114 void SpellCheckMessageFilter::OnNotifyChecked(const string16& word, | 114 void SpellCheckMessageFilter::OnNotifyChecked(const string16& word, |
| 115 bool misspelled) { | 115 bool misspelled) { |
| 116 RenderProcessHost* host = RenderProcessHost::FromID(render_process_id_); | 116 RenderProcessHost* host = RenderProcessHost::FromID(render_process_id_); |
| 117 if (!host) | 117 if (!host) |
| 118 return; // Teardown. | 118 return; // Teardown. |
| 119 // Delegates to SpellCheckHost which tracks the stats of our spellchecker. | 119 // Delegates to SpellCheckHost which tracks the stats of our spellchecker. |
| 120 Profile* profile = Profile::FromBrowserContext(host->browser_context()); | 120 SpellCheckHost* spellcheck_host = host->profile()->GetSpellCheckHost(); |
| 121 SpellCheckHost* spellcheck_host = profile->GetSpellCheckHost(); | |
| 122 if (spellcheck_host && spellcheck_host->GetMetrics()) | 121 if (spellcheck_host && spellcheck_host->GetMetrics()) |
| 123 spellcheck_host->GetMetrics()->RecordCheckedWordStats(word, misspelled); | 122 spellcheck_host->GetMetrics()->RecordCheckedWordStats(word, misspelled); |
| 124 } | 123 } |
| OLD | NEW |