OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/environment.h" | 10 #include "base/environment.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
94 #include "chrome/common/url_constants.h" | 94 #include "chrome/common/url_constants.h" |
95 #include "content/browser/in_process_webkit/webkit_context.h" | 95 #include "content/browser/in_process_webkit/webkit_context.h" |
96 #include "content/browser/speech/speech_input_manager.h" | 96 #include "content/browser/speech/speech_input_manager.h" |
97 #include "content/public/browser/browser_thread.h" | 97 #include "content/public/browser/browser_thread.h" |
98 #include "content/public/browser/host_zoom_map.h" | 98 #include "content/public/browser/host_zoom_map.h" |
99 #include "content/public/browser/notification_service.h" | 99 #include "content/public/browser/notification_service.h" |
100 #include "content/public/browser/user_metrics.h" | 100 #include "content/public/browser/user_metrics.h" |
101 #include "grit/locale_settings.h" | 101 #include "grit/locale_settings.h" |
102 #include "net/base/transport_security_state.h" | 102 #include "net/base/transport_security_state.h" |
103 #include "net/http/http_server_properties.h" | 103 #include "net/http/http_server_properties.h" |
104 #include "webkit/appcache/appcache_service.h" | |
104 #include "webkit/database/database_tracker.h" | 105 #include "webkit/database/database_tracker.h" |
105 | 106 |
106 #if defined(OS_WIN) | 107 #if defined(OS_WIN) |
107 #include "chrome/browser/instant/promo_counter.h" | 108 #include "chrome/browser/instant/promo_counter.h" |
108 #include "chrome/browser/password_manager/password_store_win.h" | 109 #include "chrome/browser/password_manager/password_store_win.h" |
109 #include "chrome/installer/util/install_util.h" | 110 #include "chrome/installer/util/install_util.h" |
110 #elif defined(OS_MACOSX) | 111 #elif defined(OS_MACOSX) |
111 #include "chrome/browser/keychain_mac.h" | 112 #include "chrome/browser/keychain_mac.h" |
112 #include "chrome/browser/mock_keychain_mac.h" | 113 #include "chrome/browser/mock_keychain_mac.h" |
113 #include "chrome/browser/password_manager/password_store_mac.h" | 114 #include "chrome/browser/password_manager/password_store_mac.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
167 FilePath GetCachePath(const FilePath& base) { | 168 FilePath GetCachePath(const FilePath& base) { |
168 return base.Append(chrome::kCacheDirname); | 169 return base.Append(chrome::kCacheDirname); |
169 } | 170 } |
170 | 171 |
171 FilePath GetMediaCachePath(const FilePath& base) { | 172 FilePath GetMediaCachePath(const FilePath& base) { |
172 return base.Append(chrome::kMediaCacheDirname); | 173 return base.Append(chrome::kMediaCacheDirname); |
173 } | 174 } |
174 | 175 |
175 void SaveSessionStateOnIOThread( | 176 void SaveSessionStateOnIOThread( |
176 net::URLRequestContextGetter* url_request_context_getter, | 177 net::URLRequestContextGetter* url_request_context_getter, |
177 ChromeAppCacheService* appcache_service) { | 178 appcache::AppCacheService* appcache_service) { |
Jói
2012/02/20 23:13:49
perhaps DCHECK on this not being NULL since you re
jam
2012/02/21 01:20:13
I'm personally not a fan of DCHECKing that a point
| |
178 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 179 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
179 url_request_context_getter->GetURLRequestContext()->cookie_store()-> | 180 url_request_context_getter->GetURLRequestContext()->cookie_store()-> |
180 GetCookieMonster()->SaveSessionCookies(); | 181 GetCookieMonster()->SaveSessionCookies(); |
181 if (appcache_service) | 182 appcache_service->set_save_session_state(true); |
182 appcache_service->set_save_session_state(true); | |
183 } | 183 } |
184 | 184 |
185 } // namespace | 185 } // namespace |
186 | 186 |
187 // static | 187 // static |
188 Profile* Profile::CreateProfile(const FilePath& path) { | 188 Profile* Profile::CreateProfile(const FilePath& path) { |
189 if (!file_util::PathExists(path)) { | 189 if (!file_util::PathExists(path)) { |
190 // TODO(tc): http://b/1094718 Bad things happen if we can't write to the | 190 // TODO(tc): http://b/1094718 Bad things happen if we can't write to the |
191 // profile directory. We should eventually be able to run in this | 191 // profile directory. We should eventually be able to run in this |
192 // situation. | 192 // situation. |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
544 content::NotificationService::NoDetails()); | 544 content::NotificationService::NoDetails()); |
545 // Save the session state if we're going to restore the session during the | 545 // Save the session state if we're going to restore the session during the |
546 // next startup. | 546 // next startup. |
547 SessionStartupPref pref = SessionStartupPref::GetStartupPref(this); | 547 SessionStartupPref pref = SessionStartupPref::GetStartupPref(this); |
548 if (pref.type == SessionStartupPref::LAST) { | 548 if (pref.type == SessionStartupPref::LAST) { |
549 SaveSessionState(); | 549 SaveSessionState(); |
550 } else if (clear_local_state_on_exit_) { | 550 } else if (clear_local_state_on_exit_) { |
551 BrowserThread::PostTask( | 551 BrowserThread::PostTask( |
552 BrowserThread::IO, FROM_HERE, | 552 BrowserThread::IO, FROM_HERE, |
553 base::Bind(&appcache::AppCacheService::set_clear_local_state_on_exit, | 553 base::Bind(&appcache::AppCacheService::set_clear_local_state_on_exit, |
554 BrowserContext::GetAppCacheService(this), true)); | 554 base::Unretained(BrowserContext::GetAppCacheService(this)), true)); |
555 BrowserContext::GetWebKitContext(this)->set_clear_local_state_on_exit(true); | 555 BrowserContext::GetWebKitContext(this)->set_clear_local_state_on_exit(true); |
556 BrowserContext::GetDatabaseTracker(this)->SetClearLocalStateOnExit(true); | 556 BrowserContext::GetDatabaseTracker(this)->SetClearLocalStateOnExit(true); |
557 } | 557 } |
558 | 558 |
559 StopCreateSessionServiceTimer(); | 559 StopCreateSessionServiceTimer(); |
560 | 560 |
561 // Remove pref observers | 561 // Remove pref observers |
562 pref_change_registrar_.RemoveAll(); | 562 pref_change_registrar_.RemoveAll(); |
563 | 563 |
564 ChromePluginServiceFilter::GetInstance()->UnregisterResourceContext( | 564 ChromePluginServiceFilter::GetInstance()->UnregisterResourceContext( |
(...skipping 866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1431 void ProfileImpl::SaveSessionState() { | 1431 void ProfileImpl::SaveSessionState() { |
1432 if (!session_restore_enabled_) | 1432 if (!session_restore_enabled_) |
1433 return; | 1433 return; |
1434 BrowserContext::GetWebKitContext(this)->SaveSessionState(); | 1434 BrowserContext::GetWebKitContext(this)->SaveSessionState(); |
1435 BrowserContext::GetDatabaseTracker(this)->SaveSessionState(); | 1435 BrowserContext::GetDatabaseTracker(this)->SaveSessionState(); |
1436 | 1436 |
1437 BrowserThread::PostTask( | 1437 BrowserThread::PostTask( |
1438 BrowserThread::IO, FROM_HERE, | 1438 BrowserThread::IO, FROM_HERE, |
1439 base::Bind(&SaveSessionStateOnIOThread, | 1439 base::Bind(&SaveSessionStateOnIOThread, |
1440 make_scoped_refptr(GetRequestContext()), | 1440 make_scoped_refptr(GetRequestContext()), |
1441 make_scoped_refptr(BrowserContext::GetAppCacheService(this)))); | 1441 BrowserContext::GetAppCacheService(this))); |
1442 } | 1442 } |
1443 | 1443 |
1444 void ProfileImpl::UpdateProfileUserNameCache() { | 1444 void ProfileImpl::UpdateProfileUserNameCache() { |
1445 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 1445 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
1446 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); | 1446 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); |
1447 size_t index = cache.GetIndexOfProfileWithPath(GetPath()); | 1447 size_t index = cache.GetIndexOfProfileWithPath(GetPath()); |
1448 if (index != std::string::npos) { | 1448 if (index != std::string::npos) { |
1449 std::string user_name = | 1449 std::string user_name = |
1450 GetPrefs()->GetString(prefs::kGoogleServicesUsername); | 1450 GetPrefs()->GetString(prefs::kGoogleServicesUsername); |
1451 cache.SetUserNameOfProfileAtIndex(index, UTF8ToUTF16(user_name)); | 1451 cache.SetUserNameOfProfileAtIndex(index, UTF8ToUTF16(user_name)); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1483 FilePath* cache_path, | 1483 FilePath* cache_path, |
1484 int* max_size) { | 1484 int* max_size) { |
1485 DCHECK(cache_path); | 1485 DCHECK(cache_path); |
1486 DCHECK(max_size); | 1486 DCHECK(max_size); |
1487 FilePath path(prefs_->GetFilePath(prefs::kDiskCacheDir)); | 1487 FilePath path(prefs_->GetFilePath(prefs::kDiskCacheDir)); |
1488 if (!path.empty()) | 1488 if (!path.empty()) |
1489 *cache_path = path; | 1489 *cache_path = path; |
1490 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) : | 1490 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) : |
1491 prefs_->GetInteger(prefs::kDiskCacheSize); | 1491 prefs_->GetInteger(prefs::kDiskCacheSize); |
1492 } | 1492 } |
OLD | NEW |