| 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/off_the_record_profile_impl.h" |    5 #include "chrome/browser/profiles/off_the_record_profile_impl.h" | 
|    6  |    6  | 
|    7 #include "base/bind.h" |    7 #include "base/bind.h" | 
|    8 #include "base/command_line.h" |    8 #include "base/command_line.h" | 
|    9 #include "base/compiler_specific.h" |    9 #include "base/compiler_specific.h" | 
|   10 #include "base/file_path.h" |   10 #include "base/file_path.h" | 
|   11 #include "base/file_util.h" |   11 #include "base/file_util.h" | 
|   12 #include "base/memory/scoped_ptr.h" |   12 #include "base/memory/scoped_ptr.h" | 
|   13 #include "base/path_service.h" |   13 #include "base/path_service.h" | 
|   14 #include "base/string_util.h" |   14 #include "base/string_util.h" | 
|   15 #include "build/build_config.h" |   15 #include "build/build_config.h" | 
|   16 #include "chrome/browser/background/background_contents_service_factory.h" |   16 #include "chrome/browser/background/background_contents_service_factory.h" | 
|   17 #include "chrome/browser/browser_process.h" |   17 #include "chrome/browser/browser_process.h" | 
|   18 #include "chrome/browser/chrome_plugin_service_filter.h" |   18 #include "chrome/browser/chrome_plugin_service_filter.h" | 
|   19 #include "chrome/browser/content_settings/host_content_settings_map.h" |   19 #include "chrome/browser/content_settings/host_content_settings_map.h" | 
|   20 #include "chrome/browser/download/download_service.h" |   20 #include "chrome/browser/download/download_service.h" | 
|   21 #include "chrome/browser/download/download_service_factory.h" |   21 #include "chrome/browser/download/download_service_factory.h" | 
|   22 #include "chrome/browser/extensions/api/web_request/web_request_api.h" |   22 #include "chrome/browser/extensions/api/web_request/web_request_api.h" | 
|   23 #include "chrome/browser/extensions/extension_info_map.h" |   23 #include "chrome/browser/extensions/extension_info_map.h" | 
|   24 #include "chrome/browser/extensions/extension_message_service.h" |  | 
|   25 #include "chrome/browser/extensions/extension_pref_store.h" |   24 #include "chrome/browser/extensions/extension_pref_store.h" | 
 |   25 #include "chrome/browser/extensions/extension_pref_value_map.h" | 
|   26 #include "chrome/browser/extensions/extension_process_manager.h" |   26 #include "chrome/browser/extensions/extension_process_manager.h" | 
|   27 #include "chrome/browser/extensions/extension_service.h" |   27 #include "chrome/browser/extensions/extension_service.h" | 
|   28 #include "chrome/browser/extensions/extension_special_storage_policy.h" |   28 #include "chrome/browser/extensions/extension_special_storage_policy.h" | 
 |   29 #include "chrome/browser/extensions/extension_system.h" | 
 |   30 #include "chrome/browser/extensions/extension_system_factory.h" | 
|   29 #include "chrome/browser/io_thread.h" |   31 #include "chrome/browser/io_thread.h" | 
|   30 #include "chrome/browser/net/proxy_service_factory.h" |   32 #include "chrome/browser/net/proxy_service_factory.h" | 
|   31 #include "chrome/browser/plugin_prefs.h" |   33 #include "chrome/browser/plugin_prefs.h" | 
|   32 #include "chrome/browser/prefs/incognito_mode_prefs.h" |   34 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 
|   33 #include "chrome/browser/prefs/pref_service.h" |   35 #include "chrome/browser/prefs/pref_service.h" | 
|   34 #include "chrome/browser/profiles/profile_dependency_manager.h" |   36 #include "chrome/browser/profiles/profile_dependency_manager.h" | 
|   35 #include "chrome/browser/themes/theme_service.h" |   37 #include "chrome/browser/themes/theme_service.h" | 
|   36 #include "chrome/browser/transport_security_persister.h" |   38 #include "chrome/browser/transport_security_persister.h" | 
|   37 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |   39 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 
|   38 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" |   40 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" | 
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   78 }  // namespace |   80 }  // namespace | 
|   79  |   81  | 
|   80 OffTheRecordProfileImpl::OffTheRecordProfileImpl(Profile* real_profile) |   82 OffTheRecordProfileImpl::OffTheRecordProfileImpl(Profile* real_profile) | 
|   81     : profile_(real_profile), |   83     : profile_(real_profile), | 
|   82       prefs_(real_profile->GetOffTheRecordPrefs()), |   84       prefs_(real_profile->GetOffTheRecordPrefs()), | 
|   83       ALLOW_THIS_IN_INITIALIZER_LIST(io_data_(this)), |   85       ALLOW_THIS_IN_INITIALIZER_LIST(io_data_(this)), | 
|   84       start_time_(Time::Now()) { |   86       start_time_(Time::Now()) { | 
|   85 } |   87 } | 
|   86  |   88  | 
|   87 void OffTheRecordProfileImpl::Init() { |   89 void OffTheRecordProfileImpl::Init() { | 
|   88   extension_process_manager_.reset(ExtensionProcessManager::Create(this)); |  | 
|   89  |  | 
|   90   ProfileDependencyManager::GetInstance()->CreateProfileServices(this, false); |   90   ProfileDependencyManager::GetInstance()->CreateProfileServices(this, false); | 
|   91  |   91  | 
|   92   DCHECK_NE(IncognitoModePrefs::DISABLED, |   92   DCHECK_NE(IncognitoModePrefs::DISABLED, | 
|   93             IncognitoModePrefs::GetAvailability(profile_->GetPrefs())); |   93             IncognitoModePrefs::GetAvailability(profile_->GetPrefs())); | 
|   94  |   94  | 
|   95   // TODO(oshima): Remove the need to eagerly initialize the request context |   95   // TODO(oshima): Remove the need to eagerly initialize the request context | 
|   96   // getter. chromeos::OnlineAttempt is illegally trying to access this |   96   // getter. chromeos::OnlineAttempt is illegally trying to access this | 
|   97   // Profile member from a thread other than the UI thread, so we need to |   97   // Profile member from a thread other than the UI thread, so we need to | 
|   98   // prevent a race. |   98   // prevent a race. | 
|   99 #if defined(OS_CHROMEOS) |   99 #if defined(OS_CHROMEOS) | 
| (...skipping 15 matching lines...) Expand all  Loading... | 
|  115 } |  115 } | 
|  116  |  116  | 
|  117 OffTheRecordProfileImpl::~OffTheRecordProfileImpl() { |  117 OffTheRecordProfileImpl::~OffTheRecordProfileImpl() { | 
|  118   content::NotificationService::current()->Notify( |  118   content::NotificationService::current()->Notify( | 
|  119     chrome::NOTIFICATION_PROFILE_DESTROYED, content::Source<Profile>(this), |  119     chrome::NOTIFICATION_PROFILE_DESTROYED, content::Source<Profile>(this), | 
|  120     content::NotificationService::NoDetails()); |  120     content::NotificationService::NoDetails()); | 
|  121  |  121  | 
|  122   ChromePluginServiceFilter::GetInstance()->UnregisterResourceContext( |  122   ChromePluginServiceFilter::GetInstance()->UnregisterResourceContext( | 
|  123     io_data_.GetResourceContextNoInit()); |  123     io_data_.GetResourceContextNoInit()); | 
|  124  |  124  | 
 |  125   ExtensionService* extension_service = | 
 |  126       ExtensionSystemFactory::GetForProfile(this)->extension_service(); | 
 |  127   if (extension_service && extension_service->extensions_enabled()) { | 
 |  128     extension_service->extension_prefs()-> | 
 |  129         ClearIncognitoSessionOnlyContentSettings(); | 
 |  130   } | 
 |  131  | 
|  125   ProfileDependencyManager::GetInstance()->DestroyProfileServices(this); |  132   ProfileDependencyManager::GetInstance()->DestroyProfileServices(this); | 
|  126  |  133  | 
|  127   BrowserThread::PostTask( |  134   BrowserThread::PostTask( | 
|  128       BrowserThread::IO, FROM_HERE, |  135       BrowserThread::IO, FROM_HERE, | 
|  129       base::Bind(&NotifyOTRProfileDestroyedOnIOThread, profile_, this)); |  136       base::Bind(&NotifyOTRProfileDestroyedOnIOThread, profile_, this)); | 
|  130  |  137  | 
|  131   if (host_content_settings_map_) |  138   if (host_content_settings_map_) | 
|  132     host_content_settings_map_->ShutdownOnUIThread(); |  139     host_content_settings_map_->ShutdownOnUIThread(); | 
|  133  |  140  | 
|  134   if (pref_proxy_config_tracker_.get()) |  141   if (pref_proxy_config_tracker_.get()) | 
|  135     pref_proxy_config_tracker_->DetachFromPrefService(); |  142     pref_proxy_config_tracker_->DetachFromPrefService(); | 
|  136  |  143  | 
|  137   ExtensionService* extension_service = GetExtensionService(); |  | 
|  138   if (extension_service && extension_service->extensions_enabled()) { |  | 
|  139     ExtensionPrefs* extension_prefs = extension_service->extension_prefs(); |  | 
|  140     extension_prefs->ClearIncognitoSessionOnlyContentSettings(); |  | 
|  141   } |  | 
|  142  |  | 
|  143   // Clears any data the network stack contains that may be related to the |  144   // Clears any data the network stack contains that may be related to the | 
|  144   // OTR session. |  145   // OTR session. | 
|  145   g_browser_process->io_thread()->ChangedToOnTheRecord(); |  146   g_browser_process->io_thread()->ChangedToOnTheRecord(); | 
|  146 } |  147 } | 
|  147  |  148  | 
|  148 void OffTheRecordProfileImpl::InitHostZoomMap() { |  149 void OffTheRecordProfileImpl::InitHostZoomMap() { | 
|  149   HostZoomMap* host_zoom_map = HostZoomMap::GetForBrowserContext(this); |  150   HostZoomMap* host_zoom_map = HostZoomMap::GetForBrowserContext(this); | 
|  150   HostZoomMap* parent_host_zoom_map = |  151   HostZoomMap* parent_host_zoom_map = | 
|  151       HostZoomMap::GetForBrowserContext(profile_); |  152       HostZoomMap::GetForBrowserContext(profile_); | 
|  152   host_zoom_map->CopyFrom(parent_host_zoom_map); |  153   host_zoom_map->CopyFrom(parent_host_zoom_map); | 
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  185 Profile* OffTheRecordProfileImpl::GetOriginalProfile() { |  186 Profile* OffTheRecordProfileImpl::GetOriginalProfile() { | 
|  186   return profile_; |  187   return profile_; | 
|  187 } |  188 } | 
|  188  |  189  | 
|  189 VisitedLinkMaster* OffTheRecordProfileImpl::GetVisitedLinkMaster() { |  190 VisitedLinkMaster* OffTheRecordProfileImpl::GetVisitedLinkMaster() { | 
|  190   // We don't provide access to the VisitedLinkMaster when we're OffTheRecord |  191   // We don't provide access to the VisitedLinkMaster when we're OffTheRecord | 
|  191   // because we don't want to leak the sites that the user has visited before. |  192   // because we don't want to leak the sites that the user has visited before. | 
|  192   return NULL; |  193   return NULL; | 
|  193 } |  194 } | 
|  194  |  195  | 
 |  196 ExtensionPrefValueMap* OffTheRecordProfileImpl::GetExtensionPrefValueMap() { | 
 |  197   return NULL; | 
 |  198 } | 
 |  199  | 
|  195 ExtensionService* OffTheRecordProfileImpl::GetExtensionService() { |  200 ExtensionService* OffTheRecordProfileImpl::GetExtensionService() { | 
|  196   return GetOriginalProfile()->GetExtensionService(); |  201   return ExtensionSystemFactory::GetForProfile(this)->extension_service(); | 
|  197 } |  202 } | 
|  198  |  203  | 
|  199 UserScriptMaster* OffTheRecordProfileImpl::GetUserScriptMaster() { |  204 UserScriptMaster* OffTheRecordProfileImpl::GetUserScriptMaster() { | 
|  200   return GetOriginalProfile()->GetUserScriptMaster(); |  205   return ExtensionSystemFactory::GetForProfile(this)->user_script_master(); | 
|  201 } |  | 
|  202  |  | 
|  203 ExtensionDevToolsManager* |  | 
|  204     OffTheRecordProfileImpl::GetExtensionDevToolsManager() { |  | 
|  205   // TODO(mpcomplete): figure out whether we should return the original |  | 
|  206   // profile's version. |  | 
|  207   return NULL; |  | 
|  208 } |  206 } | 
|  209  |  207  | 
|  210 ExtensionProcessManager* |  208 ExtensionProcessManager* | 
|  211     OffTheRecordProfileImpl::GetExtensionProcessManager() { |  209     OffTheRecordProfileImpl::GetExtensionProcessManager() { | 
|  212   return extension_process_manager_.get(); |  210   return ExtensionSystemFactory::GetForProfile(this)->process_manager(); | 
|  213 } |  | 
|  214  |  | 
|  215 ExtensionMessageService* |  | 
|  216     OffTheRecordProfileImpl::GetExtensionMessageService() { |  | 
|  217   return GetOriginalProfile()->GetExtensionMessageService(); |  | 
|  218 } |  211 } | 
|  219  |  212  | 
|  220 ExtensionEventRouter* OffTheRecordProfileImpl::GetExtensionEventRouter() { |  213 ExtensionEventRouter* OffTheRecordProfileImpl::GetExtensionEventRouter() { | 
|  221   return GetOriginalProfile()->GetExtensionEventRouter(); |  214   return ExtensionSystemFactory::GetForProfile(this)->event_router(); | 
|  222 } |  215 } | 
|  223  |  216  | 
|  224 ExtensionSpecialStoragePolicy* |  217 ExtensionSpecialStoragePolicy* | 
|  225     OffTheRecordProfileImpl::GetExtensionSpecialStoragePolicy() { |  218     OffTheRecordProfileImpl::GetExtensionSpecialStoragePolicy() { | 
|  226   return GetOriginalProfile()->GetExtensionSpecialStoragePolicy(); |  219   return GetOriginalProfile()->GetExtensionSpecialStoragePolicy(); | 
|  227 } |  220 } | 
|  228  |  221  | 
|  229 LazyBackgroundTaskQueue* OffTheRecordProfileImpl::GetLazyBackgroundTaskQueue() { |  | 
|  230   return GetOriginalProfile()->GetLazyBackgroundTaskQueue(); |  | 
|  231 } |  | 
|  232  |  | 
|  233 GAIAInfoUpdateService* OffTheRecordProfileImpl::GetGAIAInfoUpdateService() { |  222 GAIAInfoUpdateService* OffTheRecordProfileImpl::GetGAIAInfoUpdateService() { | 
|  234   return NULL; |  223   return NULL; | 
|  235 } |  224 } | 
|  236  |  225  | 
|  237 HistoryService* OffTheRecordProfileImpl::GetHistoryService( |  226 HistoryService* OffTheRecordProfileImpl::GetHistoryService( | 
|  238     ServiceAccessType sat) { |  227     ServiceAccessType sat) { | 
|  239   if (sat == EXPLICIT_ACCESS) |  228   if (sat == EXPLICIT_ACCESS) | 
|  240     return profile_->GetHistoryService(sat); |  229     return profile_->GetHistoryService(sat); | 
|  241  |  230  | 
|  242   NOTREACHED() << "This profile is OffTheRecord"; |  231   NOTREACHED() << "This profile is OffTheRecord"; | 
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  391   return NULL; |  380   return NULL; | 
|  392 } |  381 } | 
|  393  |  382  | 
|  394 history::TopSites* OffTheRecordProfileImpl::GetTopSites() { |  383 history::TopSites* OffTheRecordProfileImpl::GetTopSites() { | 
|  395   return NULL; |  384   return NULL; | 
|  396 } |  385 } | 
|  397  |  386  | 
|  398 void OffTheRecordProfileImpl::MarkAsCleanShutdown() { |  387 void OffTheRecordProfileImpl::MarkAsCleanShutdown() { | 
|  399 } |  388 } | 
|  400  |  389  | 
|  401 void OffTheRecordProfileImpl::InitExtensions(bool extensions_enabled) { |  | 
|  402   NOTREACHED(); |  | 
|  403 } |  | 
|  404  |  | 
|  405 void OffTheRecordProfileImpl::InitPromoResources() { |  390 void OffTheRecordProfileImpl::InitPromoResources() { | 
|  406   NOTREACHED(); |  391   NOTREACHED(); | 
|  407 } |  392 } | 
|  408  |  393  | 
|  409 void OffTheRecordProfileImpl::InitRegisteredProtocolHandlers() { |  394 void OffTheRecordProfileImpl::InitRegisteredProtocolHandlers() { | 
|  410   NOTREACHED(); |  395   NOTREACHED(); | 
|  411 } |  396 } | 
|  412  |  397  | 
|  413 FilePath OffTheRecordProfileImpl::last_selected_directory() { |  398 FilePath OffTheRecordProfileImpl::last_selected_directory() { | 
|  414   const FilePath& directory = last_selected_directory_; |  399   const FilePath& directory = last_selected_directory_; | 
| (...skipping 17 matching lines...) Expand all  Loading... | 
|  432 void OffTheRecordProfileImpl::SetupChromeOSEnterpriseExtensionObserver() { |  417 void OffTheRecordProfileImpl::SetupChromeOSEnterpriseExtensionObserver() { | 
|  433   profile_->SetupChromeOSEnterpriseExtensionObserver(); |  418   profile_->SetupChromeOSEnterpriseExtensionObserver(); | 
|  434 } |  419 } | 
|  435  |  420  | 
|  436 void OffTheRecordProfileImpl::InitChromeOSPreferences() { |  421 void OffTheRecordProfileImpl::InitChromeOSPreferences() { | 
|  437   // The incognito profile shouldn't have Chrome OS's preferences. |  422   // The incognito profile shouldn't have Chrome OS's preferences. | 
|  438   // The preferences are associated with the regular user profile. |  423   // The preferences are associated with the regular user profile. | 
|  439 } |  424 } | 
|  440 #endif  // defined(OS_CHROMEOS) |  425 #endif  // defined(OS_CHROMEOS) | 
|  441  |  426  | 
|  442 ExtensionInfoMap* OffTheRecordProfileImpl::GetExtensionInfoMap() { |  | 
|  443   return profile_->GetExtensionInfoMap(); |  | 
|  444 } |  | 
|  445  |  | 
|  446 ChromeURLDataManager* OffTheRecordProfileImpl::GetChromeURLDataManager() { |  427 ChromeURLDataManager* OffTheRecordProfileImpl::GetChromeURLDataManager() { | 
|  447   if (!chrome_url_data_manager_.get()) |  428   if (!chrome_url_data_manager_.get()) | 
|  448     chrome_url_data_manager_.reset(new ChromeURLDataManager( |  429     chrome_url_data_manager_.reset(new ChromeURLDataManager( | 
|  449         io_data_.GetChromeURLDataManagerBackendGetter())); |  430         io_data_.GetChromeURLDataManagerBackendGetter())); | 
|  450   return chrome_url_data_manager_.get(); |  431   return chrome_url_data_manager_.get(); | 
|  451 } |  432 } | 
|  452  |  433  | 
|  453 PromoCounter* OffTheRecordProfileImpl::GetInstantPromoCounter() { |  434 PromoCounter* OffTheRecordProfileImpl::GetInstantPromoCounter() { | 
|  454   return NULL; |  435   return NULL; | 
|  455 } |  436 } | 
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  526   OffTheRecordProfileImpl* profile = NULL; |  507   OffTheRecordProfileImpl* profile = NULL; | 
|  527 #if defined(OS_CHROMEOS) |  508 #if defined(OS_CHROMEOS) | 
|  528   if (Profile::IsGuestSession()) |  509   if (Profile::IsGuestSession()) | 
|  529     profile = new GuestSessionProfile(this); |  510     profile = new GuestSessionProfile(this); | 
|  530 #endif |  511 #endif | 
|  531   if (!profile) |  512   if (!profile) | 
|  532     profile = new OffTheRecordProfileImpl(this); |  513     profile = new OffTheRecordProfileImpl(this); | 
|  533   profile->Init(); |  514   profile->Init(); | 
|  534   return profile; |  515   return profile; | 
|  535 } |  516 } | 
| OLD | NEW |