Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(287)

Side by Side Diff: extensions/browser/process_manager.cc

Issue 216113007: Check the scheme of a RenderViewHost before assuming it contains an extension. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 16 matching lines...) Expand all
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 "extensions/browser/extension_host.h" 32 #include "extensions/browser/extension_host.h"
33 #include "extensions/browser/extension_registry.h" 33 #include "extensions/browser/extension_registry.h"
34 #include "extensions/browser/extension_system.h" 34 #include "extensions/browser/extension_system.h"
35 #include "extensions/browser/extensions_browser_client.h" 35 #include "extensions/browser/extensions_browser_client.h"
36 #include "extensions/browser/view_type_utils.h" 36 #include "extensions/browser/view_type_utils.h"
37 #include "extensions/common/constants.h"
37 #include "extensions/common/extension.h" 38 #include "extensions/common/extension.h"
38 #include "extensions/common/extension_messages.h" 39 #include "extensions/common/extension_messages.h"
39 #include "extensions/common/manifest_handlers/background_info.h" 40 #include "extensions/common/manifest_handlers/background_info.h"
40 #include "extensions/common/manifest_handlers/incognito_info.h" 41 #include "extensions/common/manifest_handlers/incognito_info.h"
41 #include "extensions/common/one_shot_event.h" 42 #include "extensions/common/one_shot_event.h"
42 #include "extensions/common/switches.h" 43 #include "extensions/common/switches.h"
43 44
44 using content::BrowserContext; 45 using content::BrowserContext;
45 using content::RenderViewHost; 46 using content::RenderViewHost;
46 using content::SiteInstance; 47 using content::SiteInstance;
47 using content::WebContents; 48 using content::WebContents;
48 49
49 namespace extensions { 50 namespace extensions {
50 class RenderViewHostDestructionObserver; 51 class RenderViewHostDestructionObserver;
51 } 52 }
52 DEFINE_WEB_CONTENTS_USER_DATA_KEY( 53 DEFINE_WEB_CONTENTS_USER_DATA_KEY(
53 extensions::RenderViewHostDestructionObserver); 54 extensions::RenderViewHostDestructionObserver);
54 55
55 namespace extensions { 56 namespace extensions {
56 57
57 namespace { 58 namespace {
58 59
59 std::string GetExtensionID(RenderViewHost* render_view_host) { 60 std::string GetExtensionID(RenderViewHost* render_view_host) {
60 // This works for both apps and extensions because the site has been 61 // This works for both apps and extensions because the site has been
61 // normalized to the extension URL for apps. 62 // normalized to the extension URL for hosted apps.
62 if (!render_view_host->GetSiteInstance()) 63 content::SiteInstance* site_instance = render_view_host->GetSiteInstance();
64 if (!site_instance)
63 return std::string(); 65 return std::string();
64 66
65 return render_view_host->GetSiteInstance()->GetSiteURL().host(); 67 if (site_instance->GetSiteURL().scheme() != kExtensionScheme)
ncarter (slow) 2014/03/28 19:25:31 Comments in GURL seem to suggest that .SchemeIs(kE
Jeffrey Yasskin 2014/03/28 20:19:36 Indeed, it's much better. Thanks.
68 return std::string();
69
70 return site_instance->GetSiteURL().host();
66 } 71 }
67 72
68 std::string GetExtensionIDFromFrame( 73 std::string GetExtensionIDFromFrame(
69 content::RenderFrameHost* render_frame_host) { 74 content::RenderFrameHost* render_frame_host) {
70 // This works for both apps and extensions because the site has been 75 // This works for both apps and extensions because the site has been
71 // normalized to the extension URL for apps. 76 // normalized to the extension URL for apps.
72 if (!render_frame_host->GetSiteInstance()) 77 if (!render_frame_host->GetSiteInstance())
73 return std::string(); 78 return std::string();
74 79
75 return render_frame_host->GetSiteInstance()->GetSiteURL().host(); 80 return render_frame_host->GetSiteInstance()->GetSiteURL().host();
(...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 const Extension* extension = 914 const Extension* extension =
910 registry->enabled_extensions().GetExtensionOrAppByURL(url); 915 registry->enabled_extensions().GetExtensionOrAppByURL(url);
911 if (extension && !IncognitoInfo::IsSplitMode(extension)) { 916 if (extension && !IncognitoInfo::IsSplitMode(extension)) {
912 return original_manager_->GetSiteInstanceForURL(url); 917 return original_manager_->GetSiteInstanceForURL(url);
913 } 918 }
914 } 919 }
915 return ProcessManager::GetSiteInstanceForURL(url); 920 return ProcessManager::GetSiteInstanceForURL(url);
916 } 921 }
917 922
918 } // namespace extensions 923 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698