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

Side by Side Diff: chrome/browser/profile_impl.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/profile.cc ('k') | chrome/browser/resources/extensions_ui.html » ('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_impl.h" 5 #include "chrome/browser/profile_impl.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/environment.h" 9 #include "base/environment.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 // Callee takes ownership of new ExtensionInfo struct. 165 // Callee takes ownership of new ExtensionInfo struct.
166 ChromeThread::PostTask( 166 ChromeThread::PostTask(
167 ChromeThread::IO, FROM_HERE, 167 ChromeThread::IO, FROM_HERE,
168 NewRunnableMethod(getter, 168 NewRunnableMethod(getter,
169 &ChromeURLRequestContextGetter::OnNewExtensions, 169 &ChromeURLRequestContextGetter::OnNewExtensions,
170 extension->id(), 170 extension->id(),
171 new ChromeURLRequestContext::ExtensionInfo( 171 new ChromeURLRequestContext::ExtensionInfo(
172 extension->name(), 172 extension->name(),
173 extension->path(), 173 extension->path(),
174 extension->default_locale(), 174 extension->default_locale(),
175 extension->incognito_split_mode(),
175 extension->web_extent(), 176 extension->web_extent(),
176 extension->GetEffectiveHostPermissions(), 177 extension->GetEffectiveHostPermissions(),
177 extension->api_permissions()))); 178 extension->api_permissions())));
178 } 179 }
179 180
180 void PostExtensionUnloadedToContextGetter(ChromeURLRequestContextGetter* getter, 181 void PostExtensionUnloadedToContextGetter(ChromeURLRequestContextGetter* getter,
181 Extension* extension) { 182 Extension* extension) {
182 if (!getter) 183 if (!getter)
183 return; 184 return;
184 ChromeThread::PostTask( 185 ChromeThread::PostTask(
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 void ProfileImpl::InitExtensions() { 363 void ProfileImpl::InitExtensions() {
363 if (user_script_master_ || extensions_service_) 364 if (user_script_master_ || extensions_service_)
364 return; // Already initialized. 365 return; // Already initialized.
365 366
366 const CommandLine* command_line = CommandLine::ForCurrentProcess(); 367 const CommandLine* command_line = CommandLine::ForCurrentProcess();
367 if (command_line->HasSwitch( 368 if (command_line->HasSwitch(
368 switches::kEnableExtensionTimelineApi)) { 369 switches::kEnableExtensionTimelineApi)) {
369 extension_devtools_manager_ = new ExtensionDevToolsManager(this); 370 extension_devtools_manager_ = new ExtensionDevToolsManager(this);
370 } 371 }
371 372
372 extension_process_manager_.reset(new ExtensionProcessManager(this)); 373 extension_process_manager_.reset(ExtensionProcessManager::Create(this));
373 extension_message_service_ = new ExtensionMessageService(this); 374 extension_message_service_ = new ExtensionMessageService(this);
374 375
375 ExtensionErrorReporter::Init(true); // allow noisy errors. 376 ExtensionErrorReporter::Init(true); // allow noisy errors.
376 377
377 FilePath script_dir; // Don't look for user scripts in any directory. 378 FilePath script_dir; // Don't look for user scripts in any directory.
378 // TODO(aa): We should just remove this functionality, 379 // TODO(aa): We should just remove this functionality,
379 // since it isn't used anymore. 380 // since it isn't used anymore.
380 user_script_master_ = new UserScriptMaster(script_dir, this); 381 user_script_master_ = new UserScriptMaster(script_dir, this);
381 382
382 extensions_service_ = new ExtensionsService( 383 extensions_service_ = new ExtensionsService(
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 cookie_path = cookie_path.Append(chrome::kExtensionsCookieFilename); 731 cookie_path = cookie_path.Append(chrome::kExtensionsCookieFilename);
731 732
732 extensions_request_context_ = 733 extensions_request_context_ =
733 ChromeURLRequestContextGetter::CreateOriginalForExtensions( 734 ChromeURLRequestContextGetter::CreateOriginalForExtensions(
734 this, cookie_path); 735 this, cookie_path);
735 } 736 }
736 737
737 return extensions_request_context_; 738 return extensions_request_context_;
738 } 739 }
739 740
741 // TODO(mpcomplete): This is lame. 5+ copies of the extension data on the IO
742 // thread. We should have 1 shared data object that all the contexts get access
743 // to. Fix by M8.
740 void ProfileImpl::RegisterExtensionWithRequestContexts( 744 void ProfileImpl::RegisterExtensionWithRequestContexts(
741 Extension* extension) { 745 Extension* extension) {
742 // Notify the default, extension and media contexts on the IO thread. 746 // Notify the default, extension and media contexts on the IO thread.
743 PostExtensionLoadedToContextGetter( 747 PostExtensionLoadedToContextGetter(
744 static_cast<ChromeURLRequestContextGetter*>(GetRequestContext()), 748 static_cast<ChromeURLRequestContextGetter*>(GetRequestContext()),
745 extension); 749 extension);
746 PostExtensionLoadedToContextGetter( 750 PostExtensionLoadedToContextGetter(
747 static_cast<ChromeURLRequestContextGetter*>( 751 static_cast<ChromeURLRequestContextGetter*>(
748 GetRequestContextForExtensions()), 752 GetRequestContextForExtensions()),
749 extension); 753 extension);
750 PostExtensionLoadedToContextGetter( 754 PostExtensionLoadedToContextGetter(
751 static_cast<ChromeURLRequestContextGetter*>( 755 static_cast<ChromeURLRequestContextGetter*>(
752 GetRequestContextForMedia()), 756 GetRequestContextForMedia()),
753 extension); 757 extension);
758
759 // Ditto for OTR if it's active, except for the media context which is the
760 // same as the regular context.
761 if (off_the_record_profile_.get()) {
762 PostExtensionLoadedToContextGetter(
763 static_cast<ChromeURLRequestContextGetter*>(
764 off_the_record_profile_->GetRequestContext()),
765 extension);
766 PostExtensionLoadedToContextGetter(
767 static_cast<ChromeURLRequestContextGetter*>(
768 off_the_record_profile_->GetRequestContextForExtensions()),
769 extension);
770 }
754 } 771 }
755 772
756 void ProfileImpl::UnregisterExtensionWithRequestContexts( 773 void ProfileImpl::UnregisterExtensionWithRequestContexts(
757 Extension* extension) { 774 Extension* extension) {
758 // Notify the default, extension and media contexts on the IO thread. 775 // Notify the default, extension and media contexts on the IO thread.
759 PostExtensionUnloadedToContextGetter( 776 PostExtensionUnloadedToContextGetter(
760 static_cast<ChromeURLRequestContextGetter*>(GetRequestContext()), 777 static_cast<ChromeURLRequestContextGetter*>(GetRequestContext()),
761 extension); 778 extension);
762 PostExtensionUnloadedToContextGetter( 779 PostExtensionUnloadedToContextGetter(
763 static_cast<ChromeURLRequestContextGetter*>( 780 static_cast<ChromeURLRequestContextGetter*>(
764 GetRequestContextForExtensions()), 781 GetRequestContextForExtensions()),
765 extension); 782 extension);
766 PostExtensionUnloadedToContextGetter( 783 PostExtensionUnloadedToContextGetter(
767 static_cast<ChromeURLRequestContextGetter*>( 784 static_cast<ChromeURLRequestContextGetter*>(
768 GetRequestContextForMedia()), 785 GetRequestContextForMedia()),
769 extension); 786 extension);
787
788 // Ditto for OTR if it's active, except for the media context which is the
789 // same as the regular context.
790 if (off_the_record_profile_.get()) {
791 PostExtensionUnloadedToContextGetter(
792 static_cast<ChromeURLRequestContextGetter*>(
793 off_the_record_profile_->GetRequestContext()),
794 extension);
795 PostExtensionUnloadedToContextGetter(
796 static_cast<ChromeURLRequestContextGetter*>(
797 off_the_record_profile_->GetRequestContextForExtensions()),
798 extension);
799 }
770 } 800 }
771 801
772 net::SSLConfigService* ProfileImpl::GetSSLConfigService() { 802 net::SSLConfigService* ProfileImpl::GetSSLConfigService() {
773 return ssl_config_service_manager_->Get(); 803 return ssl_config_service_manager_->Get();
774 } 804 }
775 805
776 HostContentSettingsMap* ProfileImpl::GetHostContentSettingsMap() { 806 HostContentSettingsMap* ProfileImpl::GetHostContentSettingsMap() {
777 if (!host_content_settings_map_.get()) 807 if (!host_content_settings_map_.get())
778 host_content_settings_map_ = new HostContentSettingsMap(this); 808 host_content_settings_map_ = new HostContentSettingsMap(this);
779 return host_content_settings_map_.get(); 809 return host_content_settings_map_.get();
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
1245 #if defined(OS_CHROMEOS) 1275 #if defined(OS_CHROMEOS)
1246 chromeos::ProxyConfigServiceImpl* 1276 chromeos::ProxyConfigServiceImpl*
1247 ProfileImpl::GetChromeOSProxyConfigServiceImpl() { 1277 ProfileImpl::GetChromeOSProxyConfigServiceImpl() {
1248 if (!chromeos_proxy_config_service_impl_) { 1278 if (!chromeos_proxy_config_service_impl_) {
1249 chromeos_proxy_config_service_impl_ = 1279 chromeos_proxy_config_service_impl_ =
1250 new chromeos::ProxyConfigServiceImpl(); 1280 new chromeos::ProxyConfigServiceImpl();
1251 } 1281 }
1252 return chromeos_proxy_config_service_impl_; 1282 return chromeos_proxy_config_service_impl_;
1253 } 1283 }
1254 #endif // defined(OS_CHROMEOS) 1284 #endif // defined(OS_CHROMEOS)
OLDNEW
« no previous file with comments | « chrome/browser/profile.cc ('k') | chrome/browser/resources/extensions_ui.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698