| 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/message_loop.h" | 12 #include "base/message_loop.h" |
| 13 #include "base/path_service.h" | 13 #include "base/path_service.h" |
| 14 #include "base/string_split.h" | 14 #include "base/string_split.h" |
| 15 #include "base/threading/thread_restrictions.h" | 15 #include "base/threading/thread_restrictions.h" |
| 16 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
| 17 #include "chrome/browser/prefs/pref_service.h" | 17 #include "chrome/browser/prefs/pref_service.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 19 #include "chrome/browser/spellchecker/spellcheck_factory.h" |
| 19 #include "chrome/browser/spellchecker/spellcheck_host_metrics.h" | 20 #include "chrome/browser/spellchecker/spellcheck_host_metrics.h" |
| 20 #include "chrome/browser/spellchecker/spellcheck_platform_mac.h" | 21 #include "chrome/browser/spellchecker/spellcheck_platform_mac.h" |
| 21 #include "chrome/browser/spellchecker/spellcheck_profile_provider.h" | 22 #include "chrome/browser/spellchecker/spellcheck_profile_provider.h" |
| 22 #include "chrome/common/chrome_constants.h" | 23 #include "chrome/common/chrome_constants.h" |
| 23 #include "chrome/common/chrome_paths.h" | 24 #include "chrome/common/chrome_paths.h" |
| 24 #include "chrome/common/pref_names.h" | 25 #include "chrome/common/pref_names.h" |
| 25 #include "chrome/common/spellcheck_common.h" | 26 #include "chrome/common/spellcheck_common.h" |
| 26 #include "chrome/common/spellcheck_messages.h" | 27 #include "chrome/common/spellcheck_messages.h" |
| 27 #include "content/public/browser/notification_service.h" | 28 #include "content/public/browser/notification_service.h" |
| 28 #include "content/public/browser/notification_types.h" | 29 #include "content/public/browser/notification_types.h" |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 fetcher_.reset(); | 129 fetcher_.reset(); |
| 129 registrar_.RemoveAll(); | 130 registrar_.RemoveAll(); |
| 130 } | 131 } |
| 131 | 132 |
| 132 void SpellCheckHostImpl::InitForRenderer(content::RenderProcessHost* process) { | 133 void SpellCheckHostImpl::InitForRenderer(content::RenderProcessHost* process) { |
| 133 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 134 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 134 | 135 |
| 135 // Bug 103693: SpellCheckHostImpl and SpellCheckProfile should not | 136 // Bug 103693: SpellCheckHostImpl and SpellCheckProfile should not |
| 136 // depend on Profile interface. | 137 // depend on Profile interface. |
| 137 Profile* profile = Profile::FromBrowserContext(process->GetBrowserContext()); | 138 Profile* profile = Profile::FromBrowserContext(process->GetBrowserContext()); |
| 138 if (profile->GetSpellCheckHost() != this) | 139 if (SpellCheckFactory::GetHostForProfile(profile) != this) |
| 139 return; | 140 return; |
| 140 | 141 |
| 141 PrefService* prefs = profile->GetPrefs(); | 142 PrefService* prefs = profile->GetPrefs(); |
| 142 IPC::PlatformFileForTransit file = IPC::InvalidPlatformFileForTransit(); | 143 IPC::PlatformFileForTransit file = IPC::InvalidPlatformFileForTransit(); |
| 143 | 144 |
| 144 if (GetDictionaryFile() != base::kInvalidPlatformFileValue) { | 145 if (GetDictionaryFile() != base::kInvalidPlatformFileValue) { |
| 145 #if defined(OS_POSIX) | 146 #if defined(OS_POSIX) |
| 146 file = base::FileDescriptor(GetDictionaryFile(), false); | 147 file = base::FileDescriptor(GetDictionaryFile(), false); |
| 147 #elif defined(OS_WIN) | 148 #elif defined(OS_WIN) |
| 148 ::DuplicateHandle(::GetCurrentProcess(), | 149 ::DuplicateHandle(::GetCurrentProcess(), |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 | 447 |
| 447 void SpellCheckHostImpl::AddWordComplete(const std::string& word) { | 448 void SpellCheckHostImpl::AddWordComplete(const std::string& word) { |
| 448 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 449 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 449 | 450 |
| 450 for (content::RenderProcessHost::iterator i( | 451 for (content::RenderProcessHost::iterator i( |
| 451 content::RenderProcessHost::AllHostsIterator()); | 452 content::RenderProcessHost::AllHostsIterator()); |
| 452 !i.IsAtEnd(); i.Advance()) { | 453 !i.IsAtEnd(); i.Advance()) { |
| 453 i.GetCurrentValue()->Send(new SpellCheckMsg_WordAdded(word)); | 454 i.GetCurrentValue()->Send(new SpellCheckMsg_WordAdded(word)); |
| 454 } | 455 } |
| 455 } | 456 } |
| OLD | NEW |