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

Side by Side Diff: content/browser/frame_host/render_frame_host_manager.cc

Issue 1145353002: Ensure WebUI bindings are properly set (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 | « 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 "content/browser/frame_host/render_frame_host_manager.h" 5 #include "content/browser/frame_host/render_frame_host_manager.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 1468 matching lines...) Expand 10 before | Expand all | Expand 10 after
1479 if (view_routing_id_ptr) 1479 if (view_routing_id_ptr)
1480 *view_routing_id_ptr = proxy->GetRenderViewHost()->GetRoutingID(); 1480 *view_routing_id_ptr = proxy->GetRenderViewHost()->GetRoutingID();
1481 // Delete the existing RenderFrameProxyHost, but reuse the RenderFrameHost. 1481 // Delete the existing RenderFrameProxyHost, but reuse the RenderFrameHost.
1482 // Prevent the process from exiting while we're trying to use it. 1482 // Prevent the process from exiting while we're trying to use it.
1483 if (!swapped_out) { 1483 if (!swapped_out) {
1484 new_render_frame_host = proxy->PassFrameHostOwnership(); 1484 new_render_frame_host = proxy->PassFrameHostOwnership();
1485 new_render_frame_host->GetProcess()->AddPendingView(); 1485 new_render_frame_host->GetProcess()->AddPendingView();
1486 1486
1487 proxy_hosts_.erase(instance->GetId()); 1487 proxy_hosts_.erase(instance->GetId());
1488 delete proxy; 1488 delete proxy;
1489
1490 // When a new render view is created by the renderer, the new WebContents
1491 // gets a RenderViewHost in the SiteInstance of its opener WebContents.
1492 // If not used in the first navigation, this RVH is swapped out and is not
1493 // granted bindings, so we may need to grant them when swapping it in.
1494 if (web_ui && !new_render_frame_host->GetProcess()->IsIsolatedGuest()) {
1495 int required_bindings = web_ui->GetBindings();
1496 RenderViewHost* render_view_host =
1497 new_render_frame_host->render_view_host();
1498 if ((render_view_host->GetEnabledBindings() & required_bindings) !=
1499 required_bindings) {
1500 render_view_host->AllowBindings(required_bindings);
1501 }
1502 }
1503 } 1489 }
1504 } else { 1490 } else {
1505 // Create a new RenderFrameHost if we don't find an existing one. 1491 // Create a new RenderFrameHost if we don't find an existing one.
1506 new_render_frame_host = CreateRenderFrameHost(instance, MSG_ROUTING_NONE, 1492 new_render_frame_host = CreateRenderFrameHost(instance, MSG_ROUTING_NONE,
1507 MSG_ROUTING_NONE, flags); 1493 MSG_ROUTING_NONE, flags);
1508 RenderViewHostImpl* render_view_host = 1494 RenderViewHostImpl* render_view_host =
1509 new_render_frame_host->render_view_host(); 1495 new_render_frame_host->render_view_host();
1510 int proxy_routing_id = MSG_ROUTING_NONE; 1496 int proxy_routing_id = MSG_ROUTING_NONE;
1511 1497
1512 // Prevent the process from exiting while we're trying to navigate in it. 1498 // Prevent the process from exiting while we're trying to navigate in it.
(...skipping 28 matching lines...) Expand all
1541 success = InitRenderFrame(new_render_frame_host.get()); 1527 success = InitRenderFrame(new_render_frame_host.get());
1542 } 1528 }
1543 } 1529 }
1544 1530
1545 if (success) { 1531 if (success) {
1546 if (view_routing_id_ptr) 1532 if (view_routing_id_ptr)
1547 *view_routing_id_ptr = render_view_host->GetRoutingID(); 1533 *view_routing_id_ptr = render_view_host->GetRoutingID();
1548 } 1534 }
1549 } 1535 }
1550 1536
1537 // When a new RenderView is created by the renderer process, the new
1538 // WebContents gets a RenderViewHost in the SiteInstance of its opener
1539 // WebContents. If not used in the first navigation, this RVH is swapped out
1540 // and is not granted bindings, so we may need to grant them when swapping it
1541 // in.
1542 if (web_ui && !new_render_frame_host->GetProcess()->IsIsolatedGuest()) {
1543 int required_bindings = web_ui->GetBindings();
1544 RenderViewHost* render_view_host =
1545 new_render_frame_host->render_view_host();
1546 if ((render_view_host->GetEnabledBindings() & required_bindings) !=
1547 required_bindings) {
1548 render_view_host->AllowBindings(required_bindings);
1549 }
1550 }
1551
1551 // Returns the new RFH if it isn't swapped out. 1552 // Returns the new RFH if it isn't swapped out.
1552 if (success && !swapped_out) { 1553 if (success && !swapped_out) {
1553 DCHECK(new_render_frame_host->GetSiteInstance() == instance); 1554 DCHECK(new_render_frame_host->GetSiteInstance() == instance);
1554 return new_render_frame_host.Pass(); 1555 return new_render_frame_host.Pass();
1555 } 1556 }
1556 return nullptr; 1557 return nullptr;
1557 } 1558 }
1558 1559
1559 int RenderFrameHostManager::CreateRenderFrameProxy(SiteInstance* instance) { 1560 int RenderFrameHostManager::CreateRenderFrameProxy(SiteInstance* instance) {
1560 // A RenderFrameProxyHost should never be created in the same SiteInstance as 1561 // A RenderFrameProxyHost should never be created in the same SiteInstance as
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
2109 void RenderFrameHostManager::DeleteRenderFrameProxyHost( 2110 void RenderFrameHostManager::DeleteRenderFrameProxyHost(
2110 SiteInstance* instance) { 2111 SiteInstance* instance) {
2111 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId()); 2112 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId());
2112 if (iter != proxy_hosts_.end()) { 2113 if (iter != proxy_hosts_.end()) {
2113 delete iter->second; 2114 delete iter->second;
2114 proxy_hosts_.erase(iter); 2115 proxy_hosts_.erase(iter);
2115 } 2116 }
2116 } 2117 }
2117 2118
2118 } // namespace content 2119 } // namespace content
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