2017-07-06 22:39:37 +02:00
|
|
|
// Copyright (c) 2012 The Chromium Embedded Framework Authors.
|
|
|
|
// Portions copyright (c) 2011 The Chromium Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#include "libcef/renderer/render_frame_util.h"
|
|
|
|
|
|
|
|
#include "libcef/renderer/webkit_glue.h"
|
|
|
|
|
|
|
|
#include "base/logging.h"
|
|
|
|
#include "content/renderer/render_frame_impl.h"
|
2017-09-06 23:40:58 +02:00
|
|
|
#include "third_party/WebKit/public/web/WebLocalFrame.h"
|
2017-07-06 22:39:37 +02:00
|
|
|
|
|
|
|
namespace render_frame_util {
|
|
|
|
|
2017-07-27 01:19:27 +02:00
|
|
|
int64_t GetIdentifier(blink::WebLocalFrame* frame) {
|
2017-07-06 22:39:37 +02:00
|
|
|
// Each WebFrame will have an associated RenderFrame. The RenderFrame
|
|
|
|
// routing IDs are unique within a given renderer process.
|
|
|
|
content::RenderFrame* render_frame =
|
|
|
|
content::RenderFrame::FromWebFrame(frame);
|
|
|
|
DCHECK(render_frame);
|
|
|
|
if (render_frame)
|
|
|
|
return render_frame->GetRoutingID();
|
|
|
|
return webkit_glue::kInvalidFrameId;
|
|
|
|
}
|
|
|
|
|
2018-03-28 19:30:15 +02:00
|
|
|
std::string GetName(blink::WebLocalFrame* frame) {
|
|
|
|
DCHECK(frame);
|
|
|
|
// Return the assigned name if it is non-empty. This represents the name
|
|
|
|
// property on the frame DOM element. If the assigned name is empty, revert to
|
|
|
|
// the internal unique name.
|
|
|
|
if (frame->AssignedName().length() > 0) {
|
|
|
|
return frame->AssignedName().Utf8();
|
|
|
|
}
|
2017-07-06 22:39:37 +02:00
|
|
|
content::RenderFrameImpl* render_frame =
|
|
|
|
content::RenderFrameImpl::FromWebFrame(frame);
|
|
|
|
DCHECK(render_frame);
|
|
|
|
if (render_frame)
|
|
|
|
return render_frame->unique_name();
|
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
|
2017-07-27 01:19:27 +02:00
|
|
|
} // namespace render_frame_util
|