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/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 Loading... |
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 Loading... |
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::NOTIFICATION_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 Loading... |
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::NOTIFICATION_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 Loading... |
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::NOTIFICATION_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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
691 bool ProfileImpl::IsOffTheRecord() { | 692 bool ProfileImpl::IsOffTheRecord() { |
692 return false; | 693 return false; |
693 } | 694 } |
694 | 695 |
695 Profile* ProfileImpl::GetOffTheRecordProfile() { | 696 Profile* ProfileImpl::GetOffTheRecordProfile() { |
696 if (!off_the_record_profile_.get()) { | 697 if (!off_the_record_profile_.get()) { |
697 scoped_ptr<Profile> p(CreateOffTheRecordProfile()); | 698 scoped_ptr<Profile> p(CreateOffTheRecordProfile()); |
698 off_the_record_profile_.swap(p); | 699 off_the_record_profile_.swap(p); |
699 | 700 |
700 NotificationService::current()->Notify( | 701 NotificationService::current()->Notify( |
701 NotificationType::OTR_PROFILE_CREATED, | 702 chrome::NOTIFICATION_OTR_PROFILE_CREATED, |
702 Source<Profile>(off_the_record_profile_.get()), | 703 Source<Profile>(off_the_record_profile_.get()), |
703 NotificationService::NoDetails()); | 704 NotificationService::NoDetails()); |
704 } | 705 } |
705 return off_the_record_profile_.get(); | 706 return off_the_record_profile_.get(); |
706 } | 707 } |
707 | 708 |
708 void ProfileImpl::DestroyOffTheRecordProfile() { | 709 void ProfileImpl::DestroyOffTheRecordProfile() { |
709 off_the_record_profile_.reset(); | 710 off_the_record_profile_.reset(); |
710 extension_pref_value_map_->ClearAllIncognitoSessionOnlyPreferences(); | 711 extension_pref_value_map_->ClearAllIncognitoSessionOnlyPreferences(); |
711 } | 712 } |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
859 net::URLRequestContextGetter* request_context = | 860 net::URLRequestContextGetter* request_context = |
860 io_data_.GetMainRequestContextGetter(); | 861 io_data_.GetMainRequestContextGetter(); |
861 // The first request context is always a normal (non-OTR) request context. | 862 // The first request context is always a normal (non-OTR) request context. |
862 // Even when Chromium is started in OTR mode, a normal profile is always | 863 // Even when Chromium is started in OTR mode, a normal profile is always |
863 // created first. | 864 // created first. |
864 if (!default_request_context_) { | 865 if (!default_request_context_) { |
865 default_request_context_ = request_context; | 866 default_request_context_ = request_context; |
866 // TODO(eroman): this isn't terribly useful anymore now that the | 867 // TODO(eroman): this isn't terribly useful anymore now that the |
867 // net::URLRequestContext is constructed by the IO thread... | 868 // net::URLRequestContext is constructed by the IO thread... |
868 NotificationService::current()->Notify( | 869 NotificationService::current()->Notify( |
869 NotificationType::DEFAULT_REQUEST_CONTEXT_AVAILABLE, | 870 chrome::NOTIFICATION_DEFAULT_REQUEST_CONTEXT_AVAILABLE, |
870 NotificationService::AllSources(), NotificationService::NoDetails()); | 871 NotificationService::AllSources(), NotificationService::NoDetails()); |
871 } | 872 } |
872 | 873 |
873 return request_context; | 874 return request_context; |
874 } | 875 } |
875 | 876 |
876 net::URLRequestContextGetter* ProfileImpl::GetRequestContextForRenderProcess( | 877 net::URLRequestContextGetter* ProfileImpl::GetRequestContextForRenderProcess( |
877 int renderer_child_id) { | 878 int renderer_child_id) { |
878 if (extension_service_.get()) { | 879 if (extension_service_.get()) { |
879 const Extension* installed_app = extension_service_-> | 880 const Extension* installed_app = extension_service_-> |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
966 const std::string& host(*i); | 967 const std::string& host(*i); |
967 double zoom_level = 0; | 968 double zoom_level = 0; |
968 | 969 |
969 bool success = host_zoom_dictionary->GetDoubleWithoutPathExpansion( | 970 bool success = host_zoom_dictionary->GetDoubleWithoutPathExpansion( |
970 host, &zoom_level); | 971 host, &zoom_level); |
971 DCHECK(success); | 972 DCHECK(success); |
972 host_zoom_map_->SetZoomLevel(host, zoom_level); | 973 host_zoom_map_->SetZoomLevel(host, zoom_level); |
973 } | 974 } |
974 } | 975 } |
975 | 976 |
976 registrar_.Add(this, NotificationType::ZOOM_LEVEL_CHANGED, | 977 registrar_.Add(this, content::NOTIFICATION_ZOOM_LEVEL_CHANGED, |
977 Source<HostZoomMap>(host_zoom_map_)); | 978 Source<HostZoomMap>(host_zoom_map_)); |
978 } | 979 } |
979 return host_zoom_map_.get(); | 980 return host_zoom_map_.get(); |
980 } | 981 } |
981 | 982 |
982 GeolocationContentSettingsMap* ProfileImpl::GetGeolocationContentSettingsMap() { | 983 GeolocationContentSettingsMap* ProfileImpl::GetGeolocationContentSettingsMap() { |
983 if (!geolocation_content_settings_map_.get()) | 984 if (!geolocation_content_settings_map_.get()) |
984 geolocation_content_settings_map_ = new GeolocationContentSettingsMap(this); | 985 geolocation_content_settings_map_ = new GeolocationContentSettingsMap(this); |
985 return geolocation_content_settings_map_.get(); | 986 return geolocation_content_settings_map_.get(); |
986 } | 987 } |
(...skipping 28 matching lines...) Expand all Loading... |
1015 | 1016 |
1016 if (!history_service_created_) { | 1017 if (!history_service_created_) { |
1017 history_service_created_ = true; | 1018 history_service_created_ = true; |
1018 scoped_refptr<HistoryService> history(new HistoryService(this)); | 1019 scoped_refptr<HistoryService> history(new HistoryService(this)); |
1019 if (!history->Init(GetPath(), GetBookmarkModel())) | 1020 if (!history->Init(GetPath(), GetBookmarkModel())) |
1020 return NULL; | 1021 return NULL; |
1021 history_service_.swap(history); | 1022 history_service_.swap(history); |
1022 | 1023 |
1023 // Send out the notification that the history service was created. | 1024 // Send out the notification that the history service was created. |
1024 NotificationService::current()-> | 1025 NotificationService::current()-> |
1025 Notify(NotificationType::HISTORY_CREATED, Source<Profile>(this), | 1026 Notify(chrome::NOTIFICATION_HISTORY_CREATED, Source<Profile>(this), |
1026 Details<HistoryService>(history_service_.get())); | 1027 Details<HistoryService>(history_service_.get())); |
1027 } | 1028 } |
1028 return history_service_.get(); | 1029 return history_service_.get(); |
1029 } | 1030 } |
1030 | 1031 |
1031 HistoryService* ProfileImpl::GetHistoryServiceWithoutCreating() { | 1032 HistoryService* ProfileImpl::GetHistoryServiceWithoutCreating() { |
1032 return history_service_.get(); | 1033 return history_service_.get(); |
1033 } | 1034 } |
1034 | 1035 |
1035 TemplateURLFetcher* ProfileImpl::GetTemplateURLFetcher() { | 1036 TemplateURLFetcher* ProfileImpl::GetTemplateURLFetcher() { |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1347 if (prefs_.get()) { | 1348 if (prefs_.get()) { |
1348 // The session cleanly exited, set kSessionExitedCleanly appropriately. | 1349 // The session cleanly exited, set kSessionExitedCleanly appropriately. |
1349 prefs_->SetBoolean(prefs::kSessionExitedCleanly, true); | 1350 prefs_->SetBoolean(prefs::kSessionExitedCleanly, true); |
1350 | 1351 |
1351 // NOTE: If you change what thread this writes on, be sure and update | 1352 // NOTE: If you change what thread this writes on, be sure and update |
1352 // ChromeFrame::EndSession(). | 1353 // ChromeFrame::EndSession(). |
1353 prefs_->SavePersistentPrefs(); | 1354 prefs_->SavePersistentPrefs(); |
1354 } | 1355 } |
1355 } | 1356 } |
1356 | 1357 |
1357 void ProfileImpl::Observe(NotificationType type, | 1358 void ProfileImpl::Observe(int type, |
1358 const NotificationSource& source, | 1359 const NotificationSource& source, |
1359 const NotificationDetails& details) { | 1360 const NotificationDetails& details) { |
1360 switch (type.value) { | 1361 switch (type) { |
1361 case NotificationType::PREF_INITIALIZATION_COMPLETED: { | 1362 case chrome::NOTIFICATION_PREF_INITIALIZATION_COMPLETED: { |
1362 bool* succeeded = Details<bool>(details).ptr(); | 1363 bool* succeeded = Details<bool>(details).ptr(); |
1363 PrefService *prefs = Source<PrefService>(source).ptr(); | 1364 PrefService *prefs = Source<PrefService>(source).ptr(); |
1364 DCHECK(prefs == prefs_.get()); | 1365 DCHECK(prefs == prefs_.get()); |
1365 registrar_.Remove(this, NotificationType::PREF_INITIALIZATION_COMPLETED, | 1366 registrar_.Remove(this, |
| 1367 chrome::NOTIFICATION_PREF_INITIALIZATION_COMPLETED, |
1366 Source<PrefService>(prefs)); | 1368 Source<PrefService>(prefs)); |
1367 OnPrefsLoaded(*succeeded); | 1369 OnPrefsLoaded(*succeeded); |
1368 break; | 1370 break; |
1369 } | 1371 } |
1370 case NotificationType::PREF_CHANGED: { | 1372 case chrome::NOTIFICATION_PREF_CHANGED: { |
1371 std::string* pref_name_in = Details<std::string>(details).ptr(); | 1373 std::string* pref_name_in = Details<std::string>(details).ptr(); |
1372 PrefService* prefs = Source<PrefService>(source).ptr(); | 1374 PrefService* prefs = Source<PrefService>(source).ptr(); |
1373 DCHECK(pref_name_in && prefs); | 1375 DCHECK(pref_name_in && prefs); |
1374 if (*pref_name_in == prefs::kSpellCheckDictionary || | 1376 if (*pref_name_in == prefs::kSpellCheckDictionary || |
1375 *pref_name_in == prefs::kEnableSpellCheck) { | 1377 *pref_name_in == prefs::kEnableSpellCheck) { |
1376 ReinitializeSpellCheckHost(true); | 1378 ReinitializeSpellCheckHost(true); |
1377 } else if (*pref_name_in == prefs::kEnableAutoSpellCorrect) { | 1379 } else if (*pref_name_in == prefs::kEnableAutoSpellCorrect) { |
1378 bool enabled = prefs->GetBoolean(prefs::kEnableAutoSpellCorrect); | 1380 bool enabled = prefs->GetBoolean(prefs::kEnableAutoSpellCorrect); |
1379 for (RenderProcessHost::iterator | 1381 for (RenderProcessHost::iterator |
1380 i(RenderProcessHost::AllHostsIterator()); | 1382 i(RenderProcessHost::AllHostsIterator()); |
(...skipping 18 matching lines...) Expand all Loading... |
1399 } | 1401 } |
1400 } else if (*pref_name_in == prefs::kGoogleServicesUsername) { | 1402 } else if (*pref_name_in == prefs::kGoogleServicesUsername) { |
1401 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 1403 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
1402 profile_manager->RegisterProfileName(this); | 1404 profile_manager->RegisterProfileName(this); |
1403 } else if (*pref_name_in == prefs::kDefaultZoomLevel) { | 1405 } else if (*pref_name_in == prefs::kDefaultZoomLevel) { |
1404 GetHostZoomMap()->set_default_zoom_level( | 1406 GetHostZoomMap()->set_default_zoom_level( |
1405 prefs->GetDouble(prefs::kDefaultZoomLevel)); | 1407 prefs->GetDouble(prefs::kDefaultZoomLevel)); |
1406 } | 1408 } |
1407 break; | 1409 break; |
1408 } | 1410 } |
1409 case NotificationType::BOOKMARK_MODEL_LOADED: | 1411 case chrome::NOTIFICATION_BOOKMARK_MODEL_LOADED: |
1410 GetProfileSyncService(); // Causes lazy-load if sync is enabled. | 1412 GetProfileSyncService(); // Causes lazy-load if sync is enabled. |
1411 registrar_.Remove(this, NotificationType::BOOKMARK_MODEL_LOADED, | 1413 registrar_.Remove(this, chrome::NOTIFICATION_BOOKMARK_MODEL_LOADED, |
1412 Source<Profile>(this)); | 1414 Source<Profile>(this)); |
1413 break; | 1415 break; |
1414 case NotificationType::ZOOM_LEVEL_CHANGED: { | 1416 case content::NOTIFICATION_ZOOM_LEVEL_CHANGED: { |
1415 const std::string& host = *(Details<const std::string>(details).ptr()); | 1417 const std::string& host = *(Details<const std::string>(details).ptr()); |
1416 if (!host.empty()) { | 1418 if (!host.empty()) { |
1417 double level = host_zoom_map_->GetZoomLevel(host); | 1419 double level = host_zoom_map_->GetZoomLevel(host); |
1418 DictionaryPrefUpdate update(prefs_.get(), prefs::kPerHostZoomLevels); | 1420 DictionaryPrefUpdate update(prefs_.get(), prefs::kPerHostZoomLevels); |
1419 DictionaryValue* host_zoom_dictionary = update.Get(); | 1421 DictionaryValue* host_zoom_dictionary = update.Get(); |
1420 if (level == host_zoom_map_->default_zoom_level()) { | 1422 if (level == host_zoom_map_->default_zoom_level()) { |
1421 host_zoom_dictionary->RemoveWithoutPathExpansion(host, NULL); | 1423 host_zoom_dictionary->RemoveWithoutPathExpansion(host, NULL); |
1422 } else { | 1424 } else { |
1423 host_zoom_dictionary->SetWithoutPathExpansion( | 1425 host_zoom_dictionary->SetWithoutPathExpansion( |
1424 host, Value::CreateDoubleValue(level)); | 1426 host, Value::CreateDoubleValue(level)); |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1648 if (!prerender::PrerenderManager::IsPrerenderingPossible()) | 1650 if (!prerender::PrerenderManager::IsPrerenderingPossible()) |
1649 return NULL; | 1651 return NULL; |
1650 if (!prerender_manager_.get()) { | 1652 if (!prerender_manager_.get()) { |
1651 CHECK(g_browser_process->prerender_tracker()); | 1653 CHECK(g_browser_process->prerender_tracker()); |
1652 prerender_manager_.reset( | 1654 prerender_manager_.reset( |
1653 new prerender::PrerenderManager( | 1655 new prerender::PrerenderManager( |
1654 this, g_browser_process->prerender_tracker())); | 1656 this, g_browser_process->prerender_tracker())); |
1655 } | 1657 } |
1656 return prerender_manager_.get(); | 1658 return prerender_manager_.get(); |
1657 } | 1659 } |
OLD | NEW |