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

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

Issue 6201005: Initial support for partitioning cookies for isolated apps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 11 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) 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
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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 new BackgroundContentsService(this, CommandLine::ForCurrentProcess())); 148 new BackgroundContentsService(this, CommandLine::ForCurrentProcess()));
147 } 149 }
148 150
149 virtual ~OffTheRecordProfileImpl() { 151 virtual ~OffTheRecordProfileImpl() {
150 NotificationService::current()->Notify(NotificationType::PROFILE_DESTROYED, 152 NotificationService::current()->Notify(NotificationType::PROFILE_DESTROYED,
151 Source<Profile>(this), 153 Source<Profile>(this),
152 NotificationService::NoDetails()); 154 NotificationService::NoDetails());
153 CleanupRequestContext(request_context_); 155 CleanupRequestContext(request_context_);
154 CleanupRequestContext(extensions_request_context_); 156 CleanupRequestContext(extensions_request_context_);
155 157
158 // Clean up all isolated app request contexts.
159 for (ChromeURLRequestContextGetterMap::iterator iter =
160 app_request_context_map_.begin();
161 iter != app_request_context_map_.end();
162 iter++) {
163 CleanupRequestContext(iter->second);
164 }
165
156 // Clean up all DB files/directories 166 // Clean up all DB files/directories
157 BrowserThread::PostTask( 167 BrowserThread::PostTask(
158 BrowserThread::FILE, FROM_HERE, 168 BrowserThread::FILE, FROM_HERE,
159 NewRunnableMethod( 169 NewRunnableMethod(
160 db_tracker_.get(), 170 db_tracker_.get(),
161 &webkit_database::DatabaseTracker::DeleteIncognitoDBDirectory)); 171 &webkit_database::DatabaseTracker::DeleteIncognitoDBDirectory));
162 172
163 BrowserList::RemoveObserver(this); 173 BrowserList::RemoveObserver(this);
164 } 174 }
165 175
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 } 380 }
371 381
372 virtual BrowserThemeProvider* GetThemeProvider() { 382 virtual BrowserThemeProvider* GetThemeProvider() {
373 return profile_->GetThemeProvider(); 383 return profile_->GetThemeProvider();
374 } 384 }
375 385
376 virtual URLRequestContextGetter* GetRequestContext() { 386 virtual URLRequestContextGetter* GetRequestContext() {
377 return request_context_; 387 return request_context_;
378 } 388 }
379 389
390 virtual URLRequestContextGetter* GetRequestContext(const Extension* app) {
391 if (CommandLine::ForCurrentProcess()->HasSwitch(
392 switches::kEnableExperimentalAppManifests)
393 && app != NULL
394 && app->is_storage_isolated())
395 return GetRequestContextForIsolatedApp(app);
396
397 return GetRequestContext();
398 }
399
380 virtual URLRequestContextGetter* GetRequestContextForMedia() { 400 virtual URLRequestContextGetter* GetRequestContextForMedia() {
381 // In OTR mode, media request context is the same as the original one. 401 // In OTR mode, media request context is the same as the original one.
382 return request_context_; 402 return request_context_;
383 } 403 }
384 404
385 URLRequestContextGetter* GetRequestContextForExtensions() { 405 URLRequestContextGetter* GetRequestContextForExtensions() {
386 if (!extensions_request_context_) { 406 if (!extensions_request_context_) {
387 extensions_request_context_ = 407 extensions_request_context_ =
388 ChromeURLRequestContextGetter::CreateOffTheRecordForExtensions(this); 408 ChromeURLRequestContextGetter::CreateOffTheRecordForExtensions(this);
389 } 409 }
390 410
391 return extensions_request_context_; 411 return extensions_request_context_;
392 } 412 }
393 413
414 URLRequestContextGetter* GetRequestContextForIsolatedApp(
415 const Extension* installed_app) {
416 CHECK(installed_app);
417 std::string id = installed_app->id();
418
419 // Keep a map of request contexts, one per requested app ID. Once created,
420 // the context will exist for the lifetime of the profile.
421 ChromeURLRequestContextGetterMap::iterator iter =
422 app_request_context_map_.find(id);
423 if (iter != app_request_context_map_.end())
424 return iter->second;
425
426 ChromeURLRequestContextGetter* context =
427 ChromeURLRequestContextGetter::CreateOffTheRecordForIsolatedApp(this,
428 installed_app);
429 app_request_context_map_[id] = context;
430
431 return context;
432 }
433
394 virtual net::SSLConfigService* GetSSLConfigService() { 434 virtual net::SSLConfigService* GetSSLConfigService() {
395 return profile_->GetSSLConfigService(); 435 return profile_->GetSSLConfigService();
396 } 436 }
397 437
398 virtual HostContentSettingsMap* GetHostContentSettingsMap() { 438 virtual HostContentSettingsMap* GetHostContentSettingsMap() {
399 // Retrieve the host content settings map of the parent profile in order to 439 // Retrieve the host content settings map of the parent profile in order to
400 // ensure the preferences have been migrated. 440 // ensure the preferences have been migrated.
401 profile_->GetHostContentSettingsMap(); 441 profile_->GetHostContentSettingsMap();
402 if (!host_content_settings_map_.get()) 442 if (!host_content_settings_map_.get())
403 host_content_settings_map_ = new HostContentSettingsMap(this); 443 host_content_settings_map_ = new HostContentSettingsMap(this);
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 Profile* profile_; 661 Profile* profile_;
622 662
623 scoped_ptr<ExtensionProcessManager> extension_process_manager_; 663 scoped_ptr<ExtensionProcessManager> extension_process_manager_;
624 664
625 // The context to use for requests made from this OTR session. 665 // The context to use for requests made from this OTR session.
626 scoped_refptr<ChromeURLRequestContextGetter> request_context_; 666 scoped_refptr<ChromeURLRequestContextGetter> request_context_;
627 667
628 // The context to use for requests made by an extension while in OTR mode. 668 // The context to use for requests made by an extension while in OTR mode.
629 scoped_refptr<ChromeURLRequestContextGetter> extensions_request_context_; 669 scoped_refptr<ChromeURLRequestContextGetter> extensions_request_context_;
630 670
671 // A map of request contexts, one per isolated app while in OTR mode.
672 typedef base::hash_map<std::string,
673 scoped_refptr<ChromeURLRequestContextGetter> >
674 ChromeURLRequestContextGetterMap;
675 ChromeURLRequestContextGetterMap app_request_context_map_;
676
631 // The download manager that only stores downloaded items in memory. 677 // The download manager that only stores downloaded items in memory.
632 scoped_refptr<DownloadManager> download_manager_; 678 scoped_refptr<DownloadManager> download_manager_;
633 679
634 // Use a separate desktop notification service for OTR. 680 // Use a separate desktop notification service for OTR.
635 scoped_ptr<DesktopNotificationService> desktop_notification_service_; 681 scoped_ptr<DesktopNotificationService> desktop_notification_service_;
636 682
637 // We use a non-writable content settings map for OTR. 683 // We use a non-writable content settings map for OTR.
638 scoped_refptr<HostContentSettingsMap> host_content_settings_map_; 684 scoped_refptr<HostContentSettingsMap> host_content_settings_map_;
639 685
640 // Use a separate zoom map for OTR. 686 // Use a separate zoom map for OTR.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 720
675 // The file_system context for this profile. 721 // The file_system context for this profile.
676 scoped_refptr<fileapi::SandboxedFileSystemContext> file_system_context_; 722 scoped_refptr<fileapi::SandboxedFileSystemContext> file_system_context_;
677 723
678 DISALLOW_COPY_AND_ASSIGN(OffTheRecordProfileImpl); 724 DISALLOW_COPY_AND_ASSIGN(OffTheRecordProfileImpl);
679 }; 725 };
680 726
681 Profile* Profile::CreateOffTheRecordProfile() { 727 Profile* Profile::CreateOffTheRecordProfile() {
682 return new OffTheRecordProfileImpl(this); 728 return new OffTheRecordProfileImpl(this);
683 } 729 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698