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

Side by Side Diff: chrome/browser/profiles/profile_impl.cc

Issue 7327007: Moving notification types which are chrome specific to a new header file chrome_notification_type... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/profiles/profile_impl.h" 5 #include "chrome/browser/profiles/profile_impl.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/environment.h" 9 #include "base/environment.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 #include "chrome/browser/ui/browser_list.h" 69 #include "chrome/browser/ui/browser_list.h"
70 #include "chrome/browser/ui/find_bar/find_bar_state.h" 70 #include "chrome/browser/ui/find_bar/find_bar_state.h"
71 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" 71 #include "chrome/browser/ui/webui/chrome_url_data_manager.h"
72 #include "chrome/browser/ui/webui/extension_icon_source.h" 72 #include "chrome/browser/ui/webui/extension_icon_source.h"
73 #include "chrome/browser/user_style_sheet_watcher.h" 73 #include "chrome/browser/user_style_sheet_watcher.h"
74 #include "chrome/browser/visitedlink/visitedlink_event_listener.h" 74 #include "chrome/browser/visitedlink/visitedlink_event_listener.h"
75 #include "chrome/browser/visitedlink/visitedlink_master.h" 75 #include "chrome/browser/visitedlink/visitedlink_master.h"
76 #include "chrome/browser/web_resource/promo_resource_service.h" 76 #include "chrome/browser/web_resource/promo_resource_service.h"
77 #include "chrome/browser/webdata/web_data_service.h" 77 #include "chrome/browser/webdata/web_data_service.h"
78 #include "chrome/common/chrome_constants.h" 78 #include "chrome/common/chrome_constants.h"
79 #include "chrome/common/chrome_notification_types.h"
79 #include "chrome/common/chrome_paths.h" 80 #include "chrome/common/chrome_paths.h"
80 #include "chrome/common/chrome_paths_internal.h" 81 #include "chrome/common/chrome_paths_internal.h"
81 #include "chrome/common/chrome_switches.h" 82 #include "chrome/common/chrome_switches.h"
82 #include "chrome/common/extensions/extension_permission_set.h" 83 #include "chrome/common/extensions/extension_permission_set.h"
83 #include "chrome/common/json_pref_store.h" 84 #include "chrome/common/json_pref_store.h"
84 #include "chrome/common/pref_names.h" 85 #include "chrome/common/pref_names.h"
85 #include "chrome/common/render_messages.h" 86 #include "chrome/common/render_messages.h"
86 #include "chrome/common/spellcheck_messages.h" 87 #include "chrome/common/spellcheck_messages.h"
87 #include "content/browser/appcache/chrome_appcache_service.h" 88 #include "content/browser/appcache/chrome_appcache_service.h"
88 #include "content/browser/browser_thread.h" 89 #include "content/browser/browser_thread.h"
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 TimeDelta::FromMilliseconds(kCreateSessionServiceDelayMS), this, 303 TimeDelta::FromMilliseconds(kCreateSessionServiceDelayMS), this,
303 &ProfileImpl::EnsureSessionServiceCreated); 304 &ProfileImpl::EnsureSessionServiceCreated);
304 305
305 if (delegate_) { 306 if (delegate_) {
306 prefs_.reset(PrefService::CreatePrefService( 307 prefs_.reset(PrefService::CreatePrefService(
307 GetPrefFilePath(), 308 GetPrefFilePath(),
308 new ExtensionPrefStore(GetExtensionPrefValueMap(), false), 309 new ExtensionPrefStore(GetExtensionPrefValueMap(), false),
309 true)); 310 true));
310 // Wait for the notifcation that prefs has been loaded (successfully or 311 // Wait for the notifcation that prefs has been loaded (successfully or
311 // not). 312 // not).
312 registrar_.Add(this, NotificationType::PREF_INITIALIZATION_COMPLETED, 313 registrar_.Add(this, chrome::PREF_INITIALIZATION_COMPLETED,
313 Source<PrefService>(prefs_.get())); 314 Source<PrefService>(prefs_.get()));
314 } else { 315 } else {
315 // Load prefs synchronously. 316 // Load prefs synchronously.
316 prefs_.reset(PrefService::CreatePrefService( 317 prefs_.reset(PrefService::CreatePrefService(
317 GetPrefFilePath(), 318 GetPrefFilePath(),
318 new ExtensionPrefStore(GetExtensionPrefValueMap(), false), 319 new ExtensionPrefStore(GetExtensionPrefValueMap(), false),
319 false)); 320 false));
320 OnPrefsLoaded(true); 321 OnPrefsLoaded(true);
321 } 322 }
322 } 323 }
(...skipping 20 matching lines...) Expand all
343 // It is safe since all other file operations should also be done there. 344 // It is safe since all other file operations should also be done there.
344 BrowserThread::PostTask(BrowserThread::FILE, 345 BrowserThread::PostTask(BrowserThread::FILE,
345 FROM_HERE, 346 FROM_HERE,
346 NewRunnableFunction(&file_util::CreateDirectory, 347 NewRunnableFunction(&file_util::CreateDirectory,
347 base_cache_path_)); 348 base_cache_path_));
348 } 349 }
349 350
350 #if !defined(OS_CHROMEOS) 351 #if !defined(OS_CHROMEOS)
351 // Listen for bookmark model load, to bootstrap the sync service. 352 // Listen for bookmark model load, to bootstrap the sync service.
352 // On CrOS sync service will be initialized after sign in. 353 // On CrOS sync service will be initialized after sign in.
353 registrar_.Add(this, NotificationType::BOOKMARK_MODEL_LOADED, 354 registrar_.Add(this, chrome::BOOKMARK_MODEL_LOADED,
354 Source<Profile>(this)); 355 Source<Profile>(this));
355 #endif 356 #endif
356 357
357 PrefService* local_state = g_browser_process->local_state(); 358 PrefService* local_state = g_browser_process->local_state();
358 ssl_config_service_manager_.reset( 359 ssl_config_service_manager_.reset(
359 SSLConfigServiceManager::CreateDefaultManager(local_state)); 360 SSLConfigServiceManager::CreateDefaultManager(local_state));
360 361
361 PinnedTabServiceFactory::InitForProfile(this); 362 PinnedTabServiceFactory::InitForProfile(this);
362 363
363 // Initialize the BackgroundModeManager - this has to be done here before 364 // Initialize the BackgroundModeManager - this has to be done here before
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 FilePath ProfileImpl::last_selected_directory() { 579 FilePath ProfileImpl::last_selected_directory() {
579 return GetPrefs()->GetFilePath(prefs::kSelectFileLastDirectory); 580 return GetPrefs()->GetFilePath(prefs::kSelectFileLastDirectory);
580 } 581 }
581 582
582 void ProfileImpl::set_last_selected_directory(const FilePath& path) { 583 void ProfileImpl::set_last_selected_directory(const FilePath& path) {
583 GetPrefs()->SetFilePath(prefs::kSelectFileLastDirectory, path); 584 GetPrefs()->SetFilePath(prefs::kSelectFileLastDirectory, path);
584 } 585 }
585 586
586 ProfileImpl::~ProfileImpl() { 587 ProfileImpl::~ProfileImpl() {
587 NotificationService::current()->Notify( 588 NotificationService::current()->Notify(
588 NotificationType::PROFILE_DESTROYED, 589 chrome::PROFILE_DESTROYED,
589 Source<Profile>(this), 590 Source<Profile>(this),
590 NotificationService::NoDetails()); 591 NotificationService::NoDetails());
591 592
592 StopCreateSessionServiceTimer(); 593 StopCreateSessionServiceTimer();
593 594
594 // Remove pref observers 595 // Remove pref observers
595 pref_change_registrar_.RemoveAll(); 596 pref_change_registrar_.RemoveAll();
596 597
597 ProfileDependencyManager::GetInstance()->DestroyProfileServices(this); 598 ProfileDependencyManager::GetInstance()->DestroyProfileServices(this);
598 599
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 bool ProfileImpl::IsOffTheRecord() { 684 bool ProfileImpl::IsOffTheRecord() {
684 return false; 685 return false;
685 } 686 }
686 687
687 Profile* ProfileImpl::GetOffTheRecordProfile() { 688 Profile* ProfileImpl::GetOffTheRecordProfile() {
688 if (!off_the_record_profile_.get()) { 689 if (!off_the_record_profile_.get()) {
689 scoped_ptr<Profile> p(CreateOffTheRecordProfile()); 690 scoped_ptr<Profile> p(CreateOffTheRecordProfile());
690 off_the_record_profile_.swap(p); 691 off_the_record_profile_.swap(p);
691 692
692 NotificationService::current()->Notify( 693 NotificationService::current()->Notify(
693 NotificationType::OTR_PROFILE_CREATED, 694 chrome::OTR_PROFILE_CREATED,
694 Source<Profile>(off_the_record_profile_.get()), 695 Source<Profile>(off_the_record_profile_.get()),
695 NotificationService::NoDetails()); 696 NotificationService::NoDetails());
696 } 697 }
697 return off_the_record_profile_.get(); 698 return off_the_record_profile_.get();
698 } 699 }
699 700
700 void ProfileImpl::DestroyOffTheRecordProfile() { 701 void ProfileImpl::DestroyOffTheRecordProfile() {
701 off_the_record_profile_.reset(); 702 off_the_record_profile_.reset();
702 extension_pref_value_map_->ClearAllIncognitoSessionOnlyPreferences(); 703 extension_pref_value_map_->ClearAllIncognitoSessionOnlyPreferences();
703 } 704 }
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
851 net::URLRequestContextGetter* request_context = 852 net::URLRequestContextGetter* request_context =
852 io_data_.GetMainRequestContextGetter(); 853 io_data_.GetMainRequestContextGetter();
853 // The first request context is always a normal (non-OTR) request context. 854 // The first request context is always a normal (non-OTR) request context.
854 // Even when Chromium is started in OTR mode, a normal profile is always 855 // Even when Chromium is started in OTR mode, a normal profile is always
855 // created first. 856 // created first.
856 if (!default_request_context_) { 857 if (!default_request_context_) {
857 default_request_context_ = request_context; 858 default_request_context_ = request_context;
858 // TODO(eroman): this isn't terribly useful anymore now that the 859 // TODO(eroman): this isn't terribly useful anymore now that the
859 // net::URLRequestContext is constructed by the IO thread... 860 // net::URLRequestContext is constructed by the IO thread...
860 NotificationService::current()->Notify( 861 NotificationService::current()->Notify(
861 NotificationType::DEFAULT_REQUEST_CONTEXT_AVAILABLE, 862 chrome::DEFAULT_REQUEST_CONTEXT_AVAILABLE,
862 NotificationService::AllSources(), NotificationService::NoDetails()); 863 NotificationService::AllSources(), NotificationService::NoDetails());
863 } 864 }
864 865
865 return request_context; 866 return request_context;
866 } 867 }
867 868
868 net::URLRequestContextGetter* ProfileImpl::GetRequestContextForRenderProcess( 869 net::URLRequestContextGetter* ProfileImpl::GetRequestContextForRenderProcess(
869 int renderer_child_id) { 870 int renderer_child_id) {
870 if (extension_service_.get()) { 871 if (extension_service_.get()) {
871 const Extension* installed_app = extension_service_-> 872 const Extension* installed_app = extension_service_->
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
1007 1008
1008 if (!history_service_created_) { 1009 if (!history_service_created_) {
1009 history_service_created_ = true; 1010 history_service_created_ = true;
1010 scoped_refptr<HistoryService> history(new HistoryService(this)); 1011 scoped_refptr<HistoryService> history(new HistoryService(this));
1011 if (!history->Init(GetPath(), GetBookmarkModel())) 1012 if (!history->Init(GetPath(), GetBookmarkModel()))
1012 return NULL; 1013 return NULL;
1013 history_service_.swap(history); 1014 history_service_.swap(history);
1014 1015
1015 // Send out the notification that the history service was created. 1016 // Send out the notification that the history service was created.
1016 NotificationService::current()-> 1017 NotificationService::current()->
1017 Notify(NotificationType::HISTORY_CREATED, Source<Profile>(this), 1018 Notify(chrome::HISTORY_CREATED, Source<Profile>(this),
1018 Details<HistoryService>(history_service_.get())); 1019 Details<HistoryService>(history_service_.get()));
1019 } 1020 }
1020 return history_service_.get(); 1021 return history_service_.get();
1021 } 1022 }
1022 1023
1023 HistoryService* ProfileImpl::GetHistoryServiceWithoutCreating() { 1024 HistoryService* ProfileImpl::GetHistoryServiceWithoutCreating() {
1024 return history_service_.get(); 1025 return history_service_.get();
1025 } 1026 }
1026 1027
1027 TemplateURLFetcher* ProfileImpl::GetTemplateURLFetcher() { 1028 TemplateURLFetcher* ProfileImpl::GetTemplateURLFetcher() {
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
1342 // NOTE: If you change what thread this writes on, be sure and update 1343 // NOTE: If you change what thread this writes on, be sure and update
1343 // ChromeFrame::EndSession(). 1344 // ChromeFrame::EndSession().
1344 prefs_->SavePersistentPrefs(); 1345 prefs_->SavePersistentPrefs();
1345 } 1346 }
1346 } 1347 }
1347 1348
1348 void ProfileImpl::Observe(NotificationType type, 1349 void ProfileImpl::Observe(NotificationType type,
1349 const NotificationSource& source, 1350 const NotificationSource& source,
1350 const NotificationDetails& details) { 1351 const NotificationDetails& details) {
1351 switch (type.value) { 1352 switch (type.value) {
1352 case NotificationType::PREF_INITIALIZATION_COMPLETED: { 1353 case chrome::PREF_INITIALIZATION_COMPLETED: {
1353 bool* succeeded = Details<bool>(details).ptr(); 1354 bool* succeeded = Details<bool>(details).ptr();
1354 PrefService *prefs = Source<PrefService>(source).ptr(); 1355 PrefService *prefs = Source<PrefService>(source).ptr();
1355 DCHECK(prefs == prefs_.get()); 1356 DCHECK(prefs == prefs_.get());
1356 registrar_.Remove(this, NotificationType::PREF_INITIALIZATION_COMPLETED, 1357 registrar_.Remove(this, chrome::PREF_INITIALIZATION_COMPLETED,
1357 Source<PrefService>(prefs)); 1358 Source<PrefService>(prefs));
1358 OnPrefsLoaded(*succeeded); 1359 OnPrefsLoaded(*succeeded);
1359 break; 1360 break;
1360 } 1361 }
1361 case NotificationType::PREF_CHANGED: { 1362 case chrome::PREF_CHANGED: {
1362 std::string* pref_name_in = Details<std::string>(details).ptr(); 1363 std::string* pref_name_in = Details<std::string>(details).ptr();
1363 PrefService* prefs = Source<PrefService>(source).ptr(); 1364 PrefService* prefs = Source<PrefService>(source).ptr();
1364 DCHECK(pref_name_in && prefs); 1365 DCHECK(pref_name_in && prefs);
1365 if (*pref_name_in == prefs::kSpellCheckDictionary || 1366 if (*pref_name_in == prefs::kSpellCheckDictionary ||
1366 *pref_name_in == prefs::kEnableSpellCheck) { 1367 *pref_name_in == prefs::kEnableSpellCheck) {
1367 ReinitializeSpellCheckHost(true); 1368 ReinitializeSpellCheckHost(true);
1368 } else if (*pref_name_in == prefs::kEnableAutoSpellCorrect) { 1369 } else if (*pref_name_in == prefs::kEnableAutoSpellCorrect) {
1369 bool enabled = prefs->GetBoolean(prefs::kEnableAutoSpellCorrect); 1370 bool enabled = prefs->GetBoolean(prefs::kEnableAutoSpellCorrect);
1370 for (RenderProcessHost::iterator 1371 for (RenderProcessHost::iterator
1371 i(RenderProcessHost::AllHostsIterator()); 1372 i(RenderProcessHost::AllHostsIterator());
(...skipping 14 matching lines...) Expand all
1386 } 1387 }
1387 } else if (*pref_name_in == prefs::kGoogleServicesUsername) { 1388 } else if (*pref_name_in == prefs::kGoogleServicesUsername) {
1388 ProfileManager* profile_manager = g_browser_process->profile_manager(); 1389 ProfileManager* profile_manager = g_browser_process->profile_manager();
1389 profile_manager->RegisterProfileName(this); 1390 profile_manager->RegisterProfileName(this);
1390 } else if (*pref_name_in == prefs::kDefaultZoomLevel) { 1391 } else if (*pref_name_in == prefs::kDefaultZoomLevel) {
1391 GetHostZoomMap()->set_default_zoom_level( 1392 GetHostZoomMap()->set_default_zoom_level(
1392 prefs->GetDouble(prefs::kDefaultZoomLevel)); 1393 prefs->GetDouble(prefs::kDefaultZoomLevel));
1393 } 1394 }
1394 break; 1395 break;
1395 } 1396 }
1396 case NotificationType::BOOKMARK_MODEL_LOADED: 1397 case chrome::BOOKMARK_MODEL_LOADED:
1397 GetProfileSyncService(); // Causes lazy-load if sync is enabled. 1398 GetProfileSyncService(); // Causes lazy-load if sync is enabled.
1398 registrar_.Remove(this, NotificationType::BOOKMARK_MODEL_LOADED, 1399 registrar_.Remove(this, chrome::BOOKMARK_MODEL_LOADED,
1399 Source<Profile>(this)); 1400 Source<Profile>(this));
1400 break; 1401 break;
1401 case NotificationType::ZOOM_LEVEL_CHANGED: { 1402 case NotificationType::ZOOM_LEVEL_CHANGED: {
1402 const std::string& host = *(Details<const std::string>(details).ptr()); 1403 const std::string& host = *(Details<const std::string>(details).ptr());
1403 if (!host.empty()) { 1404 if (!host.empty()) {
1404 double level = host_zoom_map_->GetZoomLevel(host); 1405 double level = host_zoom_map_->GetZoomLevel(host);
1405 DictionaryPrefUpdate update(prefs_.get(), prefs::kPerHostZoomLevels); 1406 DictionaryPrefUpdate update(prefs_.get(), prefs::kPerHostZoomLevels);
1406 DictionaryValue* host_zoom_dictionary = update.Get(); 1407 DictionaryValue* host_zoom_dictionary = update.Get();
1407 if (level == host_zoom_map_->default_zoom_level()) { 1408 if (level == host_zoom_map_->default_zoom_level()) {
1408 host_zoom_dictionary->RemoveWithoutPathExpansion(host, NULL); 1409 host_zoom_dictionary->RemoveWithoutPathExpansion(host, NULL);
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
1635 if (!prerender::PrerenderManager::IsPrerenderingPossible()) 1636 if (!prerender::PrerenderManager::IsPrerenderingPossible())
1636 return NULL; 1637 return NULL;
1637 if (!prerender_manager_.get()) { 1638 if (!prerender_manager_.get()) {
1638 CHECK(g_browser_process->prerender_tracker()); 1639 CHECK(g_browser_process->prerender_tracker());
1639 prerender_manager_.reset( 1640 prerender_manager_.reset(
1640 new prerender::PrerenderManager( 1641 new prerender::PrerenderManager(
1641 this, g_browser_process->prerender_tracker())); 1642 this, g_browser_process->prerender_tracker()));
1642 } 1643 }
1643 return prerender_manager_.get(); 1644 return prerender_manager_.get();
1644 } 1645 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698