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_host_metrics.h" | 19 #include "chrome/browser/spellchecker/spellcheck_host_metrics.h" |
| 20 #include "chrome/browser/spellchecker/spellcheck_platform_mac.h" |
20 #include "chrome/browser/spellchecker/spellcheck_profile_provider.h" | 21 #include "chrome/browser/spellchecker/spellcheck_profile_provider.h" |
21 #include "chrome/browser/spellchecker/spellchecker_platform_engine.h" | |
22 #include "chrome/common/chrome_constants.h" | 22 #include "chrome/common/chrome_constants.h" |
23 #include "chrome/common/chrome_paths.h" | 23 #include "chrome/common/chrome_paths.h" |
24 #include "chrome/common/pref_names.h" | 24 #include "chrome/common/pref_names.h" |
25 #include "chrome/common/spellcheck_common.h" | 25 #include "chrome/common/spellcheck_common.h" |
26 #include "chrome/common/spellcheck_messages.h" | 26 #include "chrome/common/spellcheck_messages.h" |
27 #include "content/public/browser/notification_service.h" | 27 #include "content/public/browser/notification_service.h" |
28 #include "content/public/browser/notification_types.h" | 28 #include "content/public/browser/notification_types.h" |
29 #include "content/public/browser/render_process_host.h" | 29 #include "content/public/browser/render_process_host.h" |
30 #include "content/public/common/url_fetcher.h" | 30 #include "content/public/common/url_fetcher.h" |
31 #include "googleurl/src/gurl.h" | 31 #include "googleurl/src/gurl.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 if (file_ != base::kInvalidPlatformFileValue) { | 94 if (file_ != base::kInvalidPlatformFileValue) { |
95 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 95 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
96 base::Bind(&CloseDictionary, file_)); | 96 base::Bind(&CloseDictionary, file_)); |
97 file_ = base::kInvalidPlatformFileValue; | 97 file_ = base::kInvalidPlatformFileValue; |
98 } | 98 } |
99 } | 99 } |
100 | 100 |
101 void SpellCheckHostImpl::Initialize() { | 101 void SpellCheckHostImpl::Initialize() { |
102 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 102 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
103 | 103 |
104 if (SpellCheckerPlatform::SpellCheckerAvailable() && | 104 #if defined(OS_MACOSX) |
105 SpellCheckerPlatform::PlatformSupportsLanguage(language_)) { | 105 if (SpellCheckerMac::SpellCheckerAvailable() && |
| 106 SpellCheckerMac::PlatformSupportsLanguage(language_)) { |
106 use_platform_spellchecker_ = true; | 107 use_platform_spellchecker_ = true; |
107 SpellCheckerPlatform::SetLanguage(language_); | 108 SpellCheckerMac::SetLanguage(language_); |
108 MessageLoop::current()->PostTask(FROM_HERE, | 109 MessageLoop::current()->PostTask(FROM_HERE, |
109 base::Bind(&SpellCheckHostImpl::InformProfileOfInitialization, | 110 base::Bind(&SpellCheckHostImpl::InformProfileOfInitialization, |
110 weak_ptr_factory_.GetWeakPtr())); | 111 weak_ptr_factory_.GetWeakPtr())); |
111 return; | 112 return; |
112 } | 113 } |
| 114 #endif // OS_MACOSX |
113 | 115 |
114 BrowserThread::PostTaskAndReply(BrowserThread::FILE, FROM_HERE, | 116 BrowserThread::PostTaskAndReply(BrowserThread::FILE, FROM_HERE, |
115 base::Bind(&SpellCheckHostImpl::InitializeDictionaryLocation, | 117 base::Bind(&SpellCheckHostImpl::InitializeDictionaryLocation, |
116 base::Unretained(this)), | 118 base::Unretained(this)), |
117 base::Bind(&SpellCheckHostImpl::InitializeDictionaryLocationComplete, | 119 base::Bind(&SpellCheckHostImpl::InitializeDictionaryLocationComplete, |
118 weak_ptr_factory_.GetWeakPtr())); | 120 weak_ptr_factory_.GetWeakPtr())); |
119 } | 121 } |
120 | 122 |
121 void SpellCheckHostImpl::UnsetProfile() { | 123 void SpellCheckHostImpl::UnsetProfile() { |
122 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 124 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 | 446 |
445 void SpellCheckHostImpl::AddWordComplete(const std::string& word) { | 447 void SpellCheckHostImpl::AddWordComplete(const std::string& word) { |
446 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 448 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
447 | 449 |
448 for (content::RenderProcessHost::iterator i( | 450 for (content::RenderProcessHost::iterator i( |
449 content::RenderProcessHost::AllHostsIterator()); | 451 content::RenderProcessHost::AllHostsIterator()); |
450 !i.IsAtEnd(); i.Advance()) { | 452 !i.IsAtEnd(); i.Advance()) { |
451 i.GetCurrentValue()->Send(new SpellCheckMsg_WordAdded(word)); | 453 i.GetCurrentValue()->Send(new SpellCheckMsg_WordAdded(word)); |
452 } | 454 } |
453 } | 455 } |
OLD | NEW |