• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2012 The Chromium Embedded Framework Authors.
2 // Portions copyright (c) 2011 The Chromium Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 
6 #include "libcef/renderer/render_frame_util.h"
7 
8 #include "libcef/common/frame_util.h"
9 #include "libcef/renderer/blink_glue.h"
10 
11 #include "base/logging.h"
12 #include "content/public/renderer/render_thread.h"
13 #include "content/public/renderer/render_view.h"
14 #include "content/renderer/render_frame_impl.h"
15 #include "third_party/blink/public/web/web_local_frame.h"
16 
17 namespace render_frame_util {
18 
GetIdentifier(blink::WebLocalFrame * frame)19 int64_t GetIdentifier(blink::WebLocalFrame* frame) {
20   // Each WebFrame will have an associated RenderFrame. The RenderFrame
21   // routing IDs are unique within a given renderer process.
22   content::RenderFrame* render_frame =
23       content::RenderFrame::FromWebFrame(frame);
24   return frame_util::MakeFrameId(content::RenderThread::Get()->GetClientId(),
25                                  render_frame->GetRoutingID());
26 }
27 
GetName(blink::WebLocalFrame * frame)28 std::string GetName(blink::WebLocalFrame* frame) {
29   DCHECK(frame);
30   // Return the assigned name if it is non-empty. This represents the name
31   // property on the frame DOM element. If the assigned name is empty, revert to
32   // the internal unique name. This matches the logic in
33   // CefFrameHostImpl::RefreshAttributes.
34   if (frame->AssignedName().length() > 0) {
35     return frame->AssignedName().Utf8();
36   }
37   content::RenderFrameImpl* render_frame =
38       content::RenderFrameImpl::FromWebFrame(frame);
39   DCHECK(render_frame);
40   if (render_frame)
41     return render_frame->unique_name();
42   return std::string();
43 }
44 
45 }  // namespace render_frame_util
46