| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 | 59 |
| 60 return render_view_host->GetSiteInstance()->GetSiteURL().host(); | 60 return render_view_host->GetSiteInstance()->GetSiteURL().host(); |
| 61 } | 61 } |
| 62 | 62 |
| 63 // Incognito profiles use this process manager. It is mostly a shim that decides | 63 // Incognito profiles use this process manager. It is mostly a shim that decides |
| 64 // whether to fall back on the original profile's ExtensionProcessManager based | 64 // whether to fall back on the original profile's ExtensionProcessManager based |
| 65 // on whether a given extension uses "split" or "spanning" incognito behavior. | 65 // on whether a given extension uses "split" or "spanning" incognito behavior. |
| 66 class IncognitoExtensionProcessManager : public ExtensionProcessManager { | 66 class IncognitoExtensionProcessManager : public ExtensionProcessManager { |
| 67 public: | 67 public: |
| 68 explicit IncognitoExtensionProcessManager(Profile* profile); | 68 explicit IncognitoExtensionProcessManager(Profile* profile); |
| 69 virtual ~IncognitoExtensionProcessManager() {} | 69 virtual ~IncognitoExtensionProcessManager(); |
| 70 virtual ExtensionHost* CreateViewHost( | 70 virtual ExtensionHost* CreateViewHost( |
| 71 const Extension* extension, | 71 const Extension* extension, |
| 72 const GURL& url, | 72 const GURL& url, |
| 73 Browser* browser, | 73 Browser* browser, |
| 74 chrome::ViewType view_type) OVERRIDE; | 74 chrome::ViewType view_type) OVERRIDE; |
| 75 virtual void CreateBackgroundHost(const Extension* extension, | 75 virtual void CreateBackgroundHost(const Extension* extension, |
| 76 const GURL& url); | 76 const GURL& url); |
| 77 virtual SiteInstance* GetSiteInstanceForURL(const GURL& url); | 77 virtual SiteInstance* GetSiteInstanceForURL(const GURL& url); |
| 78 | 78 |
| 79 private: | 79 private: |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 event_page_unloading_time_ = base::TimeDelta::FromSeconds( | 181 event_page_unloading_time_ = base::TimeDelta::FromSeconds( |
| 182 unloading_time_sec); | 182 unloading_time_sec); |
| 183 } | 183 } |
| 184 } | 184 } |
| 185 | 185 |
| 186 ExtensionProcessManager::~ExtensionProcessManager() { | 186 ExtensionProcessManager::~ExtensionProcessManager() { |
| 187 CloseBackgroundHosts(); | 187 CloseBackgroundHosts(); |
| 188 DCHECK(background_hosts_.empty()); | 188 DCHECK(background_hosts_.empty()); |
| 189 } | 189 } |
| 190 | 190 |
| 191 const ExtensionProcessManager::ViewSet |
| 192 ExtensionProcessManager::GetAllViews() const { |
| 193 ViewSet result; |
| 194 for (ExtensionRenderViews::const_iterator iter = |
| 195 all_extension_views_.begin(); |
| 196 iter != all_extension_views_.end(); ++iter) { |
| 197 result.insert(iter->first); |
| 198 } |
| 199 return result; |
| 200 } |
| 201 |
| 191 void ExtensionProcessManager::EnsureBrowserWhenRequired( | 202 void ExtensionProcessManager::EnsureBrowserWhenRequired( |
| 192 Browser* browser, | 203 Browser* browser, |
| 193 chrome::ViewType view_type) { | 204 chrome::ViewType view_type) { |
| 194 if (!browser) { | 205 if (!browser) { |
| 195 #if defined (OS_CHROMEOS) | 206 #if defined (OS_CHROMEOS) |
| 196 // On ChromeOS we'll only use ExtensionView, which | 207 // On ChromeOS we'll only use ExtensionView, which |
| 197 // does not use the browser parameter. | 208 // does not use the browser parameter. |
| 198 // TODO(rkc): Remove all this once we create a new host for | 209 // TODO(rkc): Remove all this once we create a new host for |
| 199 // screensaver extensions (crosbug.com/28211). | 210 // screensaver extensions (crosbug.com/28211). |
| 200 DCHECK(view_type == chrome::VIEW_TYPE_EXTENSION_POPUP || | 211 DCHECK(view_type == chrome::VIEW_TYPE_EXTENSION_POPUP || |
| (...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 727 Profile* profile) | 738 Profile* profile) |
| 728 : ExtensionProcessManager(profile), | 739 : ExtensionProcessManager(profile), |
| 729 original_manager_(extensions::ExtensionSystem::Get( | 740 original_manager_(extensions::ExtensionSystem::Get( |
| 730 profile->GetOriginalProfile())->process_manager()) { | 741 profile->GetOriginalProfile())->process_manager()) { |
| 731 DCHECK(profile->IsOffTheRecord()); | 742 DCHECK(profile->IsOffTheRecord()); |
| 732 | 743 |
| 733 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_WINDOW_READY, | 744 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_WINDOW_READY, |
| 734 content::NotificationService::AllSources()); | 745 content::NotificationService::AllSources()); |
| 735 } | 746 } |
| 736 | 747 |
| 737 const ExtensionProcessManager::ViewSet | 748 IncognitoExtensionProcessManager::~IncognitoExtensionProcessManager() { |
| 738 ExtensionProcessManager::GetAllViews() const { | 749 // TODO(yoz): This cleanup code belongs in the MenuManager. |
| 739 ViewSet result; | 750 // Remove "incognito" "split" mode context menu items. |
| 740 for (ExtensionRenderViews::const_iterator iter = | 751 ExtensionService* service = |
| 741 all_extension_views_.begin(); | 752 extensions::ExtensionSystem::Get(GetProfile())->extension_service(); |
| 742 iter != all_extension_views_.end(); ++iter) { | 753 if (service) |
| 743 result.insert(iter->first); | 754 service->menu_manager()->RemoveAllIncognitoContextItems(); |
| 744 } | |
| 745 return result; | |
| 746 } | 755 } |
| 747 | 756 |
| 748 ExtensionHost* IncognitoExtensionProcessManager::CreateViewHost( | 757 ExtensionHost* IncognitoExtensionProcessManager::CreateViewHost( |
| 749 const Extension* extension, | 758 const Extension* extension, |
| 750 const GURL& url, | 759 const GURL& url, |
| 751 Browser* browser, | 760 Browser* browser, |
| 752 chrome::ViewType view_type) { | 761 chrome::ViewType view_type) { |
| 753 if (extension->incognito_split_mode()) { | 762 if (extension->incognito_split_mode()) { |
| 754 if (IsIncognitoEnabled(extension)) { | 763 if (IsIncognitoEnabled(extension)) { |
| 755 return ExtensionProcessManager::CreateViewHost(extension, url, | 764 return ExtensionProcessManager::CreateViewHost(extension, url, |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 815 CreateBackgroundHostsForProfileStartup(GetProfile(), | 824 CreateBackgroundHostsForProfileStartup(GetProfile(), |
| 816 this, service->extensions()); | 825 this, service->extensions()); |
| 817 } | 826 } |
| 818 break; | 827 break; |
| 819 } | 828 } |
| 820 default: | 829 default: |
| 821 ExtensionProcessManager::Observe(type, source, details); | 830 ExtensionProcessManager::Observe(type, source, details); |
| 822 break; | 831 break; |
| 823 } | 832 } |
| 824 } | 833 } |
| OLD | NEW |