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/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
12 #include "base/string_split.h" | 12 #include "base/string_split.h" |
13 #include "base/threading/thread_restrictions.h" | 13 #include "base/threading/thread_restrictions.h" |
14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
15 #include "chrome/browser/prefs/pref_service.h" | 15 #include "chrome/browser/prefs/pref_service.h" |
16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/browser/spellchecker/spellcheck_host_metrics.h" | 17 #include "chrome/browser/spellchecker/spellcheck_host_metrics.h" |
18 #include "chrome/browser/spellchecker/spellcheck_profile_provider.h" | 18 #include "chrome/browser/spellchecker/spellcheck_profile_provider.h" |
19 #include "chrome/browser/spellchecker/spellchecker_platform_engine.h" | 19 #include "chrome/browser/spellchecker/spellchecker_platform_engine.h" |
20 #include "chrome/common/chrome_constants.h" | 20 #include "chrome/common/chrome_constants.h" |
21 #include "chrome/common/chrome_paths.h" | 21 #include "chrome/common/chrome_paths.h" |
22 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
23 #include "chrome/common/spellcheck_common.h" | 23 #include "chrome/common/spellcheck_common.h" |
24 #include "chrome/common/spellcheck_messages.h" | 24 #include "chrome/common/spellcheck_messages.h" |
25 #include "content/browser/renderer_host/render_process_host.h" | 25 #include "content/browser/renderer_host/render_process_host.h" |
26 #include "content/common/notification_service.h" | 26 #include "content/public/browser/notification_service.h" |
27 #include "content/public/browser/notification_types.h" | 27 #include "content/public/browser/notification_types.h" |
28 #include "googleurl/src/gurl.h" | 28 #include "googleurl/src/gurl.h" |
29 #include "net/url_request/url_request_context_getter.h" | 29 #include "net/url_request/url_request_context_getter.h" |
30 #include "third_party/hunspell/google/bdict.h" | 30 #include "third_party/hunspell/google/bdict.h" |
31 #include "ui/base/l10n/l10n_util.h" | 31 #include "ui/base/l10n/l10n_util.h" |
32 #if defined(OS_MACOSX) | 32 #if defined(OS_MACOSX) |
33 #include "base/metrics/histogram.h" | 33 #include "base/metrics/histogram.h" |
34 #endif | 34 #endif |
35 | 35 |
36 namespace { | 36 namespace { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 metrics_(metrics) { | 94 metrics_(metrics) { |
95 DCHECK(profile_); | 95 DCHECK(profile_); |
96 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 96 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
97 | 97 |
98 FilePath personal_file_directory; | 98 FilePath personal_file_directory; |
99 PathService::Get(chrome::DIR_USER_DATA, &personal_file_directory); | 99 PathService::Get(chrome::DIR_USER_DATA, &personal_file_directory); |
100 custom_dictionary_file_ = | 100 custom_dictionary_file_ = |
101 personal_file_directory.Append(chrome::kCustomDictionaryFileName); | 101 personal_file_directory.Append(chrome::kCustomDictionaryFileName); |
102 | 102 |
103 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CREATED, | 103 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CREATED, |
104 NotificationService::AllSources()); | 104 content::NotificationService::AllSources()); |
105 } | 105 } |
106 | 106 |
107 SpellCheckHostImpl::~SpellCheckHostImpl() { | 107 SpellCheckHostImpl::~SpellCheckHostImpl() { |
108 if (file_ != base::kInvalidPlatformFileValue) | 108 if (file_ != base::kInvalidPlatformFileValue) |
109 base::ClosePlatformFile(file_); | 109 base::ClosePlatformFile(file_); |
110 } | 110 } |
111 | 111 |
112 void SpellCheckHostImpl::Initialize() { | 112 void SpellCheckHostImpl::Initialize() { |
113 if (SpellCheckerPlatform::SpellCheckerAvailable() && | 113 if (SpellCheckerPlatform::SpellCheckerAvailable() && |
114 SpellCheckerPlatform::PlatformSupportsLanguage(language_)) { | 114 SpellCheckerPlatform::PlatformSupportsLanguage(language_)) { |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 return file_; | 433 return file_; |
434 } | 434 } |
435 | 435 |
436 const std::string& SpellCheckHostImpl::GetLanguage() const { | 436 const std::string& SpellCheckHostImpl::GetLanguage() const { |
437 return language_; | 437 return language_; |
438 } | 438 } |
439 | 439 |
440 bool SpellCheckHostImpl::IsUsingPlatformChecker() const { | 440 bool SpellCheckHostImpl::IsUsingPlatformChecker() const { |
441 return use_platform_spellchecker_; | 441 return use_platform_spellchecker_; |
442 } | 442 } |
OLD | NEW |