| 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/spellchecker/spellcheck_host_impl.h" | 5 #include "chrome/browser/spellchecker/spellcheck_host_impl.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
| 13 #include "base/string_split.h" | 13 #include "base/string_split.h" |
| 14 #include "base/threading/thread_restrictions.h" | 14 #include "base/threading/thread_restrictions.h" |
| 15 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
| 16 #include "chrome/browser/prefs/pref_service.h" | 16 #include "chrome/browser/prefs/pref_service.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/browser/spellchecker/spellcheck_host_metrics.h" | 18 #include "chrome/browser/spellchecker/spellcheck_host_metrics.h" |
| 19 #include "chrome/browser/spellchecker/spellcheck_profile_provider.h" | 19 #include "chrome/browser/spellchecker/spellcheck_profile_provider.h" |
| 20 #include "chrome/browser/spellchecker/spellchecker_platform_engine.h" | 20 #include "chrome/browser/spellchecker/spellchecker_platform_engine.h" |
| 21 #include "chrome/common/chrome_constants.h" | 21 #include "chrome/common/chrome_constants.h" |
| 22 #include "chrome/common/chrome_paths.h" | 22 #include "chrome/common/chrome_paths.h" |
| 23 #include "chrome/common/pref_names.h" | 23 #include "chrome/common/pref_names.h" |
| 24 #include "chrome/common/spellcheck_common.h" | 24 #include "chrome/common/spellcheck_common.h" |
| 25 #include "chrome/common/spellcheck_messages.h" | 25 #include "chrome/common/spellcheck_messages.h" |
| 26 #include "content/browser/renderer_host/render_process_host.h" | |
| 27 #include "content/public/browser/notification_service.h" | 26 #include "content/public/browser/notification_service.h" |
| 28 #include "content/public/browser/notification_types.h" | 27 #include "content/public/browser/notification_types.h" |
| 28 #include "content/public/browser/render_process_host.h" |
| 29 #include "content/public/common/url_fetcher.h" | 29 #include "content/public/common/url_fetcher.h" |
| 30 #include "googleurl/src/gurl.h" | 30 #include "googleurl/src/gurl.h" |
| 31 #include "net/url_request/url_request_context_getter.h" | 31 #include "net/url_request/url_request_context_getter.h" |
| 32 #include "third_party/hunspell/google/bdict.h" | 32 #include "third_party/hunspell/google/bdict.h" |
| 33 #include "ui/base/l10n/l10n_util.h" | 33 #include "ui/base/l10n/l10n_util.h" |
| 34 #if defined(OS_MACOSX) | 34 #if defined(OS_MACOSX) |
| 35 #include "base/metrics/histogram.h" | 35 #include "base/metrics/histogram.h" |
| 36 #endif | 36 #endif |
| 37 | 37 |
| 38 using content::BrowserThread; | 38 using content::BrowserThread; |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 request_context_getter_ = NULL; | 160 request_context_getter_ = NULL; |
| 161 fetcher_.reset(); | 161 fetcher_.reset(); |
| 162 registrar_.RemoveAll(); | 162 registrar_.RemoveAll(); |
| 163 } | 163 } |
| 164 | 164 |
| 165 void SpellCheckHostImpl::InitForRenderer(RenderProcessHost* process) { | 165 void SpellCheckHostImpl::InitForRenderer(RenderProcessHost* process) { |
| 166 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 166 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 167 | 167 |
| 168 // Bug 103693: SpellCheckHostImpl and SpellCheckProfile should not | 168 // Bug 103693: SpellCheckHostImpl and SpellCheckProfile should not |
| 169 // depend on Profile interface. | 169 // depend on Profile interface. |
| 170 Profile* profile = Profile::FromBrowserContext(process->browser_context()); | 170 Profile* profile = Profile::FromBrowserContext(process->GetBrowserContext()); |
| 171 if (profile->GetSpellCheckHost() != this) | 171 if (profile->GetSpellCheckHost() != this) |
| 172 return; | 172 return; |
| 173 | 173 |
| 174 PrefService* prefs = profile->GetPrefs(); | 174 PrefService* prefs = profile->GetPrefs(); |
| 175 IPC::PlatformFileForTransit file = IPC::InvalidPlatformFileForTransit(); | 175 IPC::PlatformFileForTransit file = IPC::InvalidPlatformFileForTransit(); |
| 176 | 176 |
| 177 if (GetDictionaryFile() != base::kInvalidPlatformFileValue) { | 177 if (GetDictionaryFile() != base::kInvalidPlatformFileValue) { |
| 178 #if defined(OS_POSIX) | 178 #if defined(OS_POSIX) |
| 179 file = base::FileDescriptor(GetDictionaryFile(), false); | 179 file = base::FileDescriptor(GetDictionaryFile(), false); |
| 180 #elif defined(OS_WIN) | 180 #elif defined(OS_WIN) |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 } | 476 } |
| 477 | 477 |
| 478 void SpellCheckHostImpl::AddWordComplete(const std::string& word) { | 478 void SpellCheckHostImpl::AddWordComplete(const std::string& word) { |
| 479 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 479 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 480 | 480 |
| 481 for (RenderProcessHost::iterator i(RenderProcessHost::AllHostsIterator()); | 481 for (RenderProcessHost::iterator i(RenderProcessHost::AllHostsIterator()); |
| 482 !i.IsAtEnd(); i.Advance()) { | 482 !i.IsAtEnd(); i.Advance()) { |
| 483 i.GetCurrentValue()->Send(new SpellCheckMsg_WordAdded(word)); | 483 i.GetCurrentValue()->Send(new SpellCheckMsg_WordAdded(word)); |
| 484 } | 484 } |
| 485 } | 485 } |
| OLD | NEW |