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

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

Issue 10407124: Don't force non-session only cookies to be session only cookies, instead delete on shutdown (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updates Created 8 years, 6 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) 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"
11 #include "base/stl_util.h" 11 #include "base/stl_util.h"
12 #include "base/threading/worker_pool.h" 12 #include "base/threading/worker_pool.h"
13 #include "chrome/browser/io_thread.h" 13 #include "chrome/browser/io_thread.h"
14 #include "chrome/browser/net/chrome_net_log.h" 14 #include "chrome/browser/net/chrome_net_log.h"
15 #include "chrome/browser/net/chrome_network_delegate.h" 15 #include "chrome/browser/net/chrome_network_delegate.h"
16 #include "chrome/browser/net/clear_on_exit_policy.h"
16 #include "chrome/browser/net/connect_interceptor.h" 17 #include "chrome/browser/net/connect_interceptor.h"
17 #include "chrome/browser/net/http_server_properties_manager.h" 18 #include "chrome/browser/net/http_server_properties_manager.h"
18 #include "chrome/browser/net/predictor.h" 19 #include "chrome/browser/net/predictor.h"
19 #include "chrome/browser/net/sqlite_persistent_cookie_store.h" 20 #include "chrome/browser/net/sqlite_persistent_cookie_store.h"
20 #include "chrome/browser/net/sqlite_server_bound_cert_store.h" 21 #include "chrome/browser/net/sqlite_server_bound_cert_store.h"
21 #include "chrome/browser/prefs/pref_member.h" 22 #include "chrome/browser/prefs/pref_member.h"
22 #include "chrome/browser/profiles/profile.h" 23 #include "chrome/browser/profiles/profile.h"
23 #include "chrome/common/chrome_constants.h" 24 #include "chrome/common/chrome_constants.h"
24 #include "chrome/common/chrome_switches.h" 25 #include "chrome/common/chrome_switches.h"
25 #include "chrome/common/pref_names.h" 26 #include "chrome/common/pref_names.h"
26 #include "chrome/common/url_constants.h" 27 #include "chrome/common/url_constants.h"
27 #include "content/public/browser/browser_thread.h" 28 #include "content/public/browser/browser_thread.h"
28 #include "content/public/browser/resource_context.h" 29 #include "content/public/browser/resource_context.h"
29 #include "net/base/server_bound_cert_service.h" 30 #include "net/base/server_bound_cert_service.h"
30 #include "net/ftp/ftp_network_layer.h" 31 #include "net/ftp/ftp_network_layer.h"
31 #include "net/http/http_cache.h" 32 #include "net/http/http_cache.h"
32 #include "net/url_request/url_request_job_factory.h" 33 #include "net/url_request/url_request_job_factory.h"
34 #include "webkit/quota/special_storage_policy.h"
33 35
34 using content::BrowserThread; 36 using content::BrowserThread;
35 37
36 ProfileImplIOData::Handle::Handle(Profile* profile) 38 ProfileImplIOData::Handle::Handle(Profile* profile)
37 : io_data_(new ProfileImplIOData), 39 : io_data_(new ProfileImplIOData),
38 profile_(profile), 40 profile_(profile),
39 initialized_(false) { 41 initialized_(false) {
40 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 42 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
41 DCHECK(profile); 43 DCHECK(profile);
42 } 44 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 const FilePath& server_bound_cert_path, 77 const FilePath& server_bound_cert_path,
76 const FilePath& cache_path, 78 const FilePath& cache_path,
77 int cache_max_size, 79 int cache_max_size,
78 const FilePath& media_cache_path, 80 const FilePath& media_cache_path,
79 int media_cache_max_size, 81 int media_cache_max_size,
80 const FilePath& extensions_cookie_path, 82 const FilePath& extensions_cookie_path,
81 const FilePath& app_path, 83 const FilePath& app_path,
82 chrome_browser_net::Predictor* predictor, 84 chrome_browser_net::Predictor* predictor,
83 PrefService* local_state, 85 PrefService* local_state,
84 IOThread* io_thread, 86 IOThread* io_thread,
85 bool restore_old_session_cookies) { 87 bool restore_old_session_cookies,
88 quota::SpecialStoragePolicy* special_storage_policy) {
86 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 89 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
87 DCHECK(!io_data_->lazy_params_.get()); 90 DCHECK(!io_data_->lazy_params_.get());
88 DCHECK(predictor); 91 DCHECK(predictor);
89 92
90 LazyParams* lazy_params = new LazyParams; 93 LazyParams* lazy_params = new LazyParams;
91 94
92 lazy_params->cookie_path = cookie_path; 95 lazy_params->cookie_path = cookie_path;
93 lazy_params->server_bound_cert_path = server_bound_cert_path; 96 lazy_params->server_bound_cert_path = server_bound_cert_path;
94 lazy_params->cache_path = cache_path; 97 lazy_params->cache_path = cache_path;
95 lazy_params->cache_max_size = cache_max_size; 98 lazy_params->cache_max_size = cache_max_size;
96 lazy_params->media_cache_path = media_cache_path; 99 lazy_params->media_cache_path = media_cache_path;
97 lazy_params->media_cache_max_size = media_cache_max_size; 100 lazy_params->media_cache_max_size = media_cache_max_size;
98 lazy_params->extensions_cookie_path = extensions_cookie_path; 101 lazy_params->extensions_cookie_path = extensions_cookie_path;
99 lazy_params->restore_old_session_cookies = restore_old_session_cookies; 102 lazy_params->restore_old_session_cookies = restore_old_session_cookies;
103 lazy_params->special_storage_policy = special_storage_policy;
100 104
101 io_data_->lazy_params_.reset(lazy_params); 105 io_data_->lazy_params_.reset(lazy_params);
102 106
103 // Keep track of isolated app path separately so we can use it on demand. 107 // Keep track of isolated app path separately so we can use it on demand.
104 io_data_->app_path_ = app_path; 108 io_data_->app_path_ = app_path;
105 109
106 io_data_->predictor_.reset(predictor); 110 io_data_->predictor_.reset(predictor);
107 111
108 if (!main_request_context_getter_) { 112 if (!main_request_context_getter_) {
109 main_request_context_getter_ = 113 main_request_context_getter_ =
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 base::WorkerPool::GetTaskRunner(true)); 341 base::WorkerPool::GetTaskRunner(true));
338 } 342 }
339 343
340 // setup cookie store 344 // setup cookie store
341 if (!cookie_store) { 345 if (!cookie_store) {
342 DCHECK(!lazy_params_->cookie_path.empty()); 346 DCHECK(!lazy_params_->cookie_path.empty());
343 347
344 scoped_refptr<SQLitePersistentCookieStore> cookie_db = 348 scoped_refptr<SQLitePersistentCookieStore> cookie_db =
345 new SQLitePersistentCookieStore( 349 new SQLitePersistentCookieStore(
346 lazy_params_->cookie_path, 350 lazy_params_->cookie_path,
347 lazy_params_->restore_old_session_cookies); 351 lazy_params_->restore_old_session_cookies,
352 new ClearOnExitPolicy(lazy_params_->special_storage_policy));
348 cookie_db->SetClearLocalStateOnExit( 353 cookie_db->SetClearLocalStateOnExit(
349 profile_params->clear_local_state_on_exit); 354 profile_params->clear_local_state_on_exit);
350 cookie_store = 355 cookie_store =
351 new net::CookieMonster(cookie_db.get(), 356 new net::CookieMonster(cookie_db.get(),
352 profile_params->cookie_monster_delegate); 357 profile_params->cookie_monster_delegate);
353 if (!command_line.HasSwitch(switches::kDisableRestoreSessionState)) 358 if (!command_line.HasSwitch(switches::kDisableRestoreSessionState))
354 cookie_store->GetCookieMonster()->SetPersistSessionCookies(true); 359 cookie_store->GetCookieMonster()->SetPersistSessionCookies(true);
355 } 360 }
356 361
357 net::CookieMonster* extensions_cookie_store = 362 net::CookieMonster* extensions_cookie_store =
358 new net::CookieMonster( 363 new net::CookieMonster(
359 new SQLitePersistentCookieStore( 364 new SQLitePersistentCookieStore(
360 lazy_params_->extensions_cookie_path, 365 lazy_params_->extensions_cookie_path,
361 lazy_params_->restore_old_session_cookies), NULL); 366 lazy_params_->restore_old_session_cookies, NULL), NULL);
362 // Enable cookies for devtools and extension URLs. 367 // Enable cookies for devtools and extension URLs.
363 const char* schemes[] = {chrome::kChromeDevToolsScheme, 368 const char* schemes[] = {chrome::kChromeDevToolsScheme,
364 chrome::kExtensionScheme}; 369 chrome::kExtensionScheme};
365 extensions_cookie_store->SetCookieableSchemes(schemes, 2); 370 extensions_cookie_store->SetCookieableSchemes(schemes, 2);
366 371
367 main_context->set_cookie_store(cookie_store); 372 main_context->set_cookie_store(cookie_store);
368 media_request_context_->set_cookie_store(cookie_store); 373 media_request_context_->set_cookie_store(cookie_store);
369 extensions_context->set_cookie_store(extensions_cookie_store); 374 extensions_context->set_cookie_store(extensions_cookie_store);
370 375
371 // Setup server bound cert service. 376 // Setup server bound cert service.
372 if (!server_bound_cert_service) { 377 if (!server_bound_cert_service) {
373 DCHECK(!lazy_params_->server_bound_cert_path.empty()); 378 DCHECK(!lazy_params_->server_bound_cert_path.empty());
374 379
375 scoped_refptr<SQLiteServerBoundCertStore> server_bound_cert_db = 380 scoped_refptr<SQLiteServerBoundCertStore> server_bound_cert_db =
376 new SQLiteServerBoundCertStore(lazy_params_->server_bound_cert_path); 381 new SQLiteServerBoundCertStore(
382 lazy_params_->server_bound_cert_path,
383 new ClearOnExitPolicy(lazy_params_->special_storage_policy));
377 server_bound_cert_db->SetClearLocalStateOnExit( 384 server_bound_cert_db->SetClearLocalStateOnExit(
378 profile_params->clear_local_state_on_exit); 385 profile_params->clear_local_state_on_exit);
379 server_bound_cert_service = new net::ServerBoundCertService( 386 server_bound_cert_service = new net::ServerBoundCertService(
380 new net::DefaultServerBoundCertStore(server_bound_cert_db.get()), 387 new net::DefaultServerBoundCertStore(server_bound_cert_db.get()),
381 base::WorkerPool::GetTaskRunner(true)); 388 base::WorkerPool::GetTaskRunner(true));
382 } 389 }
383 390
384 set_server_bound_cert_service(server_bound_cert_service); 391 set_server_bound_cert_service(server_bound_cert_service);
385 main_context->set_server_bound_cert_service(server_bound_cert_service); 392 main_context->set_server_bound_cert_service(server_bound_cert_service);
386 media_request_context_->set_server_bound_cert_service( 393 media_request_context_->set_server_bound_cert_service(
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 cookie_store = new net::CookieMonster(NULL, NULL); 497 cookie_store = new net::CookieMonster(NULL, NULL);
491 app_http_cache->set_mode( 498 app_http_cache->set_mode(
492 record_mode ? net::HttpCache::RECORD : net::HttpCache::PLAYBACK); 499 record_mode ? net::HttpCache::RECORD : net::HttpCache::PLAYBACK);
493 } 500 }
494 501
495 // Use an app-specific cookie store. 502 // Use an app-specific cookie store.
496 if (!cookie_store) { 503 if (!cookie_store) {
497 DCHECK(!cookie_path.empty()); 504 DCHECK(!cookie_path.empty());
498 505
499 scoped_refptr<SQLitePersistentCookieStore> cookie_db = 506 scoped_refptr<SQLitePersistentCookieStore> cookie_db =
500 new SQLitePersistentCookieStore(cookie_path, false); 507 new SQLitePersistentCookieStore(cookie_path, false, NULL);
501 cookie_db->SetClearLocalStateOnExit(clear_local_state_on_exit_); 508 cookie_db->SetClearLocalStateOnExit(clear_local_state_on_exit_);
502 // TODO(creis): We should have a cookie delegate for notifying the cookie 509 // TODO(creis): We should have a cookie delegate for notifying the cookie
503 // extensions API, but we need to update it to understand isolated apps 510 // extensions API, but we need to update it to understand isolated apps
504 // first. 511 // first.
505 cookie_store = new net::CookieMonster(cookie_db.get(), NULL); 512 cookie_store = new net::CookieMonster(cookie_db.get(), NULL);
506 } 513 }
507 514
508 context->SetCookieStore(cookie_store); 515 context->SetCookieStore(cookie_store);
509 context->SetHttpTransactionFactory(app_http_cache); 516 context->SetHttpTransactionFactory(app_http_cache);
510 517
(...skipping 20 matching lines...) Expand all
531 void ProfileImplIOData::ClearNetworkingHistorySinceOnIOThread( 538 void ProfileImplIOData::ClearNetworkingHistorySinceOnIOThread(
532 base::Time time) { 539 base::Time time) {
533 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 540 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
534 LazyInitialize(); 541 LazyInitialize();
535 542
536 DCHECK(transport_security_state()); 543 DCHECK(transport_security_state());
537 transport_security_state()->DeleteSince(time); 544 transport_security_state()->DeleteSince(time);
538 DCHECK(http_server_properties_manager()); 545 DCHECK(http_server_properties_manager());
539 http_server_properties_manager()->Clear(); 546 http_server_properties_manager()->Clear();
540 } 547 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_impl_io_data.h ('k') | chrome/browser/profiles/profile_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698