| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "extensions/browser/process_manager.h" | 5 #include "extensions/browser/process_manager.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/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 content::Source<BrowserContext>(context), | 88 content::Source<BrowserContext>(context), |
| 89 content::Details<RenderViewHost>(render_view_host)); | 89 content::Details<RenderViewHost>(render_view_host)); |
| 90 } | 90 } |
| 91 | 91 |
| 92 // Incognito profiles use this process manager. It is mostly a shim that decides | 92 // Incognito profiles use this process manager. It is mostly a shim that decides |
| 93 // whether to fall back on the original profile's ProcessManager based | 93 // whether to fall back on the original profile's ProcessManager based |
| 94 // on whether a given extension uses "split" or "spanning" incognito behavior. | 94 // on whether a given extension uses "split" or "spanning" incognito behavior. |
| 95 class IncognitoProcessManager : public ProcessManager { | 95 class IncognitoProcessManager : public ProcessManager { |
| 96 public: | 96 public: |
| 97 IncognitoProcessManager(BrowserContext* incognito_context, | 97 IncognitoProcessManager(BrowserContext* incognito_context, |
| 98 BrowserContext* original_context); | 98 BrowserContext* original_context, |
| 99 ProcessManager* original_manager); |
| 99 virtual ~IncognitoProcessManager() {} | 100 virtual ~IncognitoProcessManager() {} |
| 100 virtual bool CreateBackgroundHost(const Extension* extension, | 101 virtual bool CreateBackgroundHost(const Extension* extension, |
| 101 const GURL& url) OVERRIDE; | 102 const GURL& url) OVERRIDE; |
| 102 virtual SiteInstance* GetSiteInstanceForURL(const GURL& url) OVERRIDE; | 103 virtual SiteInstance* GetSiteInstanceForURL(const GURL& url) OVERRIDE; |
| 103 | 104 |
| 104 private: | 105 private: |
| 105 ProcessManager* original_manager_; | 106 ProcessManager* original_manager_; |
| 106 | 107 |
| 107 DISALLOW_COPY_AND_ASSIGN(IncognitoProcessManager); | 108 DISALLOW_COPY_AND_ASSIGN(IncognitoProcessManager); |
| 108 }; | 109 }; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 // In the guest session, there is a single off-the-record context. Unlike | 183 // In the guest session, there is a single off-the-record context. Unlike |
| 183 // a regular incognito mode, background pages of extensions must be | 184 // a regular incognito mode, background pages of extensions must be |
| 184 // created regardless of whether extensions use "spanning" or "split" | 185 // created regardless of whether extensions use "spanning" or "split" |
| 185 // incognito behavior. | 186 // incognito behavior. |
| 186 BrowserContext* original_context = client->GetOriginalContext(context); | 187 BrowserContext* original_context = client->GetOriginalContext(context); |
| 187 return new ProcessManager(context, original_context); | 188 return new ProcessManager(context, original_context); |
| 188 } | 189 } |
| 189 | 190 |
| 190 if (context->IsOffTheRecord()) { | 191 if (context->IsOffTheRecord()) { |
| 191 BrowserContext* original_context = client->GetOriginalContext(context); | 192 BrowserContext* original_context = client->GetOriginalContext(context); |
| 192 return new IncognitoProcessManager(context, original_context); | 193 ProcessManager* original_manager = |
| 194 ExtensionSystem::Get(original_context)->process_manager(); |
| 195 return new IncognitoProcessManager( |
| 196 context, original_context, original_manager); |
| 193 } | 197 } |
| 194 | 198 |
| 195 return new ProcessManager(context, context); | 199 return new ProcessManager(context, context); |
| 196 } | 200 } |
| 197 | 201 |
| 202 // static |
| 203 ProcessManager* ProcessManager::CreateIncognitoForTesting( |
| 204 BrowserContext* incognito_context, |
| 205 BrowserContext* original_context, |
| 206 ProcessManager* original_manager) { |
| 207 DCHECK(incognito_context->IsOffTheRecord()); |
| 208 DCHECK(!original_context->IsOffTheRecord()); |
| 209 return new IncognitoProcessManager( |
| 210 incognito_context, original_context, original_manager); |
| 211 } |
| 212 |
| 198 ProcessManager::ProcessManager(BrowserContext* context, | 213 ProcessManager::ProcessManager(BrowserContext* context, |
| 199 BrowserContext* original_context) | 214 BrowserContext* original_context) |
| 200 : site_instance_(SiteInstance::Create(context)), | 215 : site_instance_(SiteInstance::Create(context)), |
| 201 startup_background_hosts_created_(false), | 216 startup_background_hosts_created_(false), |
| 202 devtools_callback_(base::Bind( | 217 devtools_callback_(base::Bind( |
| 203 &ProcessManager::OnDevToolsStateChanged, | 218 &ProcessManager::OnDevToolsStateChanged, |
| 204 base::Unretained(this))), | 219 base::Unretained(this))), |
| 205 weak_ptr_factory_(this) { | 220 weak_ptr_factory_(this) { |
| 206 registrar_.Add(this, chrome::NOTIFICATION_EXTENSIONS_READY, | 221 registrar_.Add(this, chrome::NOTIFICATION_EXTENSIONS_READY, |
| 207 content::Source<BrowserContext>(original_context)); | 222 content::Source<BrowserContext>(original_context)); |
| (...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 854 return ExtensionsBrowserClient::Get()->DeferLoadingBackgroundHosts( | 869 return ExtensionsBrowserClient::Get()->DeferLoadingBackgroundHosts( |
| 855 GetBrowserContext()); | 870 GetBrowserContext()); |
| 856 } | 871 } |
| 857 | 872 |
| 858 // | 873 // |
| 859 // IncognitoProcessManager | 874 // IncognitoProcessManager |
| 860 // | 875 // |
| 861 | 876 |
| 862 IncognitoProcessManager::IncognitoProcessManager( | 877 IncognitoProcessManager::IncognitoProcessManager( |
| 863 BrowserContext* incognito_context, | 878 BrowserContext* incognito_context, |
| 864 BrowserContext* original_context) | 879 BrowserContext* original_context, |
| 880 ProcessManager* original_manager) |
| 865 : ProcessManager(incognito_context, original_context), | 881 : ProcessManager(incognito_context, original_context), |
| 866 original_manager_( | 882 original_manager_(original_manager) { |
| 867 ExtensionSystem::Get(original_context)->process_manager()) { | |
| 868 DCHECK(incognito_context->IsOffTheRecord()); | 883 DCHECK(incognito_context->IsOffTheRecord()); |
| 869 | 884 |
| 870 // The original profile will have its own ProcessManager to | 885 // The original profile will have its own ProcessManager to |
| 871 // load the background pages of the spanning extensions. This process | 886 // load the background pages of the spanning extensions. This process |
| 872 // manager need only worry about the split mode extensions, which is handled | 887 // manager need only worry about the split mode extensions, which is handled |
| 873 // in the NOTIFICATION_BROWSER_WINDOW_READY notification handler. | 888 // in the NOTIFICATION_BROWSER_WINDOW_READY notification handler. |
| 874 registrar_.Remove(this, chrome::NOTIFICATION_EXTENSIONS_READY, | 889 registrar_.Remove(this, chrome::NOTIFICATION_EXTENSIONS_READY, |
| 875 content::Source<BrowserContext>(original_context)); | 890 content::Source<BrowserContext>(original_context)); |
| 876 registrar_.Remove(this, chrome::NOTIFICATION_PROFILE_CREATED, | 891 registrar_.Remove(this, chrome::NOTIFICATION_PROFILE_CREATED, |
| 877 content::Source<BrowserContext>(original_context)); | 892 content::Source<BrowserContext>(original_context)); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 896 const Extension* extension = | 911 const Extension* extension = |
| 897 registry->enabled_extensions().GetExtensionOrAppByURL(url); | 912 registry->enabled_extensions().GetExtensionOrAppByURL(url); |
| 898 if (extension && !IncognitoInfo::IsSplitMode(extension)) { | 913 if (extension && !IncognitoInfo::IsSplitMode(extension)) { |
| 899 return original_manager_->GetSiteInstanceForURL(url); | 914 return original_manager_->GetSiteInstanceForURL(url); |
| 900 } | 915 } |
| 901 } | 916 } |
| 902 return ProcessManager::GetSiteInstanceForURL(url); | 917 return ProcessManager::GetSiteInstanceForURL(url); |
| 903 } | 918 } |
| 904 | 919 |
| 905 } // namespace extensions | 920 } // namespace extensions |
| OLD | NEW |