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

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

Issue 3210007: Add support for a "split" incognito behavior for extensions. (Closed)
Patch Set: latest Created 10 years, 3 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
« no previous file with comments | « chrome/browser/net/chrome_url_request_context.cc ('k') | chrome/browser/profile_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/profile.h" 5 #include "chrome/browser/profile.h"
6 6
7 #include "app/resource_bundle.h" 7 #include "app/resource_bundle.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
11 #include "base/path_service.h" 11 #include "base/path_service.h"
12 #include "base/scoped_ptr.h" 12 #include "base/scoped_ptr.h"
13 #include "base/string_util.h" 13 #include "base/string_util.h"
14 #include "chrome/browser/background_contents_service.h" 14 #include "chrome/browser/background_contents_service.h"
15 #include "chrome/browser/browser_list.h" 15 #include "chrome/browser/browser_list.h"
16 #include "chrome/browser/browser_process.h" 16 #include "chrome/browser/browser_process.h"
17 #include "chrome/browser/chrome_blob_storage_context.h" 17 #include "chrome/browser/chrome_blob_storage_context.h"
18 #include "chrome/browser/chrome_thread.h" 18 #include "chrome/browser/chrome_thread.h"
19 #include "chrome/browser/download/download_manager.h" 19 #include "chrome/browser/download/download_manager.h"
20 #include "chrome/browser/file_system/file_system_host_context.h" 20 #include "chrome/browser/file_system/file_system_host_context.h"
21 #include "chrome/browser/extensions/extension_message_service.h"
22 #include "chrome/browser/extensions/extension_process_manager.h"
21 #include "chrome/browser/find_bar_state.h" 23 #include "chrome/browser/find_bar_state.h"
22 #include "chrome/browser/in_process_webkit/webkit_context.h" 24 #include "chrome/browser/in_process_webkit/webkit_context.h"
23 #include "chrome/browser/net/chrome_url_request_context.h" 25 #include "chrome/browser/net/chrome_url_request_context.h"
24 #include "chrome/browser/notifications/desktop_notification_service.h" 26 #include "chrome/browser/notifications/desktop_notification_service.h"
25 #include "chrome/browser/ssl/ssl_host_state.h" 27 #include "chrome/browser/ssl/ssl_host_state.h"
26 #include "chrome/browser/sync/profile_sync_service.h" 28 #include "chrome/browser/sync/profile_sync_service.h"
27 #include "chrome/browser/themes/browser_theme_provider.h" 29 #include "chrome/browser/themes/browser_theme_provider.h"
28 #include "chrome/common/chrome_constants.h" 30 #include "chrome/common/chrome_constants.h"
29 #include "chrome/common/chrome_paths.h" 31 #include "chrome/common/chrome_paths.h"
30 #include "chrome/common/chrome_switches.h" 32 #include "chrome/common/chrome_switches.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 // to make it suitable for the off the record mode. 114 // to make it suitable for the off the record mode.
113 // 115 //
114 //////////////////////////////////////////////////////////////////////////////// 116 ////////////////////////////////////////////////////////////////////////////////
115 class OffTheRecordProfileImpl : public Profile, 117 class OffTheRecordProfileImpl : public Profile,
116 public NotificationObserver { 118 public NotificationObserver {
117 public: 119 public:
118 explicit OffTheRecordProfileImpl(Profile* real_profile) 120 explicit OffTheRecordProfileImpl(Profile* real_profile)
119 : profile_(real_profile), 121 : profile_(real_profile),
120 start_time_(Time::Now()) { 122 start_time_(Time::Now()) {
121 request_context_ = ChromeURLRequestContextGetter::CreateOffTheRecord(this); 123 request_context_ = ChromeURLRequestContextGetter::CreateOffTheRecord(this);
124 extension_process_manager_.reset(ExtensionProcessManager::Create(this));
122 125
123 // Register for browser close notifications so we can detect when the last 126 // Register for browser close notifications so we can detect when the last
124 // off-the-record window is closed, in which case we can clean our states 127 // off-the-record window is closed, in which case we can clean our states
125 // (cookies, downloads...). 128 // (cookies, downloads...).
126 registrar_.Add(this, NotificationType::BROWSER_CLOSED, 129 registrar_.Add(this, NotificationType::BROWSER_CLOSED,
127 NotificationService::AllSources()); 130 NotificationService::AllSources());
128 background_contents_service_.reset( 131 background_contents_service_.reset(
129 new BackgroundContentsService(this, CommandLine::ForCurrentProcess())); 132 new BackgroundContentsService(this, CommandLine::ForCurrentProcess()));
130 } 133 }
131 134
132 virtual ~OffTheRecordProfileImpl() { 135 virtual ~OffTheRecordProfileImpl() {
133 NotificationService::current()->Notify(NotificationType::PROFILE_DESTROYED, 136 NotificationService::current()->Notify(NotificationType::PROFILE_DESTROYED,
134 Source<Profile>(this), 137 Source<Profile>(this),
135 NotificationService::NoDetails()); 138 NotificationService::NoDetails());
136 CleanupRequestContext(request_context_); 139 CleanupRequestContext(request_context_);
140 CleanupRequestContext(extensions_request_context_);
137 141
138 // Clean up all DB files/directories 142 // Clean up all DB files/directories
139 ChromeThread::PostTask( 143 ChromeThread::PostTask(
140 ChromeThread::FILE, FROM_HERE, 144 ChromeThread::FILE, FROM_HERE,
141 NewRunnableMethod( 145 NewRunnableMethod(
142 db_tracker_.get(), 146 db_tracker_.get(),
143 &webkit_database::DatabaseTracker::DeleteIncognitoDBDirectory)); 147 &webkit_database::DatabaseTracker::DeleteIncognitoDBDirectory));
144 } 148 }
145 149
146 virtual ProfileId GetRuntimeId() { 150 virtual ProfileId GetRuntimeId() {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 return GetOriginalProfile()->GetUserScriptMaster(); 217 return GetOriginalProfile()->GetUserScriptMaster();
214 } 218 }
215 219
216 virtual ExtensionDevToolsManager* GetExtensionDevToolsManager() { 220 virtual ExtensionDevToolsManager* GetExtensionDevToolsManager() {
217 // TODO(mpcomplete): figure out whether we should return the original 221 // TODO(mpcomplete): figure out whether we should return the original
218 // profile's version. 222 // profile's version.
219 return NULL; 223 return NULL;
220 } 224 }
221 225
222 virtual ExtensionProcessManager* GetExtensionProcessManager() { 226 virtual ExtensionProcessManager* GetExtensionProcessManager() {
223 return GetOriginalProfile()->GetExtensionProcessManager(); 227 return extension_process_manager_.get();
224 } 228 }
225 229
226 virtual ExtensionMessageService* GetExtensionMessageService() { 230 virtual ExtensionMessageService* GetExtensionMessageService() {
227 return GetOriginalProfile()->GetExtensionMessageService(); 231 return GetOriginalProfile()->GetExtensionMessageService();
228 } 232 }
229 233
230 virtual SSLHostState* GetSSLHostState() { 234 virtual SSLHostState* GetSSLHostState() {
231 if (!ssl_host_state_.get()) 235 if (!ssl_host_state_.get())
232 ssl_host_state_.reset(new SSLHostState()); 236 ssl_host_state_.reset(new SSLHostState());
233 237
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 virtual URLRequestContextGetter* GetRequestContext() { 354 virtual URLRequestContextGetter* GetRequestContext() {
351 return request_context_; 355 return request_context_;
352 } 356 }
353 357
354 virtual URLRequestContextGetter* GetRequestContextForMedia() { 358 virtual URLRequestContextGetter* GetRequestContextForMedia() {
355 // In OTR mode, media request context is the same as the original one. 359 // In OTR mode, media request context is the same as the original one.
356 return request_context_; 360 return request_context_;
357 } 361 }
358 362
359 URLRequestContextGetter* GetRequestContextForExtensions() { 363 URLRequestContextGetter* GetRequestContextForExtensions() {
360 return GetOriginalProfile()->GetRequestContextForExtensions(); 364 if (!extensions_request_context_) {
365 extensions_request_context_ =
366 ChromeURLRequestContextGetter::CreateOffTheRecordForExtensions(this);
367 }
368
369 return extensions_request_context_;
361 } 370 }
362 371
363 virtual net::SSLConfigService* GetSSLConfigService() { 372 virtual net::SSLConfigService* GetSSLConfigService() {
364 return profile_->GetSSLConfigService(); 373 return profile_->GetSSLConfigService();
365 } 374 }
366 375
367 virtual HostContentSettingsMap* GetHostContentSettingsMap() { 376 virtual HostContentSettingsMap* GetHostContentSettingsMap() {
368 // Retrieve the host content settings map of the parent profile in order to 377 // Retrieve the host content settings map of the parent profile in order to
369 // ensure the preferences have been migrated. 378 // ensure the preferences have been migrated.
370 profile_->GetHostContentSettingsMap(); 379 profile_->GetHostContentSettingsMap();
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 } 545 }
537 return blob_storage_context_; 546 return blob_storage_context_;
538 } 547 }
539 548
540 private: 549 private:
541 NotificationRegistrar registrar_; 550 NotificationRegistrar registrar_;
542 551
543 // The real underlying profile. 552 // The real underlying profile.
544 Profile* profile_; 553 Profile* profile_;
545 554
555 scoped_ptr<ExtensionProcessManager> extension_process_manager_;
556
546 // The context to use for requests made from this OTR session. 557 // The context to use for requests made from this OTR session.
547 scoped_refptr<ChromeURLRequestContextGetter> request_context_; 558 scoped_refptr<ChromeURLRequestContextGetter> request_context_;
548 559
560 // The context to use for requests made by an extension while in OTR mode.
561 scoped_refptr<ChromeURLRequestContextGetter> extensions_request_context_;
562
549 // The download manager that only stores downloaded items in memory. 563 // The download manager that only stores downloaded items in memory.
550 scoped_refptr<DownloadManager> download_manager_; 564 scoped_refptr<DownloadManager> download_manager_;
551 565
552 // Use a separate desktop notification service for OTR. 566 // Use a separate desktop notification service for OTR.
553 scoped_ptr<DesktopNotificationService> desktop_notification_service_; 567 scoped_ptr<DesktopNotificationService> desktop_notification_service_;
554 568
555 // We use a non-writable content settings map for OTR. 569 // We use a non-writable content settings map for OTR.
556 scoped_refptr<HostContentSettingsMap> host_content_settings_map_; 570 scoped_refptr<HostContentSettingsMap> host_content_settings_map_;
557 571
558 // Use a separate zoom map for OTR. 572 // Use a separate zoom map for OTR.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 606
593 // The file_system context for this profile. 607 // The file_system context for this profile.
594 scoped_refptr<FileSystemHostContext> file_system_host_context_; 608 scoped_refptr<FileSystemHostContext> file_system_host_context_;
595 609
596 DISALLOW_COPY_AND_ASSIGN(OffTheRecordProfileImpl); 610 DISALLOW_COPY_AND_ASSIGN(OffTheRecordProfileImpl);
597 }; 611 };
598 612
599 Profile *Profile::CreateOffTheRecordProfile() { 613 Profile *Profile::CreateOffTheRecordProfile() {
600 return new OffTheRecordProfileImpl(this); 614 return new OffTheRecordProfileImpl(this);
601 } 615 }
OLDNEW
« no previous file with comments | « chrome/browser/net/chrome_url_request_context.cc ('k') | chrome/browser/profile_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698