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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 content::Details<RenderViewHost>(render_view_host)); | 76 content::Details<RenderViewHost>(render_view_host)); |
77 } | 77 } |
78 | 78 |
79 // Incognito profiles use this process manager. It is mostly a shim that decides | 79 // Incognito profiles use this process manager. It is mostly a shim that decides |
80 // whether to fall back on the original profile's ProcessManager based | 80 // whether to fall back on the original profile's ProcessManager based |
81 // on whether a given extension uses "split" or "spanning" incognito behavior. | 81 // on whether a given extension uses "split" or "spanning" incognito behavior. |
82 class IncognitoProcessManager : public ProcessManager { | 82 class IncognitoProcessManager : public ProcessManager { |
83 public: | 83 public: |
84 IncognitoProcessManager(BrowserContext* incognito_context, | 84 IncognitoProcessManager(BrowserContext* incognito_context, |
85 BrowserContext* original_context); | 85 BrowserContext* original_context); |
86 virtual ~IncognitoProcessManager(); | 86 virtual ~IncognitoProcessManager() {} |
87 virtual ExtensionHost* CreateBackgroundHost(const Extension* extension, | 87 virtual ExtensionHost* CreateBackgroundHost(const Extension* extension, |
88 const GURL& url) OVERRIDE; | 88 const GURL& url) OVERRIDE; |
89 virtual SiteInstance* GetSiteInstanceForURL(const GURL& url) OVERRIDE; | 89 virtual SiteInstance* GetSiteInstanceForURL(const GURL& url) OVERRIDE; |
90 | 90 |
91 private: | 91 private: |
92 // Returns true if the extension is allowed to run in incognito mode. | 92 // Returns true if the extension is allowed to run in incognito mode. |
93 bool IsIncognitoEnabled(const Extension* extension); | 93 bool IsIncognitoEnabled(const Extension* extension); |
94 | 94 |
95 ProcessManager* original_manager_; | 95 ProcessManager* original_manager_; |
96 | 96 |
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
785 // The original profile will have its own ProcessManager to | 785 // The original profile will have its own ProcessManager to |
786 // load the background pages of the spanning extensions. This process | 786 // load the background pages of the spanning extensions. This process |
787 // manager need only worry about the split mode extensions, which is handled | 787 // manager need only worry about the split mode extensions, which is handled |
788 // in the NOTIFICATION_BROWSER_WINDOW_READY notification handler. | 788 // in the NOTIFICATION_BROWSER_WINDOW_READY notification handler. |
789 registrar_.Remove(this, chrome::NOTIFICATION_EXTENSIONS_READY, | 789 registrar_.Remove(this, chrome::NOTIFICATION_EXTENSIONS_READY, |
790 content::Source<BrowserContext>(original_context)); | 790 content::Source<BrowserContext>(original_context)); |
791 registrar_.Remove(this, chrome::NOTIFICATION_PROFILE_CREATED, | 791 registrar_.Remove(this, chrome::NOTIFICATION_PROFILE_CREATED, |
792 content::Source<BrowserContext>(original_context)); | 792 content::Source<BrowserContext>(original_context)); |
793 } | 793 } |
794 | 794 |
795 IncognitoProcessManager::~IncognitoProcessManager() { | |
796 // TODO(yoz): This cleanup code belongs in the MenuManager. | |
797 // Remove "incognito" "split" mode context menu items. | |
798 ExtensionService* service = ExtensionSystem::GetForBrowserContext( | |
799 GetBrowserContext())->extension_service(); | |
800 if (service) | |
801 service->menu_manager()->RemoveAllIncognitoContextItems(); | |
802 } | |
803 | |
804 ExtensionHost* IncognitoProcessManager::CreateBackgroundHost( | 795 ExtensionHost* IncognitoProcessManager::CreateBackgroundHost( |
805 const Extension* extension, const GURL& url) { | 796 const Extension* extension, const GURL& url) { |
806 if (IncognitoInfo::IsSplitMode(extension)) { | 797 if (IncognitoInfo::IsSplitMode(extension)) { |
807 if (IsIncognitoEnabled(extension)) | 798 if (IsIncognitoEnabled(extension)) |
808 return ProcessManager::CreateBackgroundHost(extension, url); | 799 return ProcessManager::CreateBackgroundHost(extension, url); |
809 } else { | 800 } else { |
810 // Do nothing. If an extension is spanning, then its original-profile | 801 // Do nothing. If an extension is spanning, then its original-profile |
811 // background page is shared with incognito, so we don't create another. | 802 // background page is shared with incognito, so we don't create another. |
812 } | 803 } |
813 return NULL; | 804 return NULL; |
(...skipping 13 matching lines...) Expand all Loading... |
827 } | 818 } |
828 | 819 |
829 bool IncognitoProcessManager::IsIncognitoEnabled(const Extension* extension) { | 820 bool IncognitoProcessManager::IsIncognitoEnabled(const Extension* extension) { |
830 // Keep in sync with duplicate in extension_info_map.cc. | 821 // Keep in sync with duplicate in extension_info_map.cc. |
831 ExtensionService* service = ExtensionSystem::GetForBrowserContext( | 822 ExtensionService* service = ExtensionSystem::GetForBrowserContext( |
832 GetBrowserContext())->extension_service(); | 823 GetBrowserContext())->extension_service(); |
833 return extension_util::IsIncognitoEnabled(extension->id(), service); | 824 return extension_util::IsIncognitoEnabled(extension->id(), service); |
834 } | 825 } |
835 | 826 |
836 } // namespace extensions | 827 } // namespace extensions |
OLD | NEW |