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

Side by Side Diff: chrome/browser/profile.cc

Issue 357003: Move the spellchecker to the renderer.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: rename Created 11 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/profile.h" 5 #include "chrome/browser/profile.h"
6 6
7 #include "app/theme_provider.h" 7 #include "app/theme_provider.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 } 471 }
472 472
473 virtual SpellChecker* GetSpellChecker() { 473 virtual SpellChecker* GetSpellChecker() {
474 return profile_->GetSpellChecker(); 474 return profile_->GetSpellChecker();
475 } 475 }
476 476
477 virtual void DeleteSpellChecker() { 477 virtual void DeleteSpellChecker() {
478 profile_->DeleteSpellChecker(); 478 profile_->DeleteSpellChecker();
479 } 479 }
480 480
481 #if defined(SPELLCHECKER_IN_RENDERER)
482 virtual SpellCheckHost* GetSpellCheckHost() {
483 return profile_->GetSpellCheckHost();
484 }
485
486 virtual void ReinitializeSpellCheckHost(bool force) {
487 profile_->ReinitializeSpellCheckHost(force);
488 }
489 #endif
490
481 virtual WebKitContext* GetWebKitContext() { 491 virtual WebKitContext* GetWebKitContext() {
482 if (!webkit_context_.get()) 492 if (!webkit_context_.get())
483 webkit_context_ = new WebKitContext(GetPath(), true); 493 webkit_context_ = new WebKitContext(GetPath(), true);
484 DCHECK(webkit_context_.get()); 494 DCHECK(webkit_context_.get());
485 return webkit_context_.get(); 495 return webkit_context_.get();
486 } 496 }
487 497
488 virtual ThumbnailStore* GetThumbnailStore() { 498 virtual ThumbnailStore* GetThumbnailStore() {
489 return NULL; 499 return NULL;
490 } 500 }
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 extensions_request_context_(NULL), 572 extensions_request_context_(NULL),
563 blacklist_(NULL), 573 blacklist_(NULL),
564 history_service_created_(false), 574 history_service_created_(false),
565 favicon_service_created_(false), 575 favicon_service_created_(false),
566 created_web_data_service_(false), 576 created_web_data_service_(false),
567 created_password_store_(false), 577 created_password_store_(false),
568 created_download_manager_(false), 578 created_download_manager_(false),
569 created_theme_provider_(false), 579 created_theme_provider_(false),
570 start_time_(Time::Now()), 580 start_time_(Time::Now()),
571 spellchecker_(NULL), 581 spellchecker_(NULL),
582 #if defined(OS_LINUX)
583 spellcheck_host_(NULL),
584 spellcheck_host_ready_(false),
585 #endif
572 shutdown_session_service_(false) { 586 shutdown_session_service_(false) {
573 DCHECK(!path.empty()) << "Using an empty path will attempt to write " << 587 DCHECK(!path.empty()) << "Using an empty path will attempt to write " <<
574 "profile files to the root directory!"; 588 "profile files to the root directory!";
575 create_session_service_timer_.Start( 589 create_session_service_timer_.Start(
576 TimeDelta::FromMilliseconds(kCreateSessionServiceDelayMS), this, 590 TimeDelta::FromMilliseconds(kCreateSessionServiceDelayMS), this,
577 &ProfileImpl::EnsureSessionServiceCreated); 591 &ProfileImpl::EnsureSessionServiceCreated);
578 592
579 if (CommandLine::ForCurrentProcess()->HasSwitch( 593 if (CommandLine::ForCurrentProcess()->HasSwitch(
580 switches::kEnableExtensionTimelineApi)) { 594 switches::kEnableExtensionTimelineApi)) {
581 extension_devtools_manager_ = new ExtensionDevToolsManager(this); 595 extension_devtools_manager_ = new ExtensionDevToolsManager(this);
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 // increased the ref count of the service. In such a situation, when we 747 // increased the ref count of the service. In such a situation, when we
734 // decrement the refcount, it won't be 0, and the threads/databases aren't 748 // decrement the refcount, it won't be 0, and the threads/databases aren't
735 // properly shut down. By explicitly calling Cleanup/Shutdown we ensure the 749 // properly shut down. By explicitly calling Cleanup/Shutdown we ensure the
736 // databases are properly closed. 750 // databases are properly closed.
737 if (web_data_service_.get()) 751 if (web_data_service_.get())
738 web_data_service_->Shutdown(); 752 web_data_service_->Shutdown();
739 753
740 if (history_service_.get()) 754 if (history_service_.get())
741 history_service_->Cleanup(); 755 history_service_->Cleanup();
742 756
757 #if defined(SPELLCHECKER_IN_RENDERER)
758 if (spellcheck_host_.get())
759 spellcheck_host_->UnsetObserver();
760 #endif
743 DeleteSpellCheckerImpl(false); 761 DeleteSpellCheckerImpl(false);
744 762
745 if (default_request_context_ == request_context_) { 763 if (default_request_context_ == request_context_) {
746 #if defined(OS_LINUX) 764 #if defined(OS_LINUX)
747 // We use default_request_context_ for OCSP. 765 // We use default_request_context_ for OCSP.
748 // Release URLRequestContext used in OCSP handlers. 766 // Release URLRequestContext used in OCSP handlers.
749 net::SetURLRequestContextForOCSP(NULL); 767 net::SetURLRequestContextForOCSP(NULL);
750 #endif 768 #endif
751 default_request_context_ = NULL; 769 default_request_context_ = NULL;
752 } 770 }
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
1253 // Set auto spell correct status for spellchecker. 1271 // Set auto spell correct status for spellchecker.
1254 spellchecker_->EnableAutoSpellCorrect( 1272 spellchecker_->EnableAutoSpellCorrect(
1255 prefs->GetBoolean(prefs::kEnableAutoSpellCorrect)); 1273 prefs->GetBoolean(prefs::kEnableAutoSpellCorrect));
1256 1274
1257 NotifySpellCheckerChanged(); 1275 NotifySpellCheckerChanged();
1258 } else { 1276 } else {
1259 DeleteSpellCheckerImpl(true); 1277 DeleteSpellCheckerImpl(true);
1260 } 1278 }
1261 } 1279 }
1262 1280
1281 #if defined(SPELLCHECKER_IN_RENDERER)
1282 SpellCheckHost* ProfileImpl::GetSpellCheckHost() {
1283 return spellcheck_host_ready_ ? spellcheck_host_.get() : NULL;
1284 }
1285
1286 void ProfileImpl::ReinitializeSpellCheckHost(bool force) {
1287 // If we are already loading the spellchecker, and this is just a hint to
1288 // load the spellchecker, do nothing.
1289 if (!force && spellcheck_host_.get())
1290 return;
1291
1292 bool notify = false;
1293 if (spellcheck_host_.get()) {
1294 spellcheck_host_->UnsetObserver();
1295 spellcheck_host_.release();
1296 spellcheck_host_ready_ = false;
1297 notify = true;
1298 }
1299
1300 PrefService* prefs = GetPrefs();
1301 if (prefs->GetBoolean(prefs::kEnableSpellCheck)) {
1302 // Retrieve the (perhaps updated recently) dictionary name from preferences.
1303 spellcheck_host_ = new SpellCheckHost(this,
1304 WideToASCII(prefs->GetString(prefs::kSpellCheckDictionary)),
1305 GetRequestContext());
1306 spellcheck_host_->AddRef();
1307 } else if (notify) {
1308 // The spellchecker has been disabled.
1309 SpellCheckHostInitialized();
1310 }
1311 }
1312
1313 void ProfileImpl::SpellCheckHostInitialized() {
1314 spellcheck_host_ready_ =
1315 spellcheck_host_ && spellcheck_host_->bdict_fd().fd != -1;
1316 NotificationService::current()->Notify(
1317 NotificationType::SPELLCHECK_HOST_REINITIALIZED,
1318 Source<Profile>(this), NotificationService::NoDetails());
1319 }
1320 #endif
1321
1263 void ProfileImpl::NotifySpellCheckerChanged() { 1322 void ProfileImpl::NotifySpellCheckerChanged() {
1264 SpellcheckerReinitializedDetails scoped_spellchecker; 1323 SpellcheckerReinitializedDetails scoped_spellchecker;
1265 scoped_spellchecker.spellchecker = spellchecker_; 1324 scoped_spellchecker.spellchecker = spellchecker_;
1266 ChromeThread::PostTask( 1325 ChromeThread::PostTask(
1267 ChromeThread::IO, FROM_HERE, 1326 ChromeThread::IO, FROM_HERE,
1268 new NotifySpellcheckerChangeTask(this, scoped_spellchecker)); 1327 new NotifySpellcheckerChangeTask(this, scoped_spellchecker));
1269 } 1328 }
1270 1329
1271 void ProfileImpl::DeleteSpellCheckerImpl(bool notify) { 1330 void ProfileImpl::DeleteSpellCheckerImpl(bool notify) {
1272 if (!spellchecker_) 1331 if (!spellchecker_)
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1321 } 1380 }
1322 1381
1323 void ProfileImpl::Observe(NotificationType type, 1382 void ProfileImpl::Observe(NotificationType type,
1324 const NotificationSource& source, 1383 const NotificationSource& source,
1325 const NotificationDetails& details) { 1384 const NotificationDetails& details) {
1326 if (NotificationType::PREF_CHANGED == type) { 1385 if (NotificationType::PREF_CHANGED == type) {
1327 std::wstring* pref_name_in = Details<std::wstring>(details).ptr(); 1386 std::wstring* pref_name_in = Details<std::wstring>(details).ptr();
1328 PrefService* prefs = Source<PrefService>(source).ptr(); 1387 PrefService* prefs = Source<PrefService>(source).ptr();
1329 DCHECK(pref_name_in && prefs); 1388 DCHECK(pref_name_in && prefs);
1330 if (*pref_name_in == prefs::kSpellCheckDictionary || 1389 if (*pref_name_in == prefs::kSpellCheckDictionary ||
1331 *pref_name_in == prefs::kEnableSpellCheck || 1390 #if !defined(SPELLCHECKER_IN_RENDERER)
1332 *pref_name_in == prefs::kEnableAutoSpellCorrect) { 1391 *pref_name_in == prefs::kEnableAutoSpellCorrect ||
1392 #endif
1393 *pref_name_in == prefs::kEnableSpellCheck) {
1333 ReinitializeSpellChecker(); 1394 ReinitializeSpellChecker();
1395 #if defined(SPELLCHECKER_IN_RENDERER)
1396 ReinitializeSpellCheckHost(true);
1397 #endif
1334 } 1398 }
1335 } else if (NotificationType::THEME_INSTALLED == type) { 1399 } else if (NotificationType::THEME_INSTALLED == type) {
1336 Extension* extension = Details<Extension>(details).ptr(); 1400 Extension* extension = Details<Extension>(details).ptr();
1337 SetTheme(extension); 1401 SetTheme(extension);
1338 } else if (NotificationType::BOOKMARK_MODEL_LOADED == type) { 1402 } else if (NotificationType::BOOKMARK_MODEL_LOADED == type) {
1339 GetProfileSyncService(); // Causes lazy-load if sync is enabled. 1403 GetProfileSyncService(); // Causes lazy-load if sync is enabled.
1340 registrar_.Remove(this, NotificationType::BOOKMARK_MODEL_LOADED, 1404 registrar_.Remove(this, NotificationType::BOOKMARK_MODEL_LOADED,
1341 Source<Profile>(this)); 1405 Source<Profile>(this));
1342 } 1406 }
1343 } 1407 }
(...skipping 10 matching lines...) Expand all
1354 return sync_service_.get(); 1418 return sync_service_.get();
1355 } 1419 }
1356 #endif 1420 #endif
1357 return NULL; 1421 return NULL;
1358 } 1422 }
1359 1423
1360 void ProfileImpl::InitSyncService() { 1424 void ProfileImpl::InitSyncService() {
1361 sync_service_.reset(new ProfileSyncService(this)); 1425 sync_service_.reset(new ProfileSyncService(this));
1362 sync_service_->Initialize(); 1426 sync_service_->Initialize();
1363 } 1427 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698