| 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_io_data.h" | 5 #include "chrome/browser/profiles/profile_impl_io_data.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/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 return; | 222 return; |
| 223 | 223 |
| 224 // Set initialized_ to true at the beginning in case any of the objects | 224 // Set initialized_ to true at the beginning in case any of the objects |
| 225 // below try to get the ResourceContext pointer. | 225 // below try to get the ResourceContext pointer. |
| 226 initialized_ = true; | 226 initialized_ = true; |
| 227 PrefService* pref_service = profile_->GetPrefs(); | 227 PrefService* pref_service = profile_->GetPrefs(); |
| 228 io_data_->set_http_server_properties_manager( | 228 io_data_->set_http_server_properties_manager( |
| 229 new chrome_browser_net::HttpServerPropertiesManager(pref_service)); | 229 new chrome_browser_net::HttpServerPropertiesManager(pref_service)); |
| 230 ChromeNetworkDelegate::InitializeReferrersEnabled( | 230 ChromeNetworkDelegate::InitializeReferrersEnabled( |
| 231 io_data_->enable_referrers(), pref_service); | 231 io_data_->enable_referrers(), pref_service); |
| 232 io_data_->clear_local_state_on_exit()->Init( | |
| 233 prefs::kClearSiteDataOnExit, pref_service, NULL); | |
| 234 io_data_->clear_local_state_on_exit()->MoveToThread(BrowserThread::IO); | |
| 235 io_data_->session_startup_pref()->Init( | 232 io_data_->session_startup_pref()->Init( |
| 236 prefs::kRestoreOnStartup, pref_service, NULL); | 233 prefs::kRestoreOnStartup, pref_service, NULL); |
| 237 io_data_->session_startup_pref()->MoveToThread(BrowserThread::IO); | 234 io_data_->session_startup_pref()->MoveToThread(BrowserThread::IO); |
| 238 #if defined(ENABLE_SAFE_BROWSING) | 235 #if defined(ENABLE_SAFE_BROWSING) |
| 239 io_data_->safe_browsing_enabled()->Init(prefs::kSafeBrowsingEnabled, | 236 io_data_->safe_browsing_enabled()->Init(prefs::kSafeBrowsingEnabled, |
| 240 pref_service, NULL); | 237 pref_service, NULL); |
| 241 io_data_->safe_browsing_enabled()->MoveToThread(BrowserThread::IO); | 238 io_data_->safe_browsing_enabled()->MoveToThread(BrowserThread::IO); |
| 242 #endif | 239 #endif |
| 243 io_data_->InitializeOnUIThread(profile_); | 240 io_data_->InitializeOnUIThread(profile_); |
| 244 } | 241 } |
| 245 | 242 |
| 246 ProfileImplIOData::LazyParams::LazyParams() | 243 ProfileImplIOData::LazyParams::LazyParams() |
| 247 : cache_max_size(0), | 244 : cache_max_size(0), |
| 248 media_cache_max_size(0), | 245 media_cache_max_size(0), |
| 249 restore_old_session_cookies(false) {} | 246 restore_old_session_cookies(false) {} |
| 250 | 247 |
| 251 ProfileImplIOData::LazyParams::~LazyParams() {} | 248 ProfileImplIOData::LazyParams::~LazyParams() {} |
| 252 | 249 |
| 253 ProfileImplIOData::ProfileImplIOData() | 250 ProfileImplIOData::ProfileImplIOData() |
| 254 : ProfileIOData(false), | 251 : ProfileIOData(false) {} |
| 255 clear_local_state_on_exit_(false) {} | |
| 256 ProfileImplIOData::~ProfileImplIOData() { | 252 ProfileImplIOData::~ProfileImplIOData() { |
| 257 DestroyResourceContext(); | 253 DestroyResourceContext(); |
| 258 | 254 |
| 259 if (media_request_context_.get()) | 255 if (media_request_context_.get()) |
| 260 media_request_context_->AssertNoURLRequests(); | 256 media_request_context_->AssertNoURLRequests(); |
| 261 } | 257 } |
| 262 | 258 |
| 263 void ProfileImplIOData::LazyInitializeInternal( | 259 void ProfileImplIOData::LazyInitializeInternal( |
| 264 ProfileParams* profile_params) const { | 260 ProfileParams* profile_params) const { |
| 265 // Keep track of clear_local_state_on_exit for isolated apps. | |
| 266 clear_local_state_on_exit_ = profile_params->clear_local_state_on_exit; | |
| 267 | |
| 268 ChromeURLRequestContext* main_context = main_request_context(); | 261 ChromeURLRequestContext* main_context = main_request_context(); |
| 269 ChromeURLRequestContext* extensions_context = extensions_request_context(); | 262 ChromeURLRequestContext* extensions_context = extensions_request_context(); |
| 270 media_request_context_.reset(new ChromeURLRequestContext); | 263 media_request_context_.reset(new ChromeURLRequestContext); |
| 271 | 264 |
| 272 IOThread* const io_thread = profile_params->io_thread; | 265 IOThread* const io_thread = profile_params->io_thread; |
| 273 IOThread::Globals* const io_thread_globals = io_thread->globals(); | 266 IOThread::Globals* const io_thread_globals = io_thread->globals(); |
| 274 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 267 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 275 bool record_mode = chrome::kRecordModeEnabled && | 268 bool record_mode = chrome::kRecordModeEnabled && |
| 276 command_line.HasSwitch(switches::kRecordMode); | 269 command_line.HasSwitch(switches::kRecordMode); |
| 277 bool playback_mode = command_line.HasSwitch(switches::kPlaybackMode); | 270 bool playback_mode = command_line.HasSwitch(switches::kPlaybackMode); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 | 336 |
| 344 // setup cookie store | 337 // setup cookie store |
| 345 if (!cookie_store) { | 338 if (!cookie_store) { |
| 346 DCHECK(!lazy_params_->cookie_path.empty()); | 339 DCHECK(!lazy_params_->cookie_path.empty()); |
| 347 | 340 |
| 348 scoped_refptr<SQLitePersistentCookieStore> cookie_db = | 341 scoped_refptr<SQLitePersistentCookieStore> cookie_db = |
| 349 new SQLitePersistentCookieStore( | 342 new SQLitePersistentCookieStore( |
| 350 lazy_params_->cookie_path, | 343 lazy_params_->cookie_path, |
| 351 lazy_params_->restore_old_session_cookies, | 344 lazy_params_->restore_old_session_cookies, |
| 352 new ClearOnExitPolicy(lazy_params_->special_storage_policy)); | 345 new ClearOnExitPolicy(lazy_params_->special_storage_policy)); |
| 353 cookie_db->SetClearLocalStateOnExit( | |
| 354 profile_params->clear_local_state_on_exit); | |
| 355 cookie_store = | 346 cookie_store = |
| 356 new net::CookieMonster(cookie_db.get(), | 347 new net::CookieMonster(cookie_db.get(), |
| 357 profile_params->cookie_monster_delegate); | 348 profile_params->cookie_monster_delegate); |
| 358 if (!command_line.HasSwitch(switches::kDisableRestoreSessionState)) | 349 if (!command_line.HasSwitch(switches::kDisableRestoreSessionState)) |
| 359 cookie_store->GetCookieMonster()->SetPersistSessionCookies(true); | 350 cookie_store->GetCookieMonster()->SetPersistSessionCookies(true); |
| 360 } | 351 } |
| 361 | 352 |
| 362 net::CookieMonster* extensions_cookie_store = | 353 net::CookieMonster* extensions_cookie_store = |
| 363 new net::CookieMonster( | 354 new net::CookieMonster( |
| 364 new SQLitePersistentCookieStore( | 355 new SQLitePersistentCookieStore( |
| 365 lazy_params_->extensions_cookie_path, | 356 lazy_params_->extensions_cookie_path, |
| 366 lazy_params_->restore_old_session_cookies, NULL), NULL); | 357 lazy_params_->restore_old_session_cookies, NULL), NULL); |
| 367 // Enable cookies for devtools and extension URLs. | 358 // Enable cookies for devtools and extension URLs. |
| 368 const char* schemes[] = {chrome::kChromeDevToolsScheme, | 359 const char* schemes[] = {chrome::kChromeDevToolsScheme, |
| 369 chrome::kExtensionScheme}; | 360 chrome::kExtensionScheme}; |
| 370 extensions_cookie_store->SetCookieableSchemes(schemes, 2); | 361 extensions_cookie_store->SetCookieableSchemes(schemes, 2); |
| 371 | 362 |
| 372 main_context->set_cookie_store(cookie_store); | 363 main_context->set_cookie_store(cookie_store); |
| 373 media_request_context_->set_cookie_store(cookie_store); | 364 media_request_context_->set_cookie_store(cookie_store); |
| 374 extensions_context->set_cookie_store(extensions_cookie_store); | 365 extensions_context->set_cookie_store(extensions_cookie_store); |
| 375 | 366 |
| 376 // Setup server bound cert service. | 367 // Setup server bound cert service. |
| 377 if (!server_bound_cert_service) { | 368 if (!server_bound_cert_service) { |
| 378 DCHECK(!lazy_params_->server_bound_cert_path.empty()); | 369 DCHECK(!lazy_params_->server_bound_cert_path.empty()); |
| 379 | 370 |
| 380 scoped_refptr<SQLiteServerBoundCertStore> server_bound_cert_db = | 371 scoped_refptr<SQLiteServerBoundCertStore> server_bound_cert_db = |
| 381 new SQLiteServerBoundCertStore( | 372 new SQLiteServerBoundCertStore( |
| 382 lazy_params_->server_bound_cert_path, | 373 lazy_params_->server_bound_cert_path, |
| 383 new ClearOnExitPolicy(lazy_params_->special_storage_policy)); | 374 new ClearOnExitPolicy(lazy_params_->special_storage_policy)); |
| 384 server_bound_cert_db->SetClearLocalStateOnExit( | |
| 385 profile_params->clear_local_state_on_exit); | |
| 386 server_bound_cert_service = new net::ServerBoundCertService( | 375 server_bound_cert_service = new net::ServerBoundCertService( |
| 387 new net::DefaultServerBoundCertStore(server_bound_cert_db.get()), | 376 new net::DefaultServerBoundCertStore(server_bound_cert_db.get()), |
| 388 base::WorkerPool::GetTaskRunner(true)); | 377 base::WorkerPool::GetTaskRunner(true)); |
| 389 } | 378 } |
| 390 | 379 |
| 391 set_server_bound_cert_service(server_bound_cert_service); | 380 set_server_bound_cert_service(server_bound_cert_service); |
| 392 main_context->set_server_bound_cert_service(server_bound_cert_service); | 381 main_context->set_server_bound_cert_service(server_bound_cert_service); |
| 393 media_request_context_->set_server_bound_cert_service( | 382 media_request_context_->set_server_bound_cert_service( |
| 394 server_bound_cert_service); | 383 server_bound_cert_service); |
| 395 | 384 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 app_http_cache->set_mode( | 487 app_http_cache->set_mode( |
| 499 record_mode ? net::HttpCache::RECORD : net::HttpCache::PLAYBACK); | 488 record_mode ? net::HttpCache::RECORD : net::HttpCache::PLAYBACK); |
| 500 } | 489 } |
| 501 | 490 |
| 502 // Use an app-specific cookie store. | 491 // Use an app-specific cookie store. |
| 503 if (!cookie_store) { | 492 if (!cookie_store) { |
| 504 DCHECK(!cookie_path.empty()); | 493 DCHECK(!cookie_path.empty()); |
| 505 | 494 |
| 506 scoped_refptr<SQLitePersistentCookieStore> cookie_db = | 495 scoped_refptr<SQLitePersistentCookieStore> cookie_db = |
| 507 new SQLitePersistentCookieStore(cookie_path, false, NULL); | 496 new SQLitePersistentCookieStore(cookie_path, false, NULL); |
| 508 cookie_db->SetClearLocalStateOnExit(clear_local_state_on_exit_); | |
| 509 // TODO(creis): We should have a cookie delegate for notifying the cookie | 497 // TODO(creis): We should have a cookie delegate for notifying the cookie |
| 510 // extensions API, but we need to update it to understand isolated apps | 498 // extensions API, but we need to update it to understand isolated apps |
| 511 // first. | 499 // first. |
| 512 cookie_store = new net::CookieMonster(cookie_db.get(), NULL); | 500 cookie_store = new net::CookieMonster(cookie_db.get(), NULL); |
| 513 } | 501 } |
| 514 | 502 |
| 515 context->SetCookieStore(cookie_store); | 503 context->SetCookieStore(cookie_store); |
| 516 context->SetHttpTransactionFactory(app_http_cache); | 504 context->SetHttpTransactionFactory(app_http_cache); |
| 517 | 505 |
| 518 return context; | 506 return context; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 538 void ProfileImplIOData::ClearNetworkingHistorySinceOnIOThread( | 526 void ProfileImplIOData::ClearNetworkingHistorySinceOnIOThread( |
| 539 base::Time time) { | 527 base::Time time) { |
| 540 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 528 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 541 LazyInitialize(); | 529 LazyInitialize(); |
| 542 | 530 |
| 543 DCHECK(transport_security_state()); | 531 DCHECK(transport_security_state()); |
| 544 transport_security_state()->DeleteSince(time); | 532 transport_security_state()->DeleteSince(time); |
| 545 DCHECK(http_server_properties_manager()); | 533 DCHECK(http_server_properties_manager()); |
| 546 http_server_properties_manager()->Clear(); | 534 http_server_properties_manager()->Clear(); |
| 547 } | 535 } |
| OLD | NEW |