OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/extension_web_contents_observer.h" | 5 #include "extensions/browser/extension_web_contents_observer.h" |
6 | 6 |
7 #include "content/public/browser/child_process_security_policy.h" | 7 #include "content/public/browser/child_process_security_policy.h" |
8 #include "content/public/browser/render_frame_host.h" | 8 #include "content/public/browser/render_frame_host.h" |
9 #include "content/public/browser/render_process_host.h" | 9 #include "content/public/browser/render_process_host.h" |
10 #include "content/public/browser/render_view_host.h" | 10 #include "content/public/browser/render_view_host.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
70 | 70 |
71 void ExtensionWebContentsObserver::RenderViewCreated( | 71 void ExtensionWebContentsObserver::RenderViewCreated( |
72 content::RenderViewHost* render_view_host) { | 72 content::RenderViewHost* render_view_host) { |
73 // TODO(devlin): Most/all of this should move to RenderFrameCreated. | 73 // TODO(devlin): Most/all of this should move to RenderFrameCreated. |
74 const Extension* extension = GetExtension(render_view_host); | 74 const Extension* extension = GetExtension(render_view_host); |
75 if (!extension) | 75 if (!extension) |
76 return; | 76 return; |
77 | 77 |
78 content::RenderProcessHost* process = render_view_host->GetProcess(); | 78 content::RenderProcessHost* process = render_view_host->GetProcess(); |
79 | 79 |
80 // Some extensions use chrome:// URLs. | 80 // Some extensions use "chrome://resources/" URLs. |
Charlie Reis
2015/09/22 17:38:15
Again, I'm not sure why this is handled separately
paulmeyer
2015/09/22 22:13:57
See other comment. I'll move this out to the chrom
| |
81 // This is a temporary solution. Replace it with access to chrome-static:// | |
82 // once it is implemented. See: crbug.com/226927. | |
83 Manifest::Type type = extension->GetType(); | 81 Manifest::Type type = extension->GetType(); |
84 if (type == Manifest::TYPE_EXTENSION || | 82 if (type == Manifest::TYPE_EXTENSION || |
85 type == Manifest::TYPE_LEGACY_PACKAGED_APP || | 83 type == Manifest::TYPE_LEGACY_PACKAGED_APP || |
86 (type == Manifest::TYPE_PLATFORM_APP && | 84 (type == Manifest::TYPE_PLATFORM_APP && |
87 extension->location() == Manifest::COMPONENT)) { | 85 extension->location() == Manifest::COMPONENT)) { |
88 content::ChildProcessSecurityPolicy::GetInstance()->GrantScheme( | 86 content::ChildProcessSecurityPolicy::GetInstance()->GrantSchemeHost( |
89 process->GetID(), content::kChromeUIScheme); | 87 process->GetID(), content::kChromeUIScheme, |
88 content::kChromeUIResourcesHost); | |
90 } | 89 } |
91 | 90 |
92 // Some extensions use file:// URLs. | 91 // Some extensions use "file://" URLs. |
Charlie Reis
2015/09/22 17:38:15
nit: No need for quotes (or churn on this line).
paulmeyer
2015/09/22 22:13:57
Done.
| |
93 if (type == Manifest::TYPE_EXTENSION || | 92 if (type == Manifest::TYPE_EXTENSION || |
94 type == Manifest::TYPE_LEGACY_PACKAGED_APP) { | 93 type == Manifest::TYPE_LEGACY_PACKAGED_APP) { |
95 ExtensionPrefs* prefs = ExtensionPrefs::Get(browser_context_); | 94 ExtensionPrefs* prefs = ExtensionPrefs::Get(browser_context_); |
96 if (prefs->AllowFileAccess(extension->id())) { | 95 if (prefs->AllowFileAccess(extension->id())) { |
97 content::ChildProcessSecurityPolicy::GetInstance()->GrantScheme( | 96 content::ChildProcessSecurityPolicy::GetInstance()->GrantScheme( |
98 process->GetID(), url::kFileScheme); | 97 process->GetID(), url::kFileScheme); |
99 } | 98 } |
100 } | 99 } |
101 | 100 |
102 // Tells the new view that it's hosted in an extension process. | 101 // Tells the new view that it's hosted in an extension process. |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
208 // Since this is called for all existing RenderFrameHosts during the | 207 // Since this is called for all existing RenderFrameHosts during the |
209 // ExtensionWebContentsObserver's creation, it's possible that not all hosts | 208 // ExtensionWebContentsObserver's creation, it's possible that not all hosts |
210 // are ready. | 209 // are ready. |
211 // We only initialize the frame if the renderer counterpart is live; otherwise | 210 // We only initialize the frame if the renderer counterpart is live; otherwise |
212 // we wait for the RenderFrameCreated notification. | 211 // we wait for the RenderFrameCreated notification. |
213 if (render_frame_host->IsRenderFrameLive()) | 212 if (render_frame_host->IsRenderFrameLive()) |
214 InitializeRenderFrame(render_frame_host); | 213 InitializeRenderFrame(render_frame_host); |
215 } | 214 } |
216 | 215 |
217 } // namespace extensions | 216 } // namespace extensions |
OLD | NEW |