| 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 11 matching lines...) Expand all Loading... |
| 22 #include "content/public/browser/notification_service.h" | 22 #include "content/public/browser/notification_service.h" |
| 23 #include "content/public/browser/render_frame_host.h" | 23 #include "content/public/browser/render_frame_host.h" |
| 24 #include "content/public/browser/render_process_host.h" | 24 #include "content/public/browser/render_process_host.h" |
| 25 #include "content/public/browser/render_view_host.h" | 25 #include "content/public/browser/render_view_host.h" |
| 26 #include "content/public/browser/site_instance.h" | 26 #include "content/public/browser/site_instance.h" |
| 27 #include "content/public/browser/web_contents.h" | 27 #include "content/public/browser/web_contents.h" |
| 28 #include "content/public/browser/web_contents_delegate.h" | 28 #include "content/public/browser/web_contents_delegate.h" |
| 29 #include "content/public/browser/web_contents_observer.h" | 29 #include "content/public/browser/web_contents_observer.h" |
| 30 #include "content/public/browser/web_contents_user_data.h" | 30 #include "content/public/browser/web_contents_user_data.h" |
| 31 #include "content/public/common/renderer_preferences.h" | 31 #include "content/public/common/renderer_preferences.h" |
| 32 #include "content/public/common/url_constants.h" |
| 32 #include "extensions/browser/extension_host.h" | 33 #include "extensions/browser/extension_host.h" |
| 33 #include "extensions/browser/extension_registry.h" | 34 #include "extensions/browser/extension_registry.h" |
| 34 #include "extensions/browser/extension_system.h" | 35 #include "extensions/browser/extension_system.h" |
| 35 #include "extensions/browser/extensions_browser_client.h" | 36 #include "extensions/browser/extensions_browser_client.h" |
| 36 #include "extensions/browser/view_type_utils.h" | 37 #include "extensions/browser/view_type_utils.h" |
| 38 #include "extensions/common/constants.h" |
| 37 #include "extensions/common/extension.h" | 39 #include "extensions/common/extension.h" |
| 38 #include "extensions/common/extension_messages.h" | 40 #include "extensions/common/extension_messages.h" |
| 39 #include "extensions/common/manifest_handlers/background_info.h" | 41 #include "extensions/common/manifest_handlers/background_info.h" |
| 40 #include "extensions/common/manifest_handlers/incognito_info.h" | 42 #include "extensions/common/manifest_handlers/incognito_info.h" |
| 41 #include "extensions/common/one_shot_event.h" | 43 #include "extensions/common/one_shot_event.h" |
| 42 #include "extensions/common/switches.h" | 44 #include "extensions/common/switches.h" |
| 43 | 45 |
| 44 using content::BrowserContext; | 46 using content::BrowserContext; |
| 45 using content::RenderViewHost; | 47 using content::RenderViewHost; |
| 46 using content::SiteInstance; | 48 using content::SiteInstance; |
| 47 using content::WebContents; | 49 using content::WebContents; |
| 48 | 50 |
| 49 namespace extensions { | 51 namespace extensions { |
| 50 class RenderViewHostDestructionObserver; | 52 class RenderViewHostDestructionObserver; |
| 51 } | 53 } |
| 52 DEFINE_WEB_CONTENTS_USER_DATA_KEY( | 54 DEFINE_WEB_CONTENTS_USER_DATA_KEY( |
| 53 extensions::RenderViewHostDestructionObserver); | 55 extensions::RenderViewHostDestructionObserver); |
| 54 | 56 |
| 55 namespace extensions { | 57 namespace extensions { |
| 56 | 58 |
| 57 namespace { | 59 namespace { |
| 58 | 60 |
| 59 std::string GetExtensionID(RenderViewHost* render_view_host) { | 61 std::string GetExtensionID(RenderViewHost* render_view_host) { |
| 60 // This works for both apps and extensions because the site has been | 62 // This works for both apps and extensions because the site has been |
| 61 // normalized to the extension URL for apps. | 63 // normalized to the extension URL for hosted apps. |
| 62 if (!render_view_host->GetSiteInstance()) | 64 content::SiteInstance* site_instance = render_view_host->GetSiteInstance(); |
| 65 if (!site_instance) |
| 63 return std::string(); | 66 return std::string(); |
| 64 | 67 |
| 65 return render_view_host->GetSiteInstance()->GetSiteURL().host(); | 68 const GURL& site_url = site_instance->GetSiteURL(); |
| 69 |
| 70 if (!site_url.SchemeIs(kExtensionScheme) && |
| 71 !site_url.SchemeIs(content::kGuestScheme)) |
| 72 return std::string(); |
| 73 |
| 74 return site_url.host(); |
| 66 } | 75 } |
| 67 | 76 |
| 68 std::string GetExtensionIDFromFrame( | 77 std::string GetExtensionIDFromFrame( |
| 69 content::RenderFrameHost* render_frame_host) { | 78 content::RenderFrameHost* render_frame_host) { |
| 70 // This works for both apps and extensions because the site has been | 79 // This works for both apps and extensions because the site has been |
| 71 // normalized to the extension URL for apps. | 80 // normalized to the extension URL for apps. |
| 72 if (!render_frame_host->GetSiteInstance()) | 81 if (!render_frame_host->GetSiteInstance()) |
| 73 return std::string(); | 82 return std::string(); |
| 74 | 83 |
| 75 return render_frame_host->GetSiteInstance()->GetSiteURL().host(); | 84 return render_frame_host->GetSiteInstance()->GetSiteURL().host(); |
| (...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 909 const Extension* extension = | 918 const Extension* extension = |
| 910 registry->enabled_extensions().GetExtensionOrAppByURL(url); | 919 registry->enabled_extensions().GetExtensionOrAppByURL(url); |
| 911 if (extension && !IncognitoInfo::IsSplitMode(extension)) { | 920 if (extension && !IncognitoInfo::IsSplitMode(extension)) { |
| 912 return original_manager_->GetSiteInstanceForURL(url); | 921 return original_manager_->GetSiteInstanceForURL(url); |
| 913 } | 922 } |
| 914 } | 923 } |
| 915 return ProcessManager::GetSiteInstanceForURL(url); | 924 return ProcessManager::GetSiteInstanceForURL(url); |
| 916 } | 925 } |
| 917 | 926 |
| 918 } // namespace extensions | 927 } // namespace extensions |
| OLD | NEW |