| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/web_frame_utils.h" | 5 #include "content/renderer/web_frame_utils.h" |
| 6 | 6 |
| 7 #include "content/renderer/render_frame_impl.h" | 7 #include "content/renderer/render_frame_impl.h" |
| 8 #include "content/renderer/render_frame_proxy.h" | 8 #include "content/renderer/render_frame_proxy.h" |
| 9 #include "ipc/ipc_message.h" | 9 #include "ipc/ipc_message.h" |
| 10 #include "third_party/WebKit/public/web/WebFrame.h" | 10 #include "third_party/WebKit/public/web/WebFrame.h" |
| 11 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 11 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| 12 #include "third_party/WebKit/public/web/WebRemoteFrame.h" | 12 #include "third_party/WebKit/public/web/WebRemoteFrame.h" |
| 13 | 13 |
| 14 namespace content { | 14 namespace content { |
| 15 | 15 |
| 16 int GetRoutingIdForFrameOrProxy(blink::WebFrame* web_frame) { | |
| 17 if (!web_frame) | |
| 18 return MSG_ROUTING_NONE; | |
| 19 if (web_frame->IsWebRemoteFrame()) | |
| 20 return RenderFrameProxy::FromWebFrame(web_frame)->routing_id(); | |
| 21 return RenderFrameImpl::FromWebFrame(web_frame)->GetRoutingID(); | |
| 22 } | |
| 23 | |
| 24 blink::WebFrame* GetWebFrameFromRoutingIdForFrameOrProxy(int routing_id) { | 16 blink::WebFrame* GetWebFrameFromRoutingIdForFrameOrProxy(int routing_id) { |
| 25 auto* render_frame = RenderFrameImpl::FromRoutingID(routing_id); | 17 auto* render_frame = RenderFrameImpl::FromRoutingID(routing_id); |
| 26 if (render_frame) | 18 if (render_frame) |
| 27 return render_frame->GetWebFrame(); | 19 return render_frame->GetWebFrame(); |
| 28 | 20 |
| 29 auto* render_frame_proxy = RenderFrameProxy::FromRoutingID(routing_id); | 21 auto* render_frame_proxy = RenderFrameProxy::FromRoutingID(routing_id); |
| 30 if (render_frame_proxy) | 22 if (render_frame_proxy) |
| 31 return render_frame_proxy->web_frame(); | 23 return render_frame_proxy->web_frame(); |
| 32 | 24 |
| 33 return nullptr; | 25 return nullptr; |
| 34 } | 26 } |
| 35 | 27 |
| 36 } // namespace content | 28 } // namespace content |
| OLD | NEW |