Chromium Code Reviews| 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.h" | 5 #include "chrome/browser/profiles/profile.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "app/resource_bundle.h" | 9 #include "app/resource_bundle.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 24 #include "chrome/browser/file_system/browser_file_system_helper.h" | 24 #include "chrome/browser/file_system/browser_file_system_helper.h" |
| 25 #include "chrome/browser/in_process_webkit/webkit_context.h" | 25 #include "chrome/browser/in_process_webkit/webkit_context.h" |
| 26 #include "chrome/browser/net/chrome_url_request_context.h" | 26 #include "chrome/browser/net/chrome_url_request_context.h" |
| 27 #include "chrome/browser/notifications/desktop_notification_service.h" | 27 #include "chrome/browser/notifications/desktop_notification_service.h" |
| 28 #include "chrome/browser/ssl/ssl_host_state.h" | 28 #include "chrome/browser/ssl/ssl_host_state.h" |
| 29 #include "chrome/browser/sync/profile_sync_service.h" | 29 #include "chrome/browser/sync/profile_sync_service.h" |
| 30 #include "chrome/browser/themes/browser_theme_provider.h" | 30 #include "chrome/browser/themes/browser_theme_provider.h" |
| 31 #include "chrome/browser/ui/find_bar/find_bar_state.h" | 31 #include "chrome/browser/ui/find_bar/find_bar_state.h" |
| 32 #include "chrome/common/chrome_constants.h" | 32 #include "chrome/common/chrome_constants.h" |
| 33 #include "chrome/common/chrome_paths.h" | 33 #include "chrome/common/chrome_paths.h" |
| 34 #include "chrome/common/chrome_switches.h" | |
| 35 #include "chrome/common/extensions/extension.h" | |
| 34 #include "chrome/common/json_pref_store.h" | 36 #include "chrome/common/json_pref_store.h" |
| 35 #include "chrome/common/notification_service.h" | 37 #include "chrome/common/notification_service.h" |
| 36 #include "chrome/common/pref_names.h" | 38 #include "chrome/common/pref_names.h" |
| 37 #include "chrome/common/render_messages.h" | 39 #include "chrome/common/render_messages.h" |
| 38 #include "grit/browser_resources.h" | 40 #include "grit/browser_resources.h" |
| 39 #include "grit/locale_settings.h" | 41 #include "grit/locale_settings.h" |
| 40 #include "net/base/transport_security_state.h" | 42 #include "net/base/transport_security_state.h" |
| 41 #include "webkit/database/database_tracker.h" | 43 #include "webkit/database/database_tracker.h" |
| 42 | 44 |
| 43 #if defined(TOOLKIT_USES_GTK) | 45 #if defined(TOOLKIT_USES_GTK) |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 148 new BackgroundContentsService(this, CommandLine::ForCurrentProcess())); | 150 new BackgroundContentsService(this, CommandLine::ForCurrentProcess())); |
| 149 } | 151 } |
| 150 | 152 |
| 151 virtual ~OffTheRecordProfileImpl() { | 153 virtual ~OffTheRecordProfileImpl() { |
| 152 NotificationService::current()->Notify(NotificationType::PROFILE_DESTROYED, | 154 NotificationService::current()->Notify(NotificationType::PROFILE_DESTROYED, |
| 153 Source<Profile>(this), | 155 Source<Profile>(this), |
| 154 NotificationService::NoDetails()); | 156 NotificationService::NoDetails()); |
| 155 CleanupRequestContext(request_context_); | 157 CleanupRequestContext(request_context_); |
| 156 CleanupRequestContext(extensions_request_context_); | 158 CleanupRequestContext(extensions_request_context_); |
| 157 | 159 |
| 160 // Clean up all isolated app request contexts. | |
| 161 for (ChromeURLRequestContextGetterMap::iterator iter = | |
| 162 app_request_context_map_.begin(); | |
|
willchan no longer on Chromium
2011/01/26 23:21:52
Looks like you're missing a horizontal whitespace
Charlie Reis
2011/03/01 21:33:11
Done.
| |
| 163 iter != app_request_context_map_.end(); | |
| 164 iter++) { | |
|
willchan no longer on Chromium
2011/01/26 23:21:52
http://www.corp.google.com/eng/doc/cppguide.xml?ex
Charlie Reis
2011/03/01 21:33:11
Done.
| |
| 165 CleanupRequestContext(iter->second); | |
| 166 } | |
| 167 | |
| 158 // Clean up all DB files/directories | 168 // Clean up all DB files/directories |
| 159 BrowserThread::PostTask( | 169 BrowserThread::PostTask( |
| 160 BrowserThread::FILE, FROM_HERE, | 170 BrowserThread::FILE, FROM_HERE, |
| 161 NewRunnableMethod( | 171 NewRunnableMethod( |
| 162 db_tracker_.get(), | 172 db_tracker_.get(), |
| 163 &webkit_database::DatabaseTracker::DeleteIncognitoDBDirectory)); | 173 &webkit_database::DatabaseTracker::DeleteIncognitoDBDirectory)); |
| 164 | 174 |
| 165 BrowserList::RemoveObserver(this); | 175 BrowserList::RemoveObserver(this); |
| 166 } | 176 } |
| 167 | 177 |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 372 } | 382 } |
| 373 | 383 |
| 374 virtual BrowserThemeProvider* GetThemeProvider() { | 384 virtual BrowserThemeProvider* GetThemeProvider() { |
| 375 return profile_->GetThemeProvider(); | 385 return profile_->GetThemeProvider(); |
| 376 } | 386 } |
| 377 | 387 |
| 378 virtual URLRequestContextGetter* GetRequestContext() { | 388 virtual URLRequestContextGetter* GetRequestContext() { |
| 379 return request_context_; | 389 return request_context_; |
| 380 } | 390 } |
| 381 | 391 |
| 392 virtual URLRequestContextGetter* GetRequestContext(const Extension* app) { | |
| 393 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
| 394 switches::kEnableExperimentalAppManifests) | |
| 395 && app != NULL | |
|
willchan no longer on Chromium
2011/01/26 23:21:52
Put the && on the previous line as stated in http:
Charlie Reis
2011/03/01 21:33:11
Done.
| |
| 396 && app->is_storage_isolated()) | |
| 397 return GetRequestContextForIsolatedApp(app); | |
| 398 | |
| 399 return GetRequestContext(); | |
| 400 } | |
| 401 | |
| 382 virtual URLRequestContextGetter* GetRequestContextForMedia() { | 402 virtual URLRequestContextGetter* GetRequestContextForMedia() { |
| 383 // In OTR mode, media request context is the same as the original one. | 403 // In OTR mode, media request context is the same as the original one. |
| 384 return request_context_; | 404 return request_context_; |
| 385 } | 405 } |
| 386 | 406 |
| 387 URLRequestContextGetter* GetRequestContextForExtensions() { | 407 URLRequestContextGetter* GetRequestContextForExtensions() { |
| 388 if (!extensions_request_context_) { | 408 if (!extensions_request_context_) { |
| 389 extensions_request_context_ = | 409 extensions_request_context_ = |
| 390 ChromeURLRequestContextGetter::CreateOffTheRecordForExtensions(this); | 410 ChromeURLRequestContextGetter::CreateOffTheRecordForExtensions(this); |
| 391 } | 411 } |
| 392 | 412 |
| 393 return extensions_request_context_; | 413 return extensions_request_context_; |
| 394 } | 414 } |
| 395 | 415 |
| 416 URLRequestContextGetter* GetRequestContextForIsolatedApp( | |
| 417 const Extension* installed_app) { | |
| 418 CHECK(installed_app); | |
| 419 std::string id = installed_app->id(); | |
| 420 | |
| 421 // Keep a map of request contexts, one per requested app ID. Once created, | |
| 422 // the context will exist for the lifetime of the profile. | |
| 423 ChromeURLRequestContextGetterMap::iterator iter = | |
| 424 app_request_context_map_.find(id); | |
| 425 if (iter != app_request_context_map_.end()) | |
| 426 return iter->second; | |
| 427 | |
| 428 ChromeURLRequestContextGetter* context = | |
| 429 ChromeURLRequestContextGetter::CreateOffTheRecordForIsolatedApp(this, | |
|
willchan no longer on Chromium
2011/01/26 23:21:52
http://www.corp.google.com/eng/doc/cppguide.xml?ex
Charlie Reis
2011/03/01 21:33:11
Done.
| |
| 430 installed_app); | |
| 431 app_request_context_map_[id] = context; | |
| 432 | |
| 433 return context; | |
| 434 } | |
| 435 | |
| 396 virtual net::SSLConfigService* GetSSLConfigService() { | 436 virtual net::SSLConfigService* GetSSLConfigService() { |
| 397 return profile_->GetSSLConfigService(); | 437 return profile_->GetSSLConfigService(); |
| 398 } | 438 } |
| 399 | 439 |
| 400 virtual HostContentSettingsMap* GetHostContentSettingsMap() { | 440 virtual HostContentSettingsMap* GetHostContentSettingsMap() { |
| 401 // Retrieve the host content settings map of the parent profile in order to | 441 // Retrieve the host content settings map of the parent profile in order to |
| 402 // ensure the preferences have been migrated. | 442 // ensure the preferences have been migrated. |
| 403 profile_->GetHostContentSettingsMap(); | 443 profile_->GetHostContentSettingsMap(); |
| 404 if (!host_content_settings_map_.get()) | 444 if (!host_content_settings_map_.get()) |
| 405 host_content_settings_map_ = new HostContentSettingsMap(this); | 445 host_content_settings_map_ = new HostContentSettingsMap(this); |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 629 Profile* profile_; | 669 Profile* profile_; |
| 630 | 670 |
| 631 scoped_ptr<ExtensionProcessManager> extension_process_manager_; | 671 scoped_ptr<ExtensionProcessManager> extension_process_manager_; |
| 632 | 672 |
| 633 // The context to use for requests made from this OTR session. | 673 // The context to use for requests made from this OTR session. |
| 634 scoped_refptr<ChromeURLRequestContextGetter> request_context_; | 674 scoped_refptr<ChromeURLRequestContextGetter> request_context_; |
| 635 | 675 |
| 636 // The context to use for requests made by an extension while in OTR mode. | 676 // The context to use for requests made by an extension while in OTR mode. |
| 637 scoped_refptr<ChromeURLRequestContextGetter> extensions_request_context_; | 677 scoped_refptr<ChromeURLRequestContextGetter> extensions_request_context_; |
| 638 | 678 |
| 679 // A map of request contexts, one per isolated app while in OTR mode. | |
| 680 typedef base::hash_map<std::string, | |
|
willchan no longer on Chromium
2011/01/26 23:21:52
http://www.corp.google.com/eng/doc/cppguide.xml?ex
Charlie Reis
2011/03/01 21:33:11
Done.
| |
| 681 scoped_refptr<ChromeURLRequestContextGetter> > | |
| 682 ChromeURLRequestContextGetterMap; | |
| 683 ChromeURLRequestContextGetterMap app_request_context_map_; | |
| 684 | |
| 639 // The download manager that only stores downloaded items in memory. | 685 // The download manager that only stores downloaded items in memory. |
| 640 scoped_refptr<DownloadManager> download_manager_; | 686 scoped_refptr<DownloadManager> download_manager_; |
| 641 | 687 |
| 642 // Use a separate desktop notification service for OTR. | 688 // Use a separate desktop notification service for OTR. |
| 643 scoped_ptr<DesktopNotificationService> desktop_notification_service_; | 689 scoped_ptr<DesktopNotificationService> desktop_notification_service_; |
| 644 | 690 |
| 645 // We use a non-writable content settings map for OTR. | 691 // We use a non-writable content settings map for OTR. |
| 646 scoped_refptr<HostContentSettingsMap> host_content_settings_map_; | 692 scoped_refptr<HostContentSettingsMap> host_content_settings_map_; |
| 647 | 693 |
| 648 // Use a separate zoom map for OTR. | 694 // Use a separate zoom map for OTR. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 682 | 728 |
| 683 // The file_system context for this profile. | 729 // The file_system context for this profile. |
| 684 scoped_refptr<fileapi::SandboxedFileSystemContext> file_system_context_; | 730 scoped_refptr<fileapi::SandboxedFileSystemContext> file_system_context_; |
| 685 | 731 |
| 686 DISALLOW_COPY_AND_ASSIGN(OffTheRecordProfileImpl); | 732 DISALLOW_COPY_AND_ASSIGN(OffTheRecordProfileImpl); |
| 687 }; | 733 }; |
| 688 | 734 |
| 689 Profile* Profile::CreateOffTheRecordProfile() { | 735 Profile* Profile::CreateOffTheRecordProfile() { |
| 690 return new OffTheRecordProfileImpl(this); | 736 return new OffTheRecordProfileImpl(this); |
| 691 } | 737 } |
| OLD | NEW |