| 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_io_data.h" | 5 #include "chrome/browser/profiles/profile_io_data.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 // types a URL in the omnibar or click on a download link in a page. | 181 // types a URL in the omnibar or click on a download link in a page. |
| 182 // For the latter, we need a change on the webkit-side. | 182 // For the latter, we need a change on the webkit-side. |
| 183 // We initialize it to the default charset here and a user will | 183 // We initialize it to the default charset here and a user will |
| 184 // have an *arguably* better default charset for interpreting a raw 8bit | 184 // have an *arguably* better default charset for interpreting a raw 8bit |
| 185 // C-D header field. It means the native OS codepage fallback in | 185 // C-D header field. It means the native OS codepage fallback in |
| 186 // net_util::GetSuggestedFilename is unlikely to be taken. | 186 // net_util::GetSuggestedFilename is unlikely to be taken. |
| 187 params->referrer_charset = default_charset; | 187 params->referrer_charset = default_charset; |
| 188 | 188 |
| 189 params->io_thread = g_browser_process->io_thread(); | 189 params->io_thread = g_browser_process->io_thread(); |
| 190 | 190 |
| 191 params->host_content_settings_map = profile->GetHostContentSettingsMap(); | |
| 192 params->cookie_settings = CookieSettings::Factory::GetForProfile(profile); | 191 params->cookie_settings = CookieSettings::Factory::GetForProfile(profile); |
| 193 params->ssl_config_service = profile->GetSSLConfigService(); | 192 params->ssl_config_service = profile->GetSSLConfigService(); |
| 194 base::Callback<Profile*(void)> profile_getter = | 193 base::Callback<Profile*(void)> profile_getter = |
| 195 base::Bind(&GetProfileOnUI, g_browser_process->profile_manager(), | 194 base::Bind(&GetProfileOnUI, g_browser_process->profile_manager(), |
| 196 profile); | 195 profile); |
| 197 params->cookie_monster_delegate = | 196 params->cookie_monster_delegate = |
| 198 new ChromeCookieMonsterDelegate(profile_getter); | 197 new ChromeCookieMonsterDelegate(profile_getter); |
| 199 params->extension_info_map = | 198 params->extension_info_map = |
| 200 ExtensionSystem::Get(profile)->info_map(); | 199 ExtensionSystem::Get(profile)->info_map(); |
| 201 | 200 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 clear_local_state_on_exit(false), | 250 clear_local_state_on_exit(false), |
| 252 io_thread(NULL), | 251 io_thread(NULL), |
| 253 #if defined(ENABLE_NOTIFICATIONS) | 252 #if defined(ENABLE_NOTIFICATIONS) |
| 254 notification_service(NULL), | 253 notification_service(NULL), |
| 255 #endif | 254 #endif |
| 256 profile(NULL) {} | 255 profile(NULL) {} |
| 257 ProfileIOData::ProfileParams::~ProfileParams() {} | 256 ProfileIOData::ProfileParams::~ProfileParams() {} |
| 258 | 257 |
| 259 ProfileIOData::ProfileIOData(bool is_incognito) | 258 ProfileIOData::ProfileIOData(bool is_incognito) |
| 260 : initialized_(false), | 259 : initialized_(false), |
| 261 ALLOW_THIS_IN_INITIALIZER_LIST(resource_context_(this)), | 260 ALLOW_THIS_IN_INITIALIZER_LIST( |
| 261 resource_context_(new ResourceContext(this))), |
| 262 initialized_on_UI_thread_(false) { | 262 initialized_on_UI_thread_(false) { |
| 263 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 263 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 264 } | 264 } |
| 265 | 265 |
| 266 ProfileIOData::~ProfileIOData() { | 266 ProfileIOData::~ProfileIOData() { |
| 267 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) | 267 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) |
| 268 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 268 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 269 | 269 |
| 270 #if 0 | 270 #if 0 |
| 271 // TODO(willchan): If I am ever able to enable this assertion and have it | 271 // TODO(willchan): If I am ever able to enable this assertion and have it |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 bool ProfileIOData::IsHandledURL(const GURL& url) { | 310 bool ProfileIOData::IsHandledURL(const GURL& url) { |
| 311 if (!url.is_valid()) { | 311 if (!url.is_valid()) { |
| 312 // We handle error cases. | 312 // We handle error cases. |
| 313 return true; | 313 return true; |
| 314 } | 314 } |
| 315 | 315 |
| 316 return IsHandledProtocol(url.scheme()); | 316 return IsHandledProtocol(url.scheme()); |
| 317 } | 317 } |
| 318 | 318 |
| 319 content::ResourceContext* ProfileIOData::GetResourceContext() const { | 319 content::ResourceContext* ProfileIOData::GetResourceContext() const { |
| 320 return &resource_context_; | 320 return resource_context_.get(); |
| 321 } | 321 } |
| 322 | 322 |
| 323 ChromeURLDataManagerBackend* | 323 ChromeURLDataManagerBackend* |
| 324 ProfileIOData::GetChromeURLDataManagerBackend() const { | 324 ProfileIOData::GetChromeURLDataManagerBackend() const { |
| 325 LazyInitialize(); | 325 LazyInitialize(); |
| 326 return chrome_url_data_manager_backend_.get(); | 326 return chrome_url_data_manager_backend_.get(); |
| 327 } | 327 } |
| 328 | 328 |
| 329 scoped_refptr<ChromeURLRequestContext> | 329 scoped_refptr<ChromeURLRequestContext> |
| 330 ProfileIOData::GetMainRequestContext() const { | 330 ProfileIOData::GetMainRequestContext() const { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 360 app_request_context_map_[app_id] = context; | 360 app_request_context_map_[app_id] = context; |
| 361 } | 361 } |
| 362 DCHECK(context); | 362 DCHECK(context); |
| 363 return context; | 363 return context; |
| 364 } | 364 } |
| 365 | 365 |
| 366 ExtensionInfoMap* ProfileIOData::GetExtensionInfoMap() const { | 366 ExtensionInfoMap* ProfileIOData::GetExtensionInfoMap() const { |
| 367 return extension_info_map_; | 367 return extension_info_map_; |
| 368 } | 368 } |
| 369 | 369 |
| 370 HostContentSettingsMap* ProfileIOData::GetHostContentSettingsMap() const { | |
| 371 return host_content_settings_map_; | |
| 372 } | |
| 373 | |
| 374 CookieSettings* ProfileIOData::GetCookieSettings() const { | 370 CookieSettings* ProfileIOData::GetCookieSettings() const { |
| 375 return cookie_settings_; | 371 return cookie_settings_; |
| 376 } | 372 } |
| 377 | 373 |
| 378 #if defined(ENABLE_NOTIFICATIONS) | 374 #if defined(ENABLE_NOTIFICATIONS) |
| 379 DesktopNotificationService* ProfileIOData::GetNotificationService() const { | 375 DesktopNotificationService* ProfileIOData::GetNotificationService() const { |
| 380 return notification_service_; | 376 return notification_service_; |
| 381 } | 377 } |
| 382 #endif | 378 #endif |
| 383 | 379 |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 DCHECK(set_protocol); | 492 DCHECK(set_protocol); |
| 497 #if defined(OS_CHROMEOS) && !defined(GOOGLE_CHROME_BUILD) | 493 #if defined(OS_CHROMEOS) && !defined(GOOGLE_CHROME_BUILD) |
| 498 // Install the GView request interceptor that will redirect requests | 494 // Install the GView request interceptor that will redirect requests |
| 499 // of compatible documents (PDF, etc) to the GView document viewer. | 495 // of compatible documents (PDF, etc) to the GView document viewer. |
| 500 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); | 496 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); |
| 501 if (parsed_command_line.HasSwitch(switches::kEnableGView)) | 497 if (parsed_command_line.HasSwitch(switches::kEnableGView)) |
| 502 job_factory_->AddInterceptor(new chromeos::GViewRequestInterceptor); | 498 job_factory_->AddInterceptor(new chromeos::GViewRequestInterceptor); |
| 503 #endif // defined(OS_CHROMEOS) && !defined(GOOGLE_CHROME_BUILD) | 499 #endif // defined(OS_CHROMEOS) && !defined(GOOGLE_CHROME_BUILD) |
| 504 | 500 |
| 505 // Take ownership over these parameters. | 501 // Take ownership over these parameters. |
| 506 host_content_settings_map_ = profile_params_->host_content_settings_map; | |
| 507 cookie_settings_ = profile_params_->cookie_settings; | 502 cookie_settings_ = profile_params_->cookie_settings; |
| 508 #if defined(ENABLE_NOTIFICATIONS) | 503 #if defined(ENABLE_NOTIFICATIONS) |
| 509 notification_service_ = profile_params_->notification_service; | 504 notification_service_ = profile_params_->notification_service; |
| 510 #endif | 505 #endif |
| 511 extension_info_map_ = profile_params_->extension_info_map; | 506 extension_info_map_ = profile_params_->extension_info_map; |
| 512 | 507 |
| 513 resource_context_.host_resolver_ = io_thread_globals->host_resolver.get(); | 508 resource_context_->host_resolver_ = io_thread_globals->host_resolver.get(); |
| 514 resource_context_.request_context_ = main_request_context_; | 509 resource_context_->request_context_ = main_request_context_; |
| 515 | 510 |
| 516 LazyInitializeInternal(profile_params_.get()); | 511 LazyInitializeInternal(profile_params_.get()); |
| 517 | 512 |
| 518 profile_params_.reset(); | 513 profile_params_.reset(); |
| 519 initialized_ = true; | 514 initialized_ = true; |
| 520 } | 515 } |
| 521 | 516 |
| 522 void ProfileIOData::ApplyProfileParamsToContext( | 517 void ProfileIOData::ApplyProfileParamsToContext( |
| 523 ChromeURLRequestContext* context) const { | 518 ChromeURLRequestContext* context) const { |
| 524 context->set_is_incognito(profile_params_->is_incognito); | 519 context->set_is_incognito(profile_params_->is_incognito); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 540 #endif | 535 #endif |
| 541 bool posted = BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, this); | 536 bool posted = BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, this); |
| 542 if (!posted) | 537 if (!posted) |
| 543 delete this; | 538 delete this; |
| 544 } | 539 } |
| 545 | 540 |
| 546 void ProfileIOData::set_server_bound_cert_service( | 541 void ProfileIOData::set_server_bound_cert_service( |
| 547 net::ServerBoundCertService* server_bound_cert_service) const { | 542 net::ServerBoundCertService* server_bound_cert_service) const { |
| 548 server_bound_cert_service_.reset(server_bound_cert_service); | 543 server_bound_cert_service_.reset(server_bound_cert_service); |
| 549 } | 544 } |
| 545 |
| 546 void ProfileIOData::DestroyResourceContext() { |
| 547 resource_context_.reset(); |
| 548 } |
| OLD | NEW |