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

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

Issue 2385553002: Revert of Lock down the registration of blob:chrome-extension:// URLs (Closed)
Patch Set: Created 4 years, 2 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
« no previous file with comments | « content/public/browser/child_process_security_policy.h ('k') | 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 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/navigation_details.h" 8 #include "content/public/browser/navigation_details.h"
9 #include "content/public/browser/render_frame_host.h" 9 #include "content/public/browser/render_frame_host.h"
10 #include "content/public/browser/render_process_host.h" 10 #include "content/public/browser/render_process_host.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 // At the initialization of the render frame, the last committed URL is not 56 // At the initialization of the render frame, the last committed URL is not
57 // reliable, so do not take it into account in determining whether it is an 57 // reliable, so do not take it into account in determining whether it is an
58 // extension frame. 58 // extension frame.
59 const Extension* frame_extension = 59 const Extension* frame_extension =
60 GetExtensionFromFrame(render_frame_host, false); 60 GetExtensionFromFrame(render_frame_host, false);
61 // This observer is attached to every WebContents, so we are also notified of 61 // This observer is attached to every WebContents, so we are also notified of
62 // frames that are not in an extension process. 62 // frames that are not in an extension process.
63 if (!frame_extension) 63 if (!frame_extension)
64 return; 64 return;
65 65
66 // |render_frame_host->GetProcess()| is an extension process. Grant permission
67 // to commit pages from chrome-extension:// origins.
68 content::ChildProcessSecurityPolicy* security_policy =
69 content::ChildProcessSecurityPolicy::GetInstance();
70 int process_id = render_frame_host->GetProcess()->GetID();
71 security_policy->GrantScheme(process_id, extensions::kExtensionScheme);
72 security_policy->GrantScheme(process_id,
73 extensions::kExtensionResourceScheme);
74
75 // Notify the render frame of the view type. 66 // Notify the render frame of the view type.
76 render_frame_host->Send(new ExtensionMsg_NotifyRenderViewType( 67 render_frame_host->Send(new ExtensionMsg_NotifyRenderViewType(
77 render_frame_host->GetRoutingID(), GetViewType(web_contents()))); 68 render_frame_host->GetRoutingID(), GetViewType(web_contents())));
78 69
79 ExtensionsBrowserClient::Get()->RegisterMojoServices(render_frame_host, 70 ExtensionsBrowserClient::Get()->RegisterMojoServices(render_frame_host,
80 frame_extension); 71 frame_extension);
81 ProcessManager::Get(browser_context_) 72 ProcessManager::Get(browser_context_)
82 ->RegisterRenderFrameHost(web_contents(), render_frame_host, 73 ->RegisterRenderFrameHost(web_contents(), render_frame_host,
83 frame_extension); 74 frame_extension);
84 } 75 }
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 // Since this is called for all existing RenderFrameHosts during the 282 // Since this is called for all existing RenderFrameHosts during the
292 // ExtensionWebContentsObserver's creation, it's possible that not all hosts 283 // ExtensionWebContentsObserver's creation, it's possible that not all hosts
293 // are ready. 284 // are ready.
294 // We only initialize the frame if the renderer counterpart is live; otherwise 285 // We only initialize the frame if the renderer counterpart is live; otherwise
295 // we wait for the RenderFrameCreated notification. 286 // we wait for the RenderFrameCreated notification.
296 if (render_frame_host->IsRenderFrameLive()) 287 if (render_frame_host->IsRenderFrameLive())
297 InitializeRenderFrame(render_frame_host); 288 InitializeRenderFrame(render_frame_host);
298 } 289 }
299 290
300 } // namespace extensions 291 } // namespace extensions
OLDNEW
« no previous file with comments | « content/public/browser/child_process_security_policy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698