| 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 "content/renderer/render_frame_proxy.h" | 5 #include "content/renderer/render_frame_proxy.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 } | 105 } |
| 106 | 106 |
| 107 // static | 107 // static |
| 108 RenderFrameProxy* RenderFrameProxy::FromRoutingID(int32 routing_id) { | 108 RenderFrameProxy* RenderFrameProxy::FromRoutingID(int32 routing_id) { |
| 109 RoutingIDProxyMap* proxies = g_routing_id_proxy_map.Pointer(); | 109 RoutingIDProxyMap* proxies = g_routing_id_proxy_map.Pointer(); |
| 110 RoutingIDProxyMap::iterator it = proxies->find(routing_id); | 110 RoutingIDProxyMap::iterator it = proxies->find(routing_id); |
| 111 return it == proxies->end() ? NULL : it->second; | 111 return it == proxies->end() ? NULL : it->second; |
| 112 } | 112 } |
| 113 | 113 |
| 114 // static | 114 // static |
| 115 RenderFrameProxy* RenderFrameProxy::FromWebFrame(blink::WebFrame* web_frame) { | 115 const RenderFrameProxy* RenderFrameProxy::FromWebFrame( |
| 116 FrameMap::iterator iter = g_frame_map.Get().find(web_frame); | 116 const blink::WebFrame* web_frame) { |
| 117 const auto& const_frame_map = const_cast<const FrameMap&>(g_frame_map.Get()); |
| 118 FrameMap::const_iterator iter = |
| 119 const_frame_map.find(const_cast<blink::WebFrame*>(web_frame)); |
| 117 if (iter != g_frame_map.Get().end()) { | 120 if (iter != g_frame_map.Get().end()) { |
| 118 RenderFrameProxy* proxy = iter->second; | 121 RenderFrameProxy* proxy = iter->second; |
| 119 DCHECK_EQ(web_frame, proxy->web_frame()); | 122 DCHECK_EQ(web_frame, proxy->web_frame()); |
| 120 return proxy; | 123 return proxy; |
| 121 } | 124 } |
| 122 return NULL; | 125 return NULL; |
| 123 } | 126 } |
| 124 | 127 |
| 128 // static |
| 129 RenderFrameProxy* RenderFrameProxy::FromWebFrame(blink::WebFrame* web_frame) { |
| 130 return const_cast<RenderFrameProxy*>(RenderFrameProxy::FromWebFrame( |
| 131 static_cast<const blink::WebFrame*>(web_frame))); |
| 132 } |
| 133 |
| 125 RenderFrameProxy::RenderFrameProxy(int routing_id, int frame_routing_id) | 134 RenderFrameProxy::RenderFrameProxy(int routing_id, int frame_routing_id) |
| 126 : routing_id_(routing_id), | 135 : routing_id_(routing_id), |
| 127 frame_routing_id_(frame_routing_id), | 136 frame_routing_id_(frame_routing_id), |
| 128 web_frame_(NULL), | 137 web_frame_(NULL), |
| 129 render_view_(NULL) { | 138 render_view_(NULL) { |
| 130 std::pair<RoutingIDProxyMap::iterator, bool> result = | 139 std::pair<RoutingIDProxyMap::iterator, bool> result = |
| 131 g_routing_id_proxy_map.Get().insert(std::make_pair(routing_id_, this)); | 140 g_routing_id_proxy_map.Get().insert(std::make_pair(routing_id_, this)); |
| 132 CHECK(result.second) << "Inserting a duplicate item."; | 141 CHECK(result.second) << "Inserting a duplicate item."; |
| 133 RenderThread::Get()->AddRoute(routing_id_, this); | 142 RenderThread::Get()->AddRoute(routing_id_, this); |
| 134 } | 143 } |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 // Only a LocalFrame (i.e., the caller of window.open) should be able to | 436 // Only a LocalFrame (i.e., the caller of window.open) should be able to |
| 428 // update another frame's opener. | 437 // update another frame's opener. |
| 429 DCHECK(opener->isWebLocalFrame()); | 438 DCHECK(opener->isWebLocalFrame()); |
| 430 | 439 |
| 431 int opener_routing_id = | 440 int opener_routing_id = |
| 432 RenderFrameImpl::FromWebFrame(opener->toWebLocalFrame())->GetRoutingID(); | 441 RenderFrameImpl::FromWebFrame(opener->toWebLocalFrame())->GetRoutingID(); |
| 433 Send(new FrameHostMsg_DidChangeOpener(routing_id_, opener_routing_id)); | 442 Send(new FrameHostMsg_DidChangeOpener(routing_id_, opener_routing_id)); |
| 434 } | 443 } |
| 435 | 444 |
| 436 } // namespace | 445 } // namespace |
| OLD | NEW |