Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2902)

Unified Diff: chrome/browser/profiles/profile_impl.cc

Issue 7583003: [Refactoring] Extracted SpellCheckProfile from ProfileImpl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: To commit Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/profiles/profile_impl.h ('k') | chrome/browser/spellchecker/spellcheck_host.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/profiles/profile_impl.cc
diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc
index b6544f7984e187cd4a1283aa2e9e96aa515c31cb..ce5adbfd6f851af8bfe506071b3224b6fa49c83a 100644
--- a/chrome/browser/profiles/profile_impl.cc
+++ b/chrome/browser/profiles/profile_impl.cc
@@ -61,8 +61,7 @@
#include "chrome/browser/search_engines/template_url_fetcher.h"
#include "chrome/browser/search_engines/template_url_service.h"
#include "chrome/browser/sessions/session_service_factory.h"
-#include "chrome/browser/spellchecker/spellcheck_host.h"
-#include "chrome/browser/spellchecker/spellcheck_host_metrics.h"
+#include "chrome/browser/spellchecker/spellcheck_profile.h"
#include "chrome/browser/sync/profile_sync_factory_impl.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/tabs/pinned_tab_service_factory.h"
@@ -304,8 +303,6 @@ ProfileImpl::ProfileImpl(const FilePath& path,
created_password_store_(false),
created_download_manager_(false),
start_time_(Time::Now()),
- spellcheck_host_(NULL),
- spellcheck_host_ready_(false),
#if defined(OS_WIN)
checked_instant_promo_(false),
#endif
@@ -407,11 +404,9 @@ void ProfileImpl::DoFinalInit() {
// Instantiates Metrics object for spellchecking for use.
if (g_browser_process->metrics_service() &&
- g_browser_process->metrics_service()->recording_active()) {
- spellcheck_host_metrics_.reset(new SpellCheckHostMetrics());
- spellcheck_host_metrics_->RecordEnabledStats(
+ g_browser_process->metrics_service()->recording_active())
+ GetSpellCheckProfile()->StartRecordingMetrics(
GetPrefs()->GetBoolean(prefs::kEnableSpellCheck));
- }
speech_input::SpeechInputManager::Get()->set_censor_results(
prefs->GetBoolean(prefs::kSpeechInputCensorResults));
@@ -715,9 +710,6 @@ ProfileImpl::~ProfileImpl() {
if (history_service_.get())
history_service_->Cleanup();
- if (spellcheck_host_.get())
- spellcheck_host_->UnsetObserver();
-
if (io_data_.HasMainRequestContext() &&
default_request_context_ == GetRequestContext()) {
default_request_context_ = NULL;
@@ -1345,35 +1337,20 @@ history::TopSites* ProfileImpl::GetTopSitesWithoutCreating() {
}
SpellCheckHost* ProfileImpl::GetSpellCheckHost() {
- return spellcheck_host_ready_ ? spellcheck_host_.get() : NULL;
+ return GetSpellCheckProfile()->GetHost();
}
-void ProfileImpl::ReinitializeSpellCheckHost(bool force) {
- // If we are already loading the spellchecker, and this is just a hint to
- // load the spellchecker, do nothing.
- if (!force && spellcheck_host_.get())
- return;
-
- spellcheck_host_ready_ = false;
-
- bool notify = false;
- if (spellcheck_host_.get()) {
- spellcheck_host_->UnsetObserver();
- spellcheck_host_ = NULL;
- notify = true;
- }
- PrefService* prefs = GetPrefs();
- if (prefs->GetBoolean(prefs::kEnableSpellCheck)) {
- // Retrieve the (perhaps updated recently) dictionary name from preferences.
- spellcheck_host_ = SpellCheckHost::Create(
- this,
- prefs->GetString(prefs::kSpellCheckDictionary),
- GetRequestContext(),
- spellcheck_host_metrics_.get());
- } else if (notify) {
+void ProfileImpl::ReinitializeSpellCheckHost(bool force) {
+ PrefService* pref = GetPrefs();
+ SpellCheckProfile::ReinitializeResult result =
+ GetSpellCheckProfile()->ReinitializeHost(
+ force,
+ pref->GetBoolean(prefs::kEnableSpellCheck),
+ pref->GetString(prefs::kSpellCheckDictionary),
+ GetRequestContext());
+ if (result == SpellCheckProfile::REINITIALIZE_REMOVED_HOST) {
// The spellchecker has been disabled.
- SpellCheckHostInitialized();
for (RenderProcessHost::iterator
i(RenderProcessHost::AllHostsIterator());
!i.IsAtEnd(); i.Advance()) {
@@ -1386,13 +1363,6 @@ void ProfileImpl::ReinitializeSpellCheckHost(bool force) {
}
}
-void ProfileImpl::SpellCheckHostInitialized() {
- spellcheck_host_ready_ = spellcheck_host_ &&
- (spellcheck_host_->GetDictionaryFile() !=
- base::kInvalidPlatformFileValue ||
- spellcheck_host_->IsUsingPlatformChecker());
-}
-
ExtensionPrefValueMap* ProfileImpl::GetExtensionPrefValueMap() {
if (!extension_pref_value_map_.get())
extension_pref_value_map_.reset(new ExtensionPrefValueMap);
@@ -1757,3 +1727,9 @@ prerender::PrerenderManager* ProfileImpl::GetPrerenderManager() {
}
return prerender_manager_.get();
}
+
+SpellCheckProfile* ProfileImpl::GetSpellCheckProfile() {
+ if (!spellcheck_profile_.get())
+ spellcheck_profile_.reset(new SpellCheckProfile());
+ return spellcheck_profile_.get();
+}
« no previous file with comments | « chrome/browser/profiles/profile_impl.h ('k') | chrome/browser/spellchecker/spellcheck_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698