mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Update source files for bracket style
This commit is contained in:
@ -129,8 +129,9 @@ AlloyContentRendererClient* AlloyContentRendererClient::Get() {
|
||||
scoped_refptr<base::SingleThreadTaskRunner>
|
||||
AlloyContentRendererClient::GetCurrentTaskRunner() {
|
||||
// Check if currently on the render thread.
|
||||
if (CEF_CURRENTLY_ON_RT())
|
||||
if (CEF_CURRENTLY_ON_RT()) {
|
||||
return render_task_runner_;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -138,8 +139,9 @@ void AlloyContentRendererClient::RunSingleProcessCleanup() {
|
||||
DCHECK(content::RenderProcessHost::run_renderer_in_process());
|
||||
|
||||
// Make sure the render thread was actually started.
|
||||
if (!render_task_runner_.get())
|
||||
if (!render_task_runner_.get()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) {
|
||||
RunSingleProcessCleanupOnUIThread();
|
||||
@ -160,8 +162,9 @@ void AlloyContentRendererClient::RunSingleProcessCleanup() {
|
||||
base::AutoLock lock_scope(single_process_cleanup_lock_);
|
||||
complete = single_process_cleanup_complete_;
|
||||
}
|
||||
if (!complete)
|
||||
if (!complete) {
|
||||
base::PlatformThread::YieldCurrentThread();
|
||||
}
|
||||
} while (!complete);
|
||||
}
|
||||
|
||||
@ -218,16 +221,18 @@ void AlloyContentRendererClient::RenderThreadStarted() {
|
||||
// If the command-line switch is specified then set the value that will be
|
||||
// checked in RenderThreadImpl::Init(). Otherwise, remove the application-
|
||||
// level value.
|
||||
if (command_line->HasSwitch(switches::kDisableScrollBounce))
|
||||
if (command_line->HasSwitch(switches::kDisableScrollBounce)) {
|
||||
value.reset(base::SysUTF8ToCFStringRef("false"));
|
||||
}
|
||||
|
||||
CFPreferencesSetAppValue(key, value, kCFPreferencesCurrentApplication);
|
||||
CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication);
|
||||
}
|
||||
#endif // BUILDFLAG(IS_MAC)
|
||||
|
||||
if (extensions::ExtensionsEnabled())
|
||||
if (extensions::ExtensionsEnabled()) {
|
||||
extensions_renderer_client_->RenderThreadStarted();
|
||||
}
|
||||
}
|
||||
|
||||
void AlloyContentRendererClient::ExposeInterfacesToBrowser(
|
||||
@ -317,8 +322,9 @@ bool AlloyContentRendererClient::IsPluginHandledExternally(
|
||||
const blink::WebElement& plugin_element,
|
||||
const GURL& original_url,
|
||||
const std::string& mime_type) {
|
||||
if (!extensions::ExtensionsEnabled())
|
||||
if (!extensions::ExtensionsEnabled()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
DCHECK(plugin_element.HasHTMLTagName("object") ||
|
||||
plugin_element.HasHTMLTagName("embed"));
|
||||
@ -390,8 +396,9 @@ void AlloyContentRendererClient::WillSendRequest(
|
||||
extensions_renderer_client_->WillSendRequest(frame, transition_type, url,
|
||||
site_for_cookies,
|
||||
initiator_origin, new_url);
|
||||
if (!new_url->is_empty())
|
||||
if (!new_url->is_empty()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -417,20 +424,23 @@ void AlloyContentRendererClient::GetSupportedKeySystems(
|
||||
|
||||
void AlloyContentRendererClient::RunScriptsAtDocumentStart(
|
||||
content::RenderFrame* render_frame) {
|
||||
if (extensions::ExtensionsEnabled())
|
||||
if (extensions::ExtensionsEnabled()) {
|
||||
extensions_renderer_client_->RunScriptsAtDocumentStart(render_frame);
|
||||
}
|
||||
}
|
||||
|
||||
void AlloyContentRendererClient::RunScriptsAtDocumentEnd(
|
||||
content::RenderFrame* render_frame) {
|
||||
if (extensions::ExtensionsEnabled())
|
||||
if (extensions::ExtensionsEnabled()) {
|
||||
extensions_renderer_client_->RunScriptsAtDocumentEnd(render_frame);
|
||||
}
|
||||
}
|
||||
|
||||
void AlloyContentRendererClient::RunScriptsAtDocumentIdle(
|
||||
content::RenderFrame* render_frame) {
|
||||
if (extensions::ExtensionsEnabled())
|
||||
if (extensions::ExtensionsEnabled()) {
|
||||
extensions_renderer_client_->RunScriptsAtDocumentIdle(render_frame);
|
||||
}
|
||||
}
|
||||
|
||||
void AlloyContentRendererClient::DevToolsAgentAttached() {
|
||||
@ -468,30 +478,34 @@ AlloyContentRendererClient::CreateURLLoaderThrottleProvider(
|
||||
void AlloyContentRendererClient::AppendContentSecurityPolicy(
|
||||
const blink::WebURL& url,
|
||||
blink::WebVector<blink::WebContentSecurityPolicyHeader>* csp) {
|
||||
if (!extensions::ExtensionsEnabled())
|
||||
if (!extensions::ExtensionsEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Don't apply default CSP to PDF renderers.
|
||||
// TODO(crbug.com/1252096): Lock down the CSP once style and script are no
|
||||
// longer injected inline by `pdf::PluginResponseWriter`. That class may be a
|
||||
// better place to define such CSP, or we may continue doing so here.
|
||||
if (pdf::IsPdfRenderer())
|
||||
if (pdf::IsPdfRenderer()) {
|
||||
return;
|
||||
}
|
||||
|
||||
DCHECK(csp);
|
||||
GURL gurl(url);
|
||||
const extensions::Extension* extension =
|
||||
extensions::RendererExtensionRegistry::Get()->GetExtensionOrAppByURL(
|
||||
gurl);
|
||||
if (!extension)
|
||||
if (!extension) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Append a minimum CSP to ensure the extension can't relax the default
|
||||
// applied CSP through means like Service Worker.
|
||||
const std::string* default_csp =
|
||||
extensions::CSPInfo::GetMinimumCSPToAppend(*extension, gurl.path());
|
||||
if (!default_csp)
|
||||
if (!default_csp) {
|
||||
return;
|
||||
}
|
||||
|
||||
csp->push_back({blink::WebString::FromUTF8(*default_csp),
|
||||
network::mojom::ContentSecurityPolicyType::kEnforce,
|
||||
@ -554,8 +568,9 @@ void AlloyContentRendererClient::RunSingleProcessCleanupOnUIThread() {
|
||||
// this task will only execute when running in multi-threaded message loop
|
||||
// mode (because otherwise the UI message loop has already stopped). Therefore
|
||||
// we need to explicitly delete the object when not running in this mode.
|
||||
if (!CefContext::Get()->settings().multi_threaded_message_loop)
|
||||
if (!CefContext::Get()->settings().multi_threaded_message_loop) {
|
||||
delete host;
|
||||
}
|
||||
}
|
||||
|
||||
// Enable deprecation warnings on Windows. See http://crbug.com/585142.
|
||||
|
@ -49,20 +49,23 @@ namespace blink_glue {
|
||||
const int64_t kInvalidFrameId = -1;
|
||||
|
||||
bool CanGoBack(blink::WebView* view) {
|
||||
if (!view)
|
||||
if (!view) {
|
||||
return false;
|
||||
}
|
||||
return view->HistoryBackListCount() > 0;
|
||||
}
|
||||
|
||||
bool CanGoForward(blink::WebView* view) {
|
||||
if (!view)
|
||||
if (!view) {
|
||||
return false;
|
||||
}
|
||||
return view->HistoryForwardListCount() > 0;
|
||||
}
|
||||
|
||||
void GoBack(blink::WebView* view) {
|
||||
if (!view)
|
||||
if (!view) {
|
||||
return;
|
||||
}
|
||||
|
||||
blink::WebFrame* main_frame = view->MainFrame();
|
||||
if (main_frame && main_frame->IsWebLocalFrame()) {
|
||||
@ -76,8 +79,9 @@ void GoBack(blink::WebView* view) {
|
||||
}
|
||||
|
||||
void GoForward(blink::WebView* view) {
|
||||
if (!view)
|
||||
if (!view) {
|
||||
return;
|
||||
}
|
||||
|
||||
blink::WebFrame* main_frame = view->MainFrame();
|
||||
if (main_frame && main_frame->IsWebLocalFrame()) {
|
||||
@ -102,8 +106,9 @@ blink::WebString DumpDocumentText(blink::WebLocalFrame* frame) {
|
||||
// We use the document element's text instead of the body text here because
|
||||
// not all documents have a body, such as XML documents.
|
||||
blink::WebElement document_element = frame->GetDocument().DocumentElement();
|
||||
if (document_element.IsNull())
|
||||
if (document_element.IsNull()) {
|
||||
return blink::WebString();
|
||||
}
|
||||
|
||||
blink::Element* web_element = document_element.Unwrap<blink::Element>();
|
||||
return blink::WebString(web_element->innerText());
|
||||
@ -188,12 +193,14 @@ v8::Local<v8::Value> ExecuteV8ScriptAndReturnValue(
|
||||
int start_line,
|
||||
v8::Local<v8::Context> context,
|
||||
v8::TryCatch& tryCatch) {
|
||||
if (start_line < 1)
|
||||
if (start_line < 1) {
|
||||
start_line = 1;
|
||||
}
|
||||
|
||||
blink::LocalFrame* frame = blink::ToLocalFrameIfNotDetached(context);
|
||||
if (!frame)
|
||||
if (!frame) {
|
||||
return v8::Local<v8::Value>();
|
||||
}
|
||||
|
||||
auto* script = blink::ClassicScript::Create(
|
||||
source, blink::KURL(source_url), blink::KURL(source_url),
|
||||
|
@ -86,8 +86,9 @@ bool CefBrowserImpl::IsLoading() {
|
||||
|
||||
if (GetWebView()) {
|
||||
blink::WebFrame* main_frame = GetWebView()->MainFrame();
|
||||
if (main_frame)
|
||||
if (main_frame) {
|
||||
return main_frame->ToWebLocalFrame()->IsLoading();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -194,8 +195,9 @@ CefRefPtr<CefFrame> CefBrowserImpl::GetFrame(const CefString& name) {
|
||||
blink::WebString::FromUTF16(name.ToString16());
|
||||
// Search by assigned frame name (Frame::name).
|
||||
blink::WebFrame* frame = web_view->MainFrame();
|
||||
if (frame && frame->IsWebLocalFrame())
|
||||
if (frame && frame->IsWebLocalFrame()) {
|
||||
frame = frame->ToWebLocalFrame()->FindFrameByName(frame_name);
|
||||
}
|
||||
if (!frame) {
|
||||
// Search by unique frame name (Frame::uniqueName).
|
||||
const std::string& searchname = name;
|
||||
@ -209,8 +211,9 @@ CefRefPtr<CefFrame> CefBrowserImpl::GetFrame(const CefString& name) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (frame && frame->IsWebLocalFrame())
|
||||
if (frame && frame->IsWebLocalFrame()) {
|
||||
return GetWebFrameImpl(frame->ToWebLocalFrame()).get();
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
@ -234,15 +237,17 @@ size_t CefBrowserImpl::GetFrameCount() {
|
||||
void CefBrowserImpl::GetFrameIdentifiers(std::vector<int64>& identifiers) {
|
||||
CEF_REQUIRE_RT_RETURN_VOID();
|
||||
|
||||
if (identifiers.size() > 0)
|
||||
if (identifiers.size() > 0) {
|
||||
identifiers.clear();
|
||||
}
|
||||
|
||||
if (GetWebView()) {
|
||||
for (blink::WebFrame* frame = GetWebView()->MainFrame(); frame;
|
||||
frame = frame->TraverseNext()) {
|
||||
if (frame->IsWebLocalFrame())
|
||||
if (frame->IsWebLocalFrame()) {
|
||||
identifiers.push_back(
|
||||
render_frame_util::GetIdentifier(frame->ToWebLocalFrame()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -250,14 +255,16 @@ void CefBrowserImpl::GetFrameIdentifiers(std::vector<int64>& identifiers) {
|
||||
void CefBrowserImpl::GetFrameNames(std::vector<CefString>& names) {
|
||||
CEF_REQUIRE_RT_RETURN_VOID();
|
||||
|
||||
if (names.size() > 0)
|
||||
if (names.size() > 0) {
|
||||
names.clear();
|
||||
}
|
||||
|
||||
if (GetWebView()) {
|
||||
for (blink::WebFrame* frame = GetWebView()->MainFrame(); frame;
|
||||
frame = frame->TraverseNext()) {
|
||||
if (frame->IsWebLocalFrame())
|
||||
if (frame->IsWebLocalFrame()) {
|
||||
names.push_back(render_frame_util::GetName(frame->ToWebLocalFrame()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -283,8 +290,9 @@ CefRefPtr<CefFrameImpl> CefBrowserImpl::GetWebFrameImpl(
|
||||
|
||||
// Frames are re-used between page loads. Only add the frame to the map once.
|
||||
FrameMap::const_iterator it = frames_.find(frame_id);
|
||||
if (it != frames_.end())
|
||||
if (it != frames_.end()) {
|
||||
return it->second;
|
||||
}
|
||||
|
||||
CefRefPtr<CefFrameImpl> framePtr(new CefFrameImpl(this, frame, frame_id));
|
||||
frames_.insert(std::make_pair(frame_id, framePtr));
|
||||
@ -305,8 +313,9 @@ CefRefPtr<CefFrameImpl> CefBrowserImpl::GetWebFrameImpl(int64_t frame_id) {
|
||||
|
||||
// Check if we already know about the frame.
|
||||
FrameMap::const_iterator it = frames_.find(frame_id);
|
||||
if (it != frames_.end())
|
||||
if (it != frames_.end()) {
|
||||
return it->second;
|
||||
}
|
||||
|
||||
if (GetWebView()) {
|
||||
// Check if the frame exists but we don't know about it yet.
|
||||
@ -329,8 +338,9 @@ void CefBrowserImpl::AddFrameObject(int64_t frame_id,
|
||||
|
||||
if (!frame_objects_.empty()) {
|
||||
FrameObjectMap::const_iterator it = frame_objects_.find(frame_id);
|
||||
if (it != frame_objects_.end())
|
||||
if (it != frame_objects_.end()) {
|
||||
manager = it->second;
|
||||
}
|
||||
}
|
||||
|
||||
if (!manager.get()) {
|
||||
@ -349,8 +359,9 @@ void CefBrowserImpl::OnDestruct() {
|
||||
CefRefPtr<CefApp> app = CefAppManager::Get()->GetApplication();
|
||||
if (app.get()) {
|
||||
CefRefPtr<CefRenderProcessHandler> handler = app->GetRenderProcessHandler();
|
||||
if (handler.get())
|
||||
if (handler.get()) {
|
||||
handler->OnBrowserDestroyed(this);
|
||||
}
|
||||
}
|
||||
|
||||
CefRenderManager::Get()->OnBrowserDestroyed(this);
|
||||
@ -368,8 +379,9 @@ void CefBrowserImpl::FrameDetached(int64_t frame_id) {
|
||||
if (!frame_objects_.empty()) {
|
||||
// Remove any tracked objects associated with the frame.
|
||||
FrameObjectMap::iterator it = frame_objects_.find(frame_id);
|
||||
if (it != frame_objects_.end())
|
||||
if (it != frame_objects_.end()) {
|
||||
frame_objects_.erase(it);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,8 +19,9 @@ ChromeContentRendererClientCef::~ChromeContentRendererClientCef() = default;
|
||||
scoped_refptr<base::SingleThreadTaskRunner>
|
||||
ChromeContentRendererClientCef::GetCurrentTaskRunner() {
|
||||
// Check if currently on the render thread.
|
||||
if (CEF_CURRENTLY_ON_RT())
|
||||
if (CEF_CURRENTLY_ON_RT()) {
|
||||
return render_task_runner_;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -38,16 +38,20 @@ CefDOMDocumentImpl::~CefDOMDocumentImpl() {
|
||||
}
|
||||
|
||||
CefDOMDocumentImpl::Type CefDOMDocumentImpl::GetType() {
|
||||
if (!VerifyContext())
|
||||
if (!VerifyContext()) {
|
||||
return DOM_DOCUMENT_TYPE_UNKNOWN;
|
||||
}
|
||||
|
||||
const WebDocument& document = frame_->GetDocument();
|
||||
if (document.IsHTMLDocument())
|
||||
if (document.IsHTMLDocument()) {
|
||||
return DOM_DOCUMENT_TYPE_HTML;
|
||||
if (document.IsXHTMLDocument())
|
||||
}
|
||||
if (document.IsXHTMLDocument()) {
|
||||
return DOM_DOCUMENT_TYPE_XHTML;
|
||||
if (document.IsPluginDocument())
|
||||
}
|
||||
if (document.IsPluginDocument()) {
|
||||
return DOM_DOCUMENT_TYPE_PLUGIN;
|
||||
}
|
||||
return DOM_DOCUMENT_TYPE_UNKNOWN;
|
||||
}
|
||||
|
||||
@ -68,13 +72,15 @@ CefRefPtr<CefDOMNode> CefDOMDocumentImpl::GetHead() {
|
||||
|
||||
CefString CefDOMDocumentImpl::GetTitle() {
|
||||
CefString str;
|
||||
if (!VerifyContext())
|
||||
if (!VerifyContext()) {
|
||||
return str;
|
||||
}
|
||||
|
||||
const WebDocument& document = frame_->GetDocument();
|
||||
const WebString& title = document.Title();
|
||||
if (!title.IsNull())
|
||||
if (!title.IsNull()) {
|
||||
str = title.Utf16();
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
@ -91,74 +97,88 @@ CefRefPtr<CefDOMNode> CefDOMDocumentImpl::GetFocusedNode() {
|
||||
}
|
||||
|
||||
bool CefDOMDocumentImpl::HasSelection() {
|
||||
if (!VerifyContext())
|
||||
if (!VerifyContext()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return frame_->HasSelection();
|
||||
}
|
||||
|
||||
int CefDOMDocumentImpl::GetSelectionStartOffset() {
|
||||
if (!VerifyContext())
|
||||
if (!VerifyContext()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!frame_->HasSelection())
|
||||
if (!frame_->HasSelection()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const WebRange& range = frame_->SelectionRange();
|
||||
if (range.IsNull())
|
||||
if (range.IsNull()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return range.StartOffset();
|
||||
}
|
||||
|
||||
int CefDOMDocumentImpl::GetSelectionEndOffset() {
|
||||
if (!VerifyContext())
|
||||
if (!VerifyContext()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!frame_->HasSelection())
|
||||
if (!frame_->HasSelection()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const WebRange& range = frame_->SelectionRange();
|
||||
if (range.IsNull())
|
||||
if (range.IsNull()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return range.EndOffset();
|
||||
}
|
||||
|
||||
CefString CefDOMDocumentImpl::GetSelectionAsMarkup() {
|
||||
CefString str;
|
||||
if (!VerifyContext())
|
||||
if (!VerifyContext()) {
|
||||
return str;
|
||||
}
|
||||
|
||||
if (!frame_->HasSelection())
|
||||
if (!frame_->HasSelection()) {
|
||||
return str;
|
||||
}
|
||||
|
||||
const WebString& markup = frame_->SelectionAsMarkup();
|
||||
if (!markup.IsNull())
|
||||
if (!markup.IsNull()) {
|
||||
str = markup.Utf16();
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
CefString CefDOMDocumentImpl::GetSelectionAsText() {
|
||||
CefString str;
|
||||
if (!VerifyContext())
|
||||
if (!VerifyContext()) {
|
||||
return str;
|
||||
}
|
||||
|
||||
if (!frame_->HasSelection())
|
||||
if (!frame_->HasSelection()) {
|
||||
return str;
|
||||
}
|
||||
|
||||
const WebString& text = frame_->SelectionAsText();
|
||||
if (!text.IsNull())
|
||||
if (!text.IsNull()) {
|
||||
str = text.Utf16();
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
CefString CefDOMDocumentImpl::GetBaseURL() {
|
||||
CefString str;
|
||||
if (!VerifyContext())
|
||||
if (!VerifyContext()) {
|
||||
return str;
|
||||
}
|
||||
|
||||
const WebDocument& document = frame_->GetDocument();
|
||||
const WebURL& url = document.BaseURL();
|
||||
@ -172,8 +192,9 @@ CefString CefDOMDocumentImpl::GetBaseURL() {
|
||||
|
||||
CefString CefDOMDocumentImpl::GetCompleteURL(const CefString& partialURL) {
|
||||
CefString str;
|
||||
if (!VerifyContext())
|
||||
if (!VerifyContext()) {
|
||||
return str;
|
||||
}
|
||||
|
||||
const WebDocument& document = frame_->GetDocument();
|
||||
const WebURL& url =
|
||||
@ -188,18 +209,21 @@ CefString CefDOMDocumentImpl::GetCompleteURL(const CefString& partialURL) {
|
||||
|
||||
CefRefPtr<CefDOMNode> CefDOMDocumentImpl::GetOrCreateNode(
|
||||
const blink::WebNode& node) {
|
||||
if (!VerifyContext())
|
||||
if (!VerifyContext()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Nodes may potentially be null.
|
||||
if (node.IsNull())
|
||||
if (node.IsNull()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!node_map_.empty()) {
|
||||
// Locate the existing node, if any.
|
||||
NodeMap::const_iterator it = node_map_.find(node);
|
||||
if (it != node_map_.end())
|
||||
if (it != node_map_.end()) {
|
||||
return it->second;
|
||||
}
|
||||
}
|
||||
|
||||
// Create the new node object.
|
||||
@ -209,19 +233,22 @@ CefRefPtr<CefDOMNode> CefDOMDocumentImpl::GetOrCreateNode(
|
||||
}
|
||||
|
||||
void CefDOMDocumentImpl::RemoveNode(const blink::WebNode& node) {
|
||||
if (!VerifyContext())
|
||||
if (!VerifyContext()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!node_map_.empty()) {
|
||||
NodeMap::iterator it = node_map_.find(node);
|
||||
if (it != node_map_.end())
|
||||
if (it != node_map_.end()) {
|
||||
node_map_.erase(it);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CefDOMDocumentImpl::Detach() {
|
||||
if (!VerifyContext())
|
||||
if (!VerifyContext()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If you hit this assert it means that you are keeping references to node
|
||||
// objects beyond the valid scope.
|
||||
@ -233,8 +260,9 @@ void CefDOMDocumentImpl::Detach() {
|
||||
|
||||
if (!node_map_.empty()) {
|
||||
NodeMap::const_iterator it = node_map_.begin();
|
||||
for (; it != node_map_.end(); ++it)
|
||||
for (; it != node_map_.end(); ++it) {
|
||||
static_cast<CefDOMNodeImpl*>(it->second)->Detach();
|
||||
}
|
||||
node_map_.clear();
|
||||
}
|
||||
|
||||
|
@ -45,38 +45,44 @@ CefDOMNodeImpl::~CefDOMNodeImpl() {
|
||||
}
|
||||
|
||||
CefDOMNodeImpl::Type CefDOMNodeImpl::GetType() {
|
||||
if (!VerifyContext())
|
||||
if (!VerifyContext()) {
|
||||
return DOM_NODE_TYPE_UNSUPPORTED;
|
||||
}
|
||||
|
||||
return blink_glue::GetNodeType(node_);
|
||||
}
|
||||
|
||||
bool CefDOMNodeImpl::IsText() {
|
||||
if (!VerifyContext())
|
||||
if (!VerifyContext()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return node_.IsTextNode();
|
||||
}
|
||||
|
||||
bool CefDOMNodeImpl::IsElement() {
|
||||
if (!VerifyContext())
|
||||
if (!VerifyContext()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return node_.IsElementNode();
|
||||
}
|
||||
|
||||
// Logic copied from RenderViewImpl::IsEditableNode.
|
||||
bool CefDOMNodeImpl::IsEditable() {
|
||||
if (!VerifyContext())
|
||||
if (!VerifyContext()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (node_.IsContentEditable())
|
||||
if (node_.IsContentEditable()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (node_.IsElementNode()) {
|
||||
const WebElement& element = node_.To<WebElement>();
|
||||
if (blink_glue::IsTextControlElement(element))
|
||||
if (blink_glue::IsTextControlElement(element)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Also return true if it has an ARIA role of 'textbox'.
|
||||
for (unsigned i = 0; i < element.AttributeCount(); ++i) {
|
||||
@ -95,8 +101,9 @@ bool CefDOMNodeImpl::IsEditable() {
|
||||
}
|
||||
|
||||
bool CefDOMNodeImpl::IsFormControlElement() {
|
||||
if (!VerifyContext())
|
||||
if (!VerifyContext()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (node_.IsElementNode()) {
|
||||
const WebElement& element = node_.To<WebElement>();
|
||||
@ -108,8 +115,9 @@ bool CefDOMNodeImpl::IsFormControlElement() {
|
||||
|
||||
CefString CefDOMNodeImpl::GetFormControlElementType() {
|
||||
CefString str;
|
||||
if (!VerifyContext())
|
||||
if (!VerifyContext()) {
|
||||
return str;
|
||||
}
|
||||
|
||||
if (node_.IsElementNode()) {
|
||||
const WebElement& element = node_.To<WebElement>();
|
||||
@ -128,32 +136,37 @@ CefString CefDOMNodeImpl::GetFormControlElementType() {
|
||||
}
|
||||
|
||||
bool CefDOMNodeImpl::IsSame(CefRefPtr<CefDOMNode> that) {
|
||||
if (!VerifyContext())
|
||||
if (!VerifyContext()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
CefDOMNodeImpl* impl = static_cast<CefDOMNodeImpl*>(that.get());
|
||||
if (!impl || !impl->VerifyContext())
|
||||
if (!impl || !impl->VerifyContext()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return node_.Equals(impl->node_);
|
||||
}
|
||||
|
||||
CefString CefDOMNodeImpl::GetName() {
|
||||
CefString str;
|
||||
if (!VerifyContext())
|
||||
if (!VerifyContext()) {
|
||||
return str;
|
||||
}
|
||||
|
||||
const WebString& name = blink_glue::GetNodeName(node_);
|
||||
if (!name.IsNull())
|
||||
if (!name.IsNull()) {
|
||||
str = name.Utf16();
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
CefString CefDOMNodeImpl::GetValue() {
|
||||
CefString str;
|
||||
if (!VerifyContext())
|
||||
if (!VerifyContext()) {
|
||||
return str;
|
||||
}
|
||||
|
||||
if (node_.IsElementNode()) {
|
||||
const WebElement& element = node_.To<WebElement>();
|
||||
@ -182,19 +195,22 @@ CefString CefDOMNodeImpl::GetValue() {
|
||||
|
||||
if (str.empty()) {
|
||||
const WebString& value = node_.NodeValue();
|
||||
if (!value.IsNull())
|
||||
if (!value.IsNull()) {
|
||||
str = value.Utf16();
|
||||
}
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
bool CefDOMNodeImpl::SetValue(const CefString& value) {
|
||||
if (!VerifyContext())
|
||||
if (!VerifyContext()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (node_.IsElementNode())
|
||||
if (node_.IsElementNode()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return blink_glue::SetNodeValue(node_,
|
||||
WebString::FromUTF16(value.ToString16()));
|
||||
@ -202,69 +218,79 @@ bool CefDOMNodeImpl::SetValue(const CefString& value) {
|
||||
|
||||
CefString CefDOMNodeImpl::GetAsMarkup() {
|
||||
CefString str;
|
||||
if (!VerifyContext())
|
||||
if (!VerifyContext()) {
|
||||
return str;
|
||||
}
|
||||
|
||||
const WebString& markup = blink_glue::CreateNodeMarkup(node_);
|
||||
if (!markup.IsNull())
|
||||
if (!markup.IsNull()) {
|
||||
str = markup.Utf16();
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
CefRefPtr<CefDOMDocument> CefDOMNodeImpl::GetDocument() {
|
||||
if (!VerifyContext())
|
||||
if (!VerifyContext()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return document_.get();
|
||||
}
|
||||
|
||||
CefRefPtr<CefDOMNode> CefDOMNodeImpl::GetParent() {
|
||||
if (!VerifyContext())
|
||||
if (!VerifyContext()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return document_->GetOrCreateNode(node_.ParentNode());
|
||||
}
|
||||
|
||||
CefRefPtr<CefDOMNode> CefDOMNodeImpl::GetPreviousSibling() {
|
||||
if (!VerifyContext())
|
||||
if (!VerifyContext()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return document_->GetOrCreateNode(node_.PreviousSibling());
|
||||
}
|
||||
|
||||
CefRefPtr<CefDOMNode> CefDOMNodeImpl::GetNextSibling() {
|
||||
if (!VerifyContext())
|
||||
if (!VerifyContext()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return document_->GetOrCreateNode(node_.NextSibling());
|
||||
}
|
||||
|
||||
bool CefDOMNodeImpl::HasChildren() {
|
||||
if (!VerifyContext())
|
||||
if (!VerifyContext()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !node_.FirstChild().IsNull();
|
||||
}
|
||||
|
||||
CefRefPtr<CefDOMNode> CefDOMNodeImpl::GetFirstChild() {
|
||||
if (!VerifyContext())
|
||||
if (!VerifyContext()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return document_->GetOrCreateNode(node_.FirstChild());
|
||||
}
|
||||
|
||||
CefRefPtr<CefDOMNode> CefDOMNodeImpl::GetLastChild() {
|
||||
if (!VerifyContext())
|
||||
if (!VerifyContext()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return document_->GetOrCreateNode(node_.LastChild());
|
||||
}
|
||||
|
||||
CefString CefDOMNodeImpl::GetElementTagName() {
|
||||
CefString str;
|
||||
if (!VerifyContext())
|
||||
if (!VerifyContext()) {
|
||||
return str;
|
||||
}
|
||||
|
||||
if (!node_.IsElementNode()) {
|
||||
NOTREACHED();
|
||||
@ -273,15 +299,17 @@ CefString CefDOMNodeImpl::GetElementTagName() {
|
||||
|
||||
const WebElement& element = node_.To<blink::WebElement>();
|
||||
const WebString& tagname = element.TagName();
|
||||
if (!tagname.IsNull())
|
||||
if (!tagname.IsNull()) {
|
||||
str = tagname.Utf16();
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
bool CefDOMNodeImpl::HasElementAttributes() {
|
||||
if (!VerifyContext())
|
||||
if (!VerifyContext()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!node_.IsElementNode()) {
|
||||
NOTREACHED();
|
||||
@ -293,8 +321,9 @@ bool CefDOMNodeImpl::HasElementAttributes() {
|
||||
}
|
||||
|
||||
bool CefDOMNodeImpl::HasElementAttribute(const CefString& attrName) {
|
||||
if (!VerifyContext())
|
||||
if (!VerifyContext()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!node_.IsElementNode()) {
|
||||
NOTREACHED();
|
||||
@ -307,8 +336,9 @@ bool CefDOMNodeImpl::HasElementAttribute(const CefString& attrName) {
|
||||
|
||||
CefString CefDOMNodeImpl::GetElementAttribute(const CefString& attrName) {
|
||||
CefString str;
|
||||
if (!VerifyContext())
|
||||
if (!VerifyContext()) {
|
||||
return str;
|
||||
}
|
||||
|
||||
if (!node_.IsElementNode()) {
|
||||
NOTREACHED();
|
||||
@ -318,15 +348,17 @@ CefString CefDOMNodeImpl::GetElementAttribute(const CefString& attrName) {
|
||||
const WebElement& element = node_.To<blink::WebElement>();
|
||||
const WebString& attr =
|
||||
element.GetAttribute(WebString::FromUTF16(attrName.ToString16()));
|
||||
if (!attr.IsNull())
|
||||
if (!attr.IsNull()) {
|
||||
str = attr.Utf16();
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
void CefDOMNodeImpl::GetElementAttributes(AttributeMap& attrMap) {
|
||||
if (!VerifyContext())
|
||||
if (!VerifyContext()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!node_.IsElementNode()) {
|
||||
NOTREACHED();
|
||||
@ -335,8 +367,9 @@ void CefDOMNodeImpl::GetElementAttributes(AttributeMap& attrMap) {
|
||||
|
||||
const WebElement& element = node_.To<blink::WebElement>();
|
||||
unsigned int len = element.AttributeCount();
|
||||
if (len == 0)
|
||||
if (len == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < len; ++i) {
|
||||
std::u16string name = element.AttributeLocalName(i).Utf16();
|
||||
@ -347,8 +380,9 @@ void CefDOMNodeImpl::GetElementAttributes(AttributeMap& attrMap) {
|
||||
|
||||
bool CefDOMNodeImpl::SetElementAttribute(const CefString& attrName,
|
||||
const CefString& value) {
|
||||
if (!VerifyContext())
|
||||
if (!VerifyContext()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!node_.IsElementNode()) {
|
||||
NOTREACHED();
|
||||
@ -363,8 +397,9 @@ bool CefDOMNodeImpl::SetElementAttribute(const CefString& attrName,
|
||||
|
||||
CefString CefDOMNodeImpl::GetElementInnerText() {
|
||||
CefString str;
|
||||
if (!VerifyContext())
|
||||
if (!VerifyContext()) {
|
||||
return str;
|
||||
}
|
||||
|
||||
if (!node_.IsElementNode()) {
|
||||
NOTREACHED();
|
||||
@ -373,16 +408,18 @@ CefString CefDOMNodeImpl::GetElementInnerText() {
|
||||
|
||||
WebElement element = node_.To<blink::WebElement>();
|
||||
const WebString& text = element.TextContent();
|
||||
if (!text.IsNull())
|
||||
if (!text.IsNull()) {
|
||||
str = text.Utf16();
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
CefRect CefDOMNodeImpl::GetElementBounds() {
|
||||
CefRect rect;
|
||||
if (!VerifyContext())
|
||||
if (!VerifyContext()) {
|
||||
return rect;
|
||||
}
|
||||
|
||||
if (!node_.IsElementNode()) {
|
||||
NOTREACHED();
|
||||
@ -406,8 +443,9 @@ bool CefDOMNodeImpl::VerifyContext() {
|
||||
NOTREACHED();
|
||||
return false;
|
||||
}
|
||||
if (!document_->VerifyContext())
|
||||
if (!document_->VerifyContext()) {
|
||||
return false;
|
||||
}
|
||||
if (node_.IsNull()) {
|
||||
NOTREACHED();
|
||||
return false;
|
||||
|
@ -100,8 +100,9 @@ void CefExtensionsRendererClient::RenderFrameCreated(
|
||||
bool CefExtensionsRendererClient::OverrideCreatePlugin(
|
||||
content::RenderFrame* render_frame,
|
||||
const blink::WebPluginParams& params) {
|
||||
if (params.mime_type.Utf8() != content::kBrowserPluginMimeType)
|
||||
if (params.mime_type.Utf8() != content::kBrowserPluginMimeType) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool guest_view_api_available = false;
|
||||
extension_dispatcher_->script_context_set_iterator()->ForEach(
|
||||
|
@ -131,8 +131,9 @@ void CefFrameImpl::GetText(CefRefPtr<CefStringVisitor> visitor) {
|
||||
void CefFrameImpl::LoadRequest(CefRefPtr<CefRequest> request) {
|
||||
CEF_REQUIRE_RT_RETURN_VOID();
|
||||
|
||||
if (!frame_)
|
||||
if (!frame_) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto params = cef::mojom::RequestParams::New();
|
||||
static_cast<CefRequestImpl*>(request.get())->Get(params);
|
||||
@ -142,8 +143,9 @@ void CefFrameImpl::LoadRequest(CefRefPtr<CefRequest> request) {
|
||||
void CefFrameImpl::LoadURL(const CefString& url) {
|
||||
CEF_REQUIRE_RT_RETURN_VOID();
|
||||
|
||||
if (!frame_)
|
||||
if (!frame_) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto params = cef::mojom::RequestParams::New();
|
||||
params->url = GURL(url.ToString());
|
||||
@ -160,16 +162,18 @@ void CefFrameImpl::ExecuteJavaScript(const CefString& jsCode,
|
||||
bool CefFrameImpl::IsMain() {
|
||||
CEF_REQUIRE_RT_RETURN(false);
|
||||
|
||||
if (frame_)
|
||||
if (frame_) {
|
||||
return (frame_->Parent() == nullptr);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CefFrameImpl::IsFocused() {
|
||||
CEF_REQUIRE_RT_RETURN(false);
|
||||
|
||||
if (frame_ && frame_->View())
|
||||
if (frame_ && frame_->View()) {
|
||||
return (frame_->View()->FocusedFrame() == frame_);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -177,8 +181,9 @@ CefString CefFrameImpl::GetName() {
|
||||
CefString name;
|
||||
CEF_REQUIRE_RT_RETURN(name);
|
||||
|
||||
if (frame_)
|
||||
if (frame_) {
|
||||
name = render_frame_util::GetName(frame_);
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
@ -193,8 +198,9 @@ CefRefPtr<CefFrame> CefFrameImpl::GetParent() {
|
||||
|
||||
if (frame_) {
|
||||
blink::WebFrame* parent = frame_->Parent();
|
||||
if (parent && parent->IsWebLocalFrame())
|
||||
if (parent && parent->IsWebLocalFrame()) {
|
||||
return browser_->GetWebFrameImpl(parent->ToWebLocalFrame()).get();
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
@ -232,20 +238,23 @@ CefRefPtr<CefV8Context> CefFrameImpl::GetV8Context() {
|
||||
void CefFrameImpl::VisitDOM(CefRefPtr<CefDOMVisitor> visitor) {
|
||||
CEF_REQUIRE_RT_RETURN_VOID();
|
||||
|
||||
if (!frame_)
|
||||
if (!frame_) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Create a CefDOMDocumentImpl object that is valid only for the scope of this
|
||||
// method.
|
||||
CefRefPtr<CefDOMDocumentImpl> documentImpl;
|
||||
const blink::WebDocument& document = frame_->GetDocument();
|
||||
if (!document.IsNull())
|
||||
if (!document.IsNull()) {
|
||||
documentImpl = new CefDOMDocumentImpl(browser_, frame_);
|
||||
}
|
||||
|
||||
visitor->Visit(documentImpl.get());
|
||||
|
||||
if (documentImpl.get())
|
||||
if (documentImpl.get()) {
|
||||
documentImpl->Detach();
|
||||
}
|
||||
}
|
||||
|
||||
CefRefPtr<CefURLRequest> CefFrameImpl::CreateURLRequest(
|
||||
@ -253,13 +262,15 @@ CefRefPtr<CefURLRequest> CefFrameImpl::CreateURLRequest(
|
||||
CefRefPtr<CefURLRequestClient> client) {
|
||||
CEF_REQUIRE_RT_RETURN(nullptr);
|
||||
|
||||
if (!request || !client || !frame_)
|
||||
if (!request || !client || !frame_) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CefRefPtr<CefRenderURLRequest> impl =
|
||||
new CefRenderURLRequest(this, request, client);
|
||||
if (impl->Start())
|
||||
if (impl->Start()) {
|
||||
return impl.get();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -268,8 +279,9 @@ void CefFrameImpl::SendProcessMessage(CefProcessId target_process,
|
||||
CEF_REQUIRE_RT_RETURN_VOID();
|
||||
DCHECK_EQ(PID_BROWSER, target_process);
|
||||
DCHECK(message && message->IsValid());
|
||||
if (!message || !message->IsValid())
|
||||
if (!message || !message->IsValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (message->GetArgumentList() != nullptr) {
|
||||
// Invalidate the message object immediately by taking the argument list.
|
||||
@ -299,8 +311,9 @@ void CefFrameImpl::SendProcessMessage(CefProcessId target_process,
|
||||
|
||||
std::unique_ptr<blink::WebURLLoader> CefFrameImpl::CreateURLLoader() {
|
||||
CEF_REQUIRE_RT();
|
||||
if (!frame_)
|
||||
if (!frame_) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!url_loader_factory_) {
|
||||
auto render_frame = content::RenderFrameImpl::FromWebFrame(frame_);
|
||||
@ -308,8 +321,9 @@ std::unique_ptr<blink::WebURLLoader> CefFrameImpl::CreateURLLoader() {
|
||||
url_loader_factory_ = render_frame->CreateURLLoaderFactory();
|
||||
}
|
||||
}
|
||||
if (!url_loader_factory_)
|
||||
if (!url_loader_factory_) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return url_loader_factory_->CreateURLLoader(
|
||||
blink::WebURLRequest(),
|
||||
@ -324,8 +338,9 @@ CefFrameImpl::CreateResourceLoadInfoNotifierWrapper() {
|
||||
CEF_REQUIRE_RT();
|
||||
if (frame_) {
|
||||
auto render_frame = content::RenderFrameImpl::FromWebFrame(frame_);
|
||||
if (render_frame)
|
||||
if (render_frame) {
|
||||
return render_frame->CreateResourceLoadInfoNotifierWrapper();
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
@ -350,8 +365,9 @@ void CefFrameImpl::OnDidCommitProvisionalLoad() {
|
||||
void CefFrameImpl::OnDidFinishLoad() {
|
||||
// Ignore notifications from the embedded frame hosting a mime-type plugin.
|
||||
// We'll eventually receive a notification from the owner frame.
|
||||
if (blink_glue::HasPluginFrameOwner(frame_))
|
||||
if (blink_glue::HasPluginFrameOwner(frame_)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!blink::RuntimeEnabledFeatures::BackForwardCacheEnabled() && IsMain()) {
|
||||
// Refresh draggable regions. Otherwise, we may not receive updated regions
|
||||
@ -380,8 +396,9 @@ void CefFrameImpl::OnDraggableRegionsChanged() {
|
||||
// Match the behavior in ChromeRenderFrameObserver::DraggableRegionsChanged.
|
||||
// Only the main frame is allowed to control draggable regions, to avoid other
|
||||
// frames manipulate the regions in the browser process.
|
||||
if (frame_->Parent() != nullptr)
|
||||
if (frame_->Parent() != nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
blink::WebVector<blink::WebDraggableRegion> webregions =
|
||||
frame_->GetDocument().DraggableRegions();
|
||||
@ -606,8 +623,9 @@ void CefFrameImpl::OnDisconnect(DisconnectReason reason) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (!frame_)
|
||||
if (!frame_) {
|
||||
state_str += ", FRAME_INVALID";
|
||||
}
|
||||
|
||||
VLOG(1) << GetDebugString() << " disconnected (reason=" << reason_str
|
||||
<< ", current_state=" << state_str << ")";
|
||||
|
@ -38,8 +38,9 @@ CefRenderFrameObserver::~CefRenderFrameObserver() = default;
|
||||
|
||||
void CefRenderFrameObserver::DidCommitProvisionalLoad(
|
||||
ui::PageTransition transition) {
|
||||
if (!frame_)
|
||||
if (!frame_) {
|
||||
return;
|
||||
}
|
||||
|
||||
frame_->OnDidCommitProvisionalLoad();
|
||||
|
||||
@ -79,21 +80,25 @@ void CefRenderFrameObserver::WillDetach() {
|
||||
|
||||
void CefRenderFrameObserver::FocusedElementChanged(
|
||||
const blink::WebElement& element) {
|
||||
if (!frame_)
|
||||
if (!frame_) {
|
||||
return;
|
||||
}
|
||||
|
||||
blink::WebLocalFrame* frame = render_frame()->GetWebFrame();
|
||||
CefRefPtr<CefBrowserImpl> browserPtr =
|
||||
CefBrowserImpl::GetBrowserForMainFrame(frame->Top());
|
||||
if (!browserPtr)
|
||||
if (!browserPtr) {
|
||||
return;
|
||||
}
|
||||
|
||||
CefRefPtr<CefRenderProcessHandler> handler;
|
||||
CefRefPtr<CefApp> application = CefAppManager::Get()->GetApplication();
|
||||
if (application)
|
||||
if (application) {
|
||||
handler = application->GetRenderProcessHandler();
|
||||
if (!handler)
|
||||
}
|
||||
if (!handler) {
|
||||
return;
|
||||
}
|
||||
|
||||
CefRefPtr<CefFrameImpl> framePtr = browserPtr->GetWebFrameImpl(frame);
|
||||
|
||||
@ -102,8 +107,9 @@ void CefRenderFrameObserver::FocusedElementChanged(
|
||||
return;
|
||||
}
|
||||
|
||||
if (element.GetDocument().IsNull())
|
||||
if (element.GetDocument().IsNull()) {
|
||||
return;
|
||||
}
|
||||
|
||||
CefRefPtr<CefDOMDocumentImpl> documentImpl =
|
||||
new CefDOMDocumentImpl(browserPtr.get(), frame);
|
||||
@ -121,19 +127,22 @@ void CefRenderFrameObserver::DraggableRegionsChanged() {
|
||||
void CefRenderFrameObserver::DidCreateScriptContext(
|
||||
v8::Handle<v8::Context> context,
|
||||
int world_id) {
|
||||
if (!frame_)
|
||||
if (!frame_) {
|
||||
return;
|
||||
}
|
||||
|
||||
blink::WebLocalFrame* frame = render_frame()->GetWebFrame();
|
||||
CefRefPtr<CefBrowserImpl> browserPtr =
|
||||
CefBrowserImpl::GetBrowserForMainFrame(frame->Top());
|
||||
if (!browserPtr)
|
||||
if (!browserPtr) {
|
||||
return;
|
||||
}
|
||||
|
||||
CefRefPtr<CefRenderProcessHandler> handler;
|
||||
CefRefPtr<CefApp> application = CefAppManager::Get()->GetApplication();
|
||||
if (application)
|
||||
if (application) {
|
||||
handler = application->GetRenderProcessHandler();
|
||||
}
|
||||
|
||||
CefRefPtr<CefFrameImpl> framePtr = browserPtr->GetWebFrameImpl(frame);
|
||||
|
||||
@ -159,13 +168,15 @@ void CefRenderFrameObserver::WillReleaseScriptContext(
|
||||
blink::WebLocalFrame* frame = render_frame()->GetWebFrame();
|
||||
CefRefPtr<CefBrowserImpl> browserPtr =
|
||||
CefBrowserImpl::GetBrowserForMainFrame(frame->Top());
|
||||
if (!browserPtr)
|
||||
if (!browserPtr) {
|
||||
return;
|
||||
}
|
||||
|
||||
CefRefPtr<CefRenderProcessHandler> handler;
|
||||
CefRefPtr<CefApp> application = CefAppManager::Get()->GetApplication();
|
||||
if (application)
|
||||
if (application) {
|
||||
handler = application->GetRenderProcessHandler();
|
||||
}
|
||||
|
||||
CefRefPtr<CefFrameImpl> framePtr = browserPtr->GetWebFrameImpl(frame);
|
||||
|
||||
|
@ -36,8 +36,9 @@ std::string GetName(blink::WebLocalFrame* frame) {
|
||||
content::RenderFrameImpl* render_frame =
|
||||
content::RenderFrameImpl::FromWebFrame(frame);
|
||||
DCHECK(render_frame);
|
||||
if (render_frame)
|
||||
if (render_frame) {
|
||||
return render_frame->unique_name();
|
||||
}
|
||||
return std::string();
|
||||
}
|
||||
|
||||
|
@ -155,8 +155,9 @@ void CefRenderManager::ExposeInterfacesToBrowser(mojo::BinderMap* binders) {
|
||||
CefRefPtr<CefBrowserImpl> CefRenderManager::GetBrowserForView(
|
||||
blink::WebView* view) {
|
||||
BrowserMap::const_iterator it = browsers_.find(view);
|
||||
if (it != browsers_.end())
|
||||
if (it != browsers_.end()) {
|
||||
return it->second;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -239,10 +240,12 @@ void CefRenderManager::WebKitInitialized() {
|
||||
const CefSchemeInfo& info = *it;
|
||||
const blink::WebString& scheme =
|
||||
blink::WebString::FromUTF8(info.scheme_name);
|
||||
if (info.is_display_isolated)
|
||||
if (info.is_display_isolated) {
|
||||
blink::WebSecurityPolicy::RegisterURLSchemeAsDisplayIsolated(scheme);
|
||||
if (info.is_fetch_enabled)
|
||||
}
|
||||
if (info.is_fetch_enabled) {
|
||||
blink_glue::RegisterURLSchemeAsSupportingFetchAPI(scheme);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -272,8 +275,9 @@ void CefRenderManager::WebKitInitialized() {
|
||||
if (application.get()) {
|
||||
CefRefPtr<CefRenderProcessHandler> handler =
|
||||
application->GetRenderProcessHandler();
|
||||
if (handler.get())
|
||||
if (handler.get()) {
|
||||
handler->OnWebKitInitialized();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -282,11 +286,13 @@ CefRefPtr<CefBrowserImpl> CefRenderManager::MaybeCreateBrowser(
|
||||
content::RenderFrame* render_frame,
|
||||
bool* browser_created,
|
||||
absl::optional<bool>* is_windowless) {
|
||||
if (browser_created)
|
||||
if (browser_created) {
|
||||
*browser_created = false;
|
||||
}
|
||||
|
||||
if (!web_view || !render_frame)
|
||||
if (!web_view || !render_frame) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Don't create another browser or guest view object if one already exists for
|
||||
// the view.
|
||||
@ -350,13 +356,15 @@ CefRefPtr<CefBrowserImpl> CefRenderManager::MaybeCreateBrowser(
|
||||
/*will_delete=*/false, /*read_only=*/true);
|
||||
}
|
||||
handler->OnBrowserCreated(browser.get(), dictValuePtr.get());
|
||||
if (dictValuePtr)
|
||||
if (dictValuePtr) {
|
||||
std::ignore = dictValuePtr->Detach(nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (browser_created)
|
||||
if (browser_created) {
|
||||
*browser_created = true;
|
||||
}
|
||||
|
||||
return browser;
|
||||
}
|
||||
@ -378,8 +386,9 @@ CefGuestView* CefRenderManager::GetGuestViewForView(blink::WebView* view) {
|
||||
CEF_REQUIRE_RT_RETURN(nullptr);
|
||||
|
||||
GuestViewMap::const_iterator it = guest_views_.find(view);
|
||||
if (it != guest_views_.end())
|
||||
if (it != guest_views_.end()) {
|
||||
return it->second.get();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -106,8 +106,9 @@ class CefRenderURLRequest::Context
|
||||
|
||||
bool Start() {
|
||||
GURL url = GURL(request_->GetURL().ToString());
|
||||
if (!url.is_valid())
|
||||
if (!url.is_valid()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
url_client_.reset(new CefWebURLLoaderClient(this, request_->GetFlags()));
|
||||
|
||||
@ -157,8 +158,9 @@ class CefRenderURLRequest::Context
|
||||
|
||||
void Cancel() {
|
||||
// The request may already be complete.
|
||||
if (!loader_.get() || status_ != UR_IO_PENDING)
|
||||
if (!loader_.get() || status_ != UR_IO_PENDING) {
|
||||
return;
|
||||
}
|
||||
|
||||
status_ = UR_CANCELED;
|
||||
error_code_ = ERR_ABORTED;
|
||||
@ -217,8 +219,9 @@ class CefRenderURLRequest::Context
|
||||
NotifyUploadProgressIfNecessary();
|
||||
}
|
||||
|
||||
if (loader_.get())
|
||||
if (loader_.get()) {
|
||||
loader_.reset(nullptr);
|
||||
}
|
||||
|
||||
DCHECK(url_request_.get());
|
||||
client_->OnRequestComplete(url_request_.get());
|
||||
@ -298,8 +301,9 @@ class CefRenderURLRequest::Context
|
||||
|
||||
void OnUploadProgress(int64_t current, int64_t total) {
|
||||
DCHECK(url_request_.get());
|
||||
if (current == total)
|
||||
if (current == total) {
|
||||
got_upload_progress_complete_ = true;
|
||||
}
|
||||
client_->OnUploadProgress(url_request_.get(), current, total);
|
||||
}
|
||||
|
||||
@ -357,8 +361,9 @@ CefWebURLLoaderClient::~CefWebURLLoaderClient() {}
|
||||
|
||||
void CefWebURLLoaderClient::DidSendData(uint64_t bytes_sent,
|
||||
uint64_t total_bytes_to_be_sent) {
|
||||
if (request_flags_ & UR_FLAG_REPORT_UPLOAD_PROGRESS)
|
||||
if (request_flags_ & UR_FLAG_REPORT_UPLOAD_PROGRESS) {
|
||||
context_->OnUploadProgress(bytes_sent, total_bytes_to_be_sent);
|
||||
}
|
||||
}
|
||||
|
||||
void CefWebURLLoaderClient::DidReceiveResponse(const WebURLResponse& response) {
|
||||
@ -368,8 +373,9 @@ void CefWebURLLoaderClient::DidReceiveResponse(const WebURLResponse& response) {
|
||||
void CefWebURLLoaderClient::DidReceiveData(const char* data, int dataLength) {
|
||||
context_->OnDownloadProgress(dataLength);
|
||||
|
||||
if (!(request_flags_ & UR_FLAG_NO_DOWNLOAD_DATA))
|
||||
if (!(request_flags_ & UR_FLAG_NO_DOWNLOAD_DATA)) {
|
||||
context_->OnDownloadData(data, dataLength);
|
||||
}
|
||||
}
|
||||
|
||||
void CefWebURLLoaderClient::DidFinishLoading(
|
||||
@ -429,50 +435,58 @@ CefRenderURLRequest::CefRenderURLRequest(
|
||||
CefRenderURLRequest::~CefRenderURLRequest() {}
|
||||
|
||||
bool CefRenderURLRequest::Start() {
|
||||
if (!VerifyContext())
|
||||
if (!VerifyContext()) {
|
||||
return false;
|
||||
}
|
||||
return context_->Start();
|
||||
}
|
||||
|
||||
CefRefPtr<CefRequest> CefRenderURLRequest::GetRequest() {
|
||||
if (!VerifyContext())
|
||||
if (!VerifyContext()) {
|
||||
return nullptr;
|
||||
}
|
||||
return context_->request();
|
||||
}
|
||||
|
||||
CefRefPtr<CefURLRequestClient> CefRenderURLRequest::GetClient() {
|
||||
if (!VerifyContext())
|
||||
if (!VerifyContext()) {
|
||||
return nullptr;
|
||||
}
|
||||
return context_->client();
|
||||
}
|
||||
|
||||
CefURLRequest::Status CefRenderURLRequest::GetRequestStatus() {
|
||||
if (!VerifyContext())
|
||||
if (!VerifyContext()) {
|
||||
return UR_UNKNOWN;
|
||||
}
|
||||
return context_->status();
|
||||
}
|
||||
|
||||
CefURLRequest::ErrorCode CefRenderURLRequest::GetRequestError() {
|
||||
if (!VerifyContext())
|
||||
if (!VerifyContext()) {
|
||||
return ERR_NONE;
|
||||
}
|
||||
return context_->error_code();
|
||||
}
|
||||
|
||||
CefRefPtr<CefResponse> CefRenderURLRequest::GetResponse() {
|
||||
if (!VerifyContext())
|
||||
if (!VerifyContext()) {
|
||||
return nullptr;
|
||||
}
|
||||
return context_->response();
|
||||
}
|
||||
|
||||
bool CefRenderURLRequest::ResponseWasCached() {
|
||||
if (!VerifyContext())
|
||||
if (!VerifyContext()) {
|
||||
return false;
|
||||
}
|
||||
return context_->response_was_cached();
|
||||
}
|
||||
|
||||
void CefRenderURLRequest::Cancel() {
|
||||
if (!VerifyContext())
|
||||
if (!VerifyContext()) {
|
||||
return;
|
||||
}
|
||||
return context_->Cancel();
|
||||
}
|
||||
|
||||
|
@ -105,16 +105,18 @@ class CefV8IsolateManager {
|
||||
DCHECK(context.IsEmpty() || isolate_ == context->GetIsolate());
|
||||
|
||||
if (context.IsEmpty()) {
|
||||
if (isolate_->InContext())
|
||||
if (isolate_->InContext()) {
|
||||
context = isolate_->GetCurrentContext();
|
||||
else
|
||||
} else {
|
||||
return scoped_refptr<CefV8ContextState>();
|
||||
}
|
||||
}
|
||||
|
||||
int hash = context->Global()->GetIdentityHash();
|
||||
ContextMap::const_iterator it = context_map_.find(hash);
|
||||
if (it != context_map_.end())
|
||||
if (it != context_map_.end()) {
|
||||
return it->second;
|
||||
}
|
||||
|
||||
scoped_refptr<CefV8ContextState> state = new CefV8ContextState();
|
||||
context_map_.insert(std::make_pair(hash, state));
|
||||
@ -145,8 +147,9 @@ class CefV8IsolateManager {
|
||||
}
|
||||
|
||||
void SetUncaughtExceptionStackSize(int stack_size) {
|
||||
if (stack_size <= 0)
|
||||
if (stack_size <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!message_listener_registered_) {
|
||||
isolate_->AddMessageListener(&MessageListenerCallbackImpl);
|
||||
@ -250,8 +253,9 @@ class V8TrackObject : public CefTrackNode {
|
||||
new_value = 0;
|
||||
}
|
||||
|
||||
if (change_in_bytes != 0)
|
||||
if (change_in_bytes != 0) {
|
||||
isolate_->AdjustAmountOfExternalAllocatedMemory(change_in_bytes);
|
||||
}
|
||||
external_memory_ = new_value;
|
||||
|
||||
return new_value;
|
||||
@ -291,8 +295,9 @@ class V8TrackObject : public CefTrackNode {
|
||||
static V8TrackObject* Unwrap(v8::Local<v8::Context> context,
|
||||
v8::Local<v8::Object> object) {
|
||||
v8::Local<v8::Value> value;
|
||||
if (GetPrivate(context, object, kCefTrackObject, &value))
|
||||
if (GetPrivate(context, object, kCefTrackObject, &value)) {
|
||||
return static_cast<V8TrackObject*>(v8::External::Cast(*value)->Value());
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
@ -346,9 +351,10 @@ class V8TrackArrayBuffer : public CefTrackNode {
|
||||
static V8TrackArrayBuffer* Unwrap(v8::Local<v8::Context> context,
|
||||
v8::Local<v8::Object> object) {
|
||||
v8::Local<v8::Value> value;
|
||||
if (GetPrivate(context, object, kCefTrackObject, &value))
|
||||
if (GetPrivate(context, object, kCefTrackObject, &value)) {
|
||||
return static_cast<V8TrackArrayBuffer*>(
|
||||
v8::External::Cast(*value)->Value());
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
@ -378,8 +384,9 @@ class V8FunctionData {
|
||||
CefString function_name() const { return function_name_; }
|
||||
|
||||
CefV8Handler* handler() const {
|
||||
if (!handler_)
|
||||
if (!handler_) {
|
||||
return nullptr;
|
||||
}
|
||||
return handler_.get();
|
||||
}
|
||||
|
||||
@ -468,14 +475,16 @@ void v8impl_string_dtor(char* str) {
|
||||
void GetCefString(v8::Isolate* isolate,
|
||||
v8::Local<v8::String> str,
|
||||
CefString& out) {
|
||||
if (str.IsEmpty())
|
||||
if (str.IsEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined(CEF_STRING_TYPE_WIDE)
|
||||
// Allocate enough space for a worst-case conversion.
|
||||
int len = str->Utf8Length();
|
||||
if (len == 0)
|
||||
if (len == 0) {
|
||||
return;
|
||||
}
|
||||
char* buf = new char[len + 1];
|
||||
str->WriteUtf8(isolate, buf, len + 1);
|
||||
|
||||
@ -487,15 +496,17 @@ void GetCefString(v8::Isolate* isolate,
|
||||
#else // !defined(CEF_STRING_TYPE_WIDE)
|
||||
#if defined(CEF_STRING_TYPE_UTF16)
|
||||
int len = str->Length();
|
||||
if (len == 0)
|
||||
if (len == 0) {
|
||||
return;
|
||||
}
|
||||
char16* buf = new char16[len + 1];
|
||||
str->Write(isolate, reinterpret_cast<uint16_t*>(buf), 0, len + 1);
|
||||
#else
|
||||
// Allocate enough space for a worst-case conversion.
|
||||
int len = str->Utf8Length();
|
||||
if (len == 0)
|
||||
if (len == 0) {
|
||||
return;
|
||||
}
|
||||
char* buf = new char[len + 1];
|
||||
str->WriteUtf8(isolate, buf, len + 1);
|
||||
#endif
|
||||
@ -521,8 +532,9 @@ void FunctionCallbackImpl(const v8::FunctionCallbackInfo<v8::Value>& info) {
|
||||
return;
|
||||
}
|
||||
CefV8ValueList params;
|
||||
for (int i = 0; i < info.Length(); i++)
|
||||
for (int i = 0; i < info.Length(); i++) {
|
||||
params.push_back(new CefV8ValueImpl(isolate, context, info[i]));
|
||||
}
|
||||
|
||||
CefRefPtr<CefV8Value> object =
|
||||
new CefV8ValueImpl(isolate, context, info.This());
|
||||
@ -559,8 +571,9 @@ void AccessorNameGetterCallbackImpl(
|
||||
CefRefPtr<CefV8Accessor> accessorPtr;
|
||||
|
||||
V8TrackObject* tracker = V8TrackObject::Unwrap(context, obj);
|
||||
if (tracker)
|
||||
if (tracker) {
|
||||
accessorPtr = tracker->GetAccessor();
|
||||
}
|
||||
|
||||
if (accessorPtr.get()) {
|
||||
CefRefPtr<CefV8Value> retval;
|
||||
@ -597,8 +610,9 @@ void AccessorNameSetterCallbackImpl(
|
||||
CefRefPtr<CefV8Accessor> accessorPtr;
|
||||
|
||||
V8TrackObject* tracker = V8TrackObject::Unwrap(context, obj);
|
||||
if (tracker)
|
||||
if (tracker) {
|
||||
accessorPtr = tracker->GetAccessor();
|
||||
}
|
||||
|
||||
if (accessorPtr.get()) {
|
||||
CefRefPtr<CefV8Value> object = new CefV8ValueImpl(isolate, context, obj);
|
||||
@ -640,10 +654,12 @@ void InterceptorGetterCallbackImpl(
|
||||
CefRefPtr<CefV8Interceptor> interceptorPtr;
|
||||
|
||||
V8TrackObject* tracker = V8TrackObject::Unwrap(context, obj);
|
||||
if (tracker)
|
||||
if (tracker) {
|
||||
interceptorPtr = tracker->GetInterceptor();
|
||||
if (!interceptorPtr.get())
|
||||
}
|
||||
if (!interceptorPtr.get()) {
|
||||
return;
|
||||
}
|
||||
|
||||
CefRefPtr<CefV8Value> object = new CefV8ValueImpl(isolate, context, obj);
|
||||
CefRefPtr<CefV8Value> retval;
|
||||
@ -672,11 +688,13 @@ void InterceptorSetterCallbackImpl(
|
||||
CefRefPtr<CefV8Interceptor> interceptorPtr;
|
||||
|
||||
V8TrackObject* tracker = V8TrackObject::Unwrap(context, obj);
|
||||
if (tracker)
|
||||
if (tracker) {
|
||||
interceptorPtr = tracker->GetInterceptor();
|
||||
}
|
||||
|
||||
if (!interceptorPtr.get())
|
||||
if (!interceptorPtr.get()) {
|
||||
return;
|
||||
}
|
||||
CefRefPtr<CefV8Value> object = new CefV8ValueImpl(isolate, context, obj);
|
||||
CefRefPtr<CefV8Value> cefValue = new CefV8ValueImpl(isolate, context, value);
|
||||
CefString exception;
|
||||
@ -700,8 +718,9 @@ class ExtensionWrapper : public v8::Extension {
|
||||
v8::Handle<v8::FunctionTemplate> GetNativeFunctionTemplate(
|
||||
v8::Isolate* isolate,
|
||||
v8::Handle<v8::String> name) override {
|
||||
if (!handler_)
|
||||
if (!handler_) {
|
||||
return v8::Local<v8::FunctionTemplate>();
|
||||
}
|
||||
|
||||
CefString func_name;
|
||||
GetCefString(isolate, name, func_name);
|
||||
@ -726,14 +745,16 @@ class CefV8ExceptionImpl : public CefV8Exception {
|
||||
end_position_(0),
|
||||
start_column_(0),
|
||||
end_column_(0) {
|
||||
if (message.IsEmpty())
|
||||
if (message.IsEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
v8::Isolate* isolate = context->GetIsolate();
|
||||
GetCefString(isolate, message->Get(), message_);
|
||||
v8::MaybeLocal<v8::String> source_line = message->GetSourceLine(context);
|
||||
if (!source_line.IsEmpty())
|
||||
if (!source_line.IsEmpty()) {
|
||||
GetCefString(isolate, source_line.ToLocalChecked(), source_line_);
|
||||
}
|
||||
|
||||
if (!message->GetScriptResourceName().IsEmpty()) {
|
||||
GetCefString(
|
||||
@ -743,8 +764,9 @@ class CefV8ExceptionImpl : public CefV8Exception {
|
||||
}
|
||||
|
||||
v8::Maybe<int> line_number = message->GetLineNumber(context);
|
||||
if (!line_number.IsNothing())
|
||||
if (!line_number.IsNothing()) {
|
||||
line_number_ = line_number.ToChecked();
|
||||
}
|
||||
start_position_ = message->GetStartPosition();
|
||||
end_position_ = message->GetEndPosition();
|
||||
start_column_ = message->GetStartColumn(context).FromJust();
|
||||
@ -776,13 +798,15 @@ class CefV8ExceptionImpl : public CefV8Exception {
|
||||
void MessageListenerCallbackImpl(v8::Handle<v8::Message> message,
|
||||
v8::Handle<v8::Value> data) {
|
||||
CefRefPtr<CefApp> application = CefAppManager::Get()->GetApplication();
|
||||
if (!application.get())
|
||||
if (!application.get()) {
|
||||
return;
|
||||
}
|
||||
|
||||
CefRefPtr<CefRenderProcessHandler> handler =
|
||||
application->GetRenderProcessHandler();
|
||||
if (!handler.get())
|
||||
if (!handler.get()) {
|
||||
return;
|
||||
}
|
||||
|
||||
v8::Isolate* isolate = GetIsolateManager()->isolate();
|
||||
CefRefPtr<CefV8Context> context = CefV8Context::GetCurrentContext();
|
||||
@ -968,8 +992,9 @@ CefRefPtr<CefBrowser> CefV8ContextImpl::GetBrowser() {
|
||||
CEF_V8_REQUIRE_VALID_HANDLE_RETURN(browser);
|
||||
|
||||
blink::WebLocalFrame* webframe = GetWebFrame();
|
||||
if (webframe)
|
||||
if (webframe) {
|
||||
browser = CefBrowserImpl::GetBrowserForMainFrame(webframe->Top());
|
||||
}
|
||||
|
||||
return browser;
|
||||
}
|
||||
@ -993,8 +1018,9 @@ CefRefPtr<CefFrame> CefV8ContextImpl::GetFrame() {
|
||||
CefRefPtr<CefV8Value> CefV8ContextImpl::GetGlobal() {
|
||||
CEF_V8_REQUIRE_VALID_HANDLE_RETURN(nullptr);
|
||||
|
||||
if (blink_glue::IsScriptForbidden())
|
||||
if (blink_glue::IsScriptForbidden()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
v8::Isolate* isolate = handle_->isolate();
|
||||
v8::HandleScope handle_scope(isolate);
|
||||
@ -1006,8 +1032,9 @@ CefRefPtr<CefV8Value> CefV8ContextImpl::GetGlobal() {
|
||||
bool CefV8ContextImpl::Enter() {
|
||||
CEF_V8_REQUIRE_VALID_HANDLE_RETURN(false);
|
||||
|
||||
if (blink_glue::IsScriptForbidden())
|
||||
if (blink_glue::IsScriptForbidden()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
v8::Isolate* isolate = handle_->isolate();
|
||||
v8::HandleScope handle_scope(isolate);
|
||||
@ -1027,8 +1054,9 @@ bool CefV8ContextImpl::Enter() {
|
||||
bool CefV8ContextImpl::Exit() {
|
||||
CEF_V8_REQUIRE_VALID_HANDLE_RETURN(false);
|
||||
|
||||
if (blink_glue::IsScriptForbidden())
|
||||
if (blink_glue::IsScriptForbidden()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (enter_count_ <= 0) {
|
||||
LOG(ERROR) << "Call to CefV8Context::Exit() without matching call to "
|
||||
@ -1052,8 +1080,9 @@ bool CefV8ContextImpl::IsSame(CefRefPtr<CefV8Context> that) {
|
||||
CEF_V8_REQUIRE_VALID_HANDLE_RETURN(false);
|
||||
|
||||
CefV8ContextImpl* impl = static_cast<CefV8ContextImpl*>(that.get());
|
||||
if (!impl || !impl->IsValid())
|
||||
if (!impl || !impl->IsValid()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (handle_->GetPersistentV8Handle() ==
|
||||
impl->handle_->GetPersistentV8Handle());
|
||||
@ -1069,8 +1098,9 @@ bool CefV8ContextImpl::Eval(const CefString& code,
|
||||
|
||||
CEF_V8_REQUIRE_VALID_HANDLE_RETURN(false);
|
||||
|
||||
if (blink_glue::IsScriptForbidden())
|
||||
if (blink_glue::IsScriptForbidden()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (code.empty()) {
|
||||
NOTREACHED() << "invalid input parameter";
|
||||
@ -1112,8 +1142,9 @@ v8::Local<v8::Context> CefV8ContextImpl::GetV8Context() {
|
||||
blink::WebLocalFrame* CefV8ContextImpl::GetWebFrame() {
|
||||
CEF_REQUIRE_RT();
|
||||
|
||||
if (blink_glue::IsScriptForbidden())
|
||||
if (blink_glue::IsScriptForbidden()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
v8::HandleScope handle_scope(handle_->isolate());
|
||||
v8::Local<v8::Context> context = GetV8Context();
|
||||
@ -1141,8 +1172,9 @@ CefV8ValueImpl::Handle::~Handle() {
|
||||
if (context_state_.get()) {
|
||||
// If the associated context is still valid then delete |tracker_|.
|
||||
// Otherwise, |tracker_| will already have been deleted.
|
||||
if (context_state_->IsValid())
|
||||
if (context_state_->IsValid()) {
|
||||
context_state_->DeleteTrackObject(tracker_);
|
||||
}
|
||||
} else {
|
||||
GetIsolateManager()->DeleteGlobalTrackObject(tracker_);
|
||||
}
|
||||
@ -1163,8 +1195,9 @@ CefV8ValueImpl::Handle::~Handle() {
|
||||
CefV8ValueImpl::Handle::handleType CefV8ValueImpl::Handle::GetNewV8Handle(
|
||||
bool should_persist) {
|
||||
DCHECK(IsValid());
|
||||
if (should_persist && !should_persist_)
|
||||
if (should_persist && !should_persist_) {
|
||||
should_persist_ = true;
|
||||
}
|
||||
return handleType::New(isolate(), handle_);
|
||||
}
|
||||
|
||||
@ -1403,8 +1436,9 @@ CefRefPtr<CefV8Value> CefV8Value::CreateArrayBuffer(
|
||||
V8TrackArrayBuffer* tracker =
|
||||
new V8TrackArrayBuffer(isolate, release_callback);
|
||||
|
||||
if (release_callback)
|
||||
if (release_callback) {
|
||||
release_callback->AddRef();
|
||||
}
|
||||
|
||||
auto deleter = [](void* data, size_t length, void* deleter_data) {
|
||||
auto* release_callback =
|
||||
@ -1523,10 +1557,12 @@ CefV8ValueImpl::CefV8ValueImpl(v8::Isolate* isolate,
|
||||
}
|
||||
|
||||
CefV8ValueImpl::~CefV8ValueImpl() {
|
||||
if (type_ == TYPE_STRING)
|
||||
if (type_ == TYPE_STRING) {
|
||||
cef_string_clear(&string_value_);
|
||||
if (handle_.get())
|
||||
}
|
||||
if (handle_.get()) {
|
||||
handle_->SetWeakIfNecessary();
|
||||
}
|
||||
}
|
||||
|
||||
void CefV8ValueImpl::InitFromV8Value(v8::Local<v8::Context> context,
|
||||
@ -1754,8 +1790,9 @@ bool CefV8ValueImpl::IsSame(CefRefPtr<CefV8Value> that) {
|
||||
CEF_V8_REQUIRE_MLT_RETURN(false);
|
||||
|
||||
CefV8ValueImpl* thatValue = static_cast<CefV8ValueImpl*>(that.get());
|
||||
if (!thatValue || !thatValue->IsValid() || type_ != thatValue->type_)
|
||||
if (!thatValue || !thatValue->IsValid() || type_ != thatValue->type_) {
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (type_) {
|
||||
case TYPE_UNDEFINED:
|
||||
@ -1787,48 +1824,54 @@ bool CefV8ValueImpl::IsSame(CefRefPtr<CefV8Value> that) {
|
||||
|
||||
bool CefV8ValueImpl::GetBoolValue() {
|
||||
CEF_V8_REQUIRE_ISOLATE_RETURN(false);
|
||||
if (type_ == TYPE_BOOL)
|
||||
if (type_ == TYPE_BOOL) {
|
||||
return bool_value_;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int32 CefV8ValueImpl::GetIntValue() {
|
||||
CEF_V8_REQUIRE_ISOLATE_RETURN(0);
|
||||
if (type_ == TYPE_INT || type_ == TYPE_UINT)
|
||||
if (type_ == TYPE_INT || type_ == TYPE_UINT) {
|
||||
return int_value_;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32 CefV8ValueImpl::GetUIntValue() {
|
||||
CEF_V8_REQUIRE_ISOLATE_RETURN(0);
|
||||
if (type_ == TYPE_INT || type_ == TYPE_UINT)
|
||||
if (type_ == TYPE_INT || type_ == TYPE_UINT) {
|
||||
return uint_value_;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
double CefV8ValueImpl::GetDoubleValue() {
|
||||
CEF_V8_REQUIRE_ISOLATE_RETURN(0.);
|
||||
if (type_ == TYPE_DOUBLE)
|
||||
if (type_ == TYPE_DOUBLE) {
|
||||
return double_value_;
|
||||
else if (type_ == TYPE_INT)
|
||||
} else if (type_ == TYPE_INT) {
|
||||
return int_value_;
|
||||
else if (type_ == TYPE_UINT)
|
||||
} else if (type_ == TYPE_UINT) {
|
||||
return uint_value_;
|
||||
}
|
||||
return 0.;
|
||||
}
|
||||
|
||||
CefBaseTime CefV8ValueImpl::GetDateValue() {
|
||||
CEF_V8_REQUIRE_ISOLATE_RETURN(CefBaseTime());
|
||||
if (type_ == TYPE_DATE)
|
||||
if (type_ == TYPE_DATE) {
|
||||
return date_value_;
|
||||
}
|
||||
return CefBaseTime();
|
||||
}
|
||||
|
||||
CefString CefV8ValueImpl::GetStringValue() {
|
||||
CefString rv;
|
||||
CEF_V8_REQUIRE_ISOLATE_RETURN(rv);
|
||||
if (type_ == TYPE_STRING)
|
||||
if (type_ == TYPE_STRING) {
|
||||
rv = CefString(&string_value_);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -2117,12 +2160,14 @@ bool CefV8ValueImpl::SetValue(const CefString& key,
|
||||
CefRefPtr<CefV8Accessor> accessorPtr;
|
||||
|
||||
V8TrackObject* tracker = V8TrackObject::Unwrap(context, obj);
|
||||
if (tracker)
|
||||
if (tracker) {
|
||||
accessorPtr = tracker->GetAccessor();
|
||||
}
|
||||
|
||||
// Verify that an accessor exists for this object.
|
||||
if (!accessorPtr.get())
|
||||
if (!accessorPtr.get()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
v8::AccessorNameGetterCallback getter = AccessorNameGetterCallbackImpl;
|
||||
v8::AccessorNameSetterCallback setter =
|
||||
@ -2207,8 +2252,9 @@ CefRefPtr<CefBaseRefCounted> CefV8ValueImpl::GetUserData() {
|
||||
v8::Local<v8::Object> obj = value->ToObject(context).ToLocalChecked();
|
||||
|
||||
V8TrackObject* tracker = V8TrackObject::Unwrap(context, obj);
|
||||
if (tracker)
|
||||
if (tracker) {
|
||||
return tracker->GetUserData();
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
@ -2229,8 +2275,9 @@ int CefV8ValueImpl::GetExternallyAllocatedMemory() {
|
||||
v8::Local<v8::Object> obj = value->ToObject(context).ToLocalChecked();
|
||||
|
||||
V8TrackObject* tracker = V8TrackObject::Unwrap(context, obj);
|
||||
if (tracker)
|
||||
if (tracker) {
|
||||
return tracker->GetExternallyAllocatedMemory();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -2251,8 +2298,9 @@ int CefV8ValueImpl::AdjustExternallyAllocatedMemory(int change_in_bytes) {
|
||||
v8::Local<v8::Object> obj = value->ToObject(context).ToLocalChecked();
|
||||
|
||||
V8TrackObject* tracker = V8TrackObject::Unwrap(context, obj);
|
||||
if (tracker)
|
||||
if (tracker) {
|
||||
return tracker->AdjustExternallyAllocatedMemory(change_in_bytes);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -2302,8 +2350,9 @@ CefV8ValueImpl::GetArrayBufferReleaseCallback() {
|
||||
v8::Local<v8::Object> obj = value->ToObject(context).ToLocalChecked();
|
||||
|
||||
V8TrackArrayBuffer* tracker = V8TrackArrayBuffer::Unwrap(context, obj);
|
||||
if (tracker)
|
||||
if (tracker) {
|
||||
return tracker->GetReleaseCallback();
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
@ -2381,8 +2430,9 @@ CefRefPtr<CefV8Handler> CefV8ValueImpl::GetFunctionHandler() {
|
||||
|
||||
v8::Local<v8::Object> obj = value->ToObject(context).ToLocalChecked();
|
||||
V8TrackObject* tracker = V8TrackObject::Unwrap(context, obj);
|
||||
if (tracker)
|
||||
if (tracker) {
|
||||
return tracker->GetHandler();
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
@ -2475,8 +2525,9 @@ CefRefPtr<CefV8Value> CefV8ValueImpl::ExecuteFunctionWithContext(
|
||||
}
|
||||
}
|
||||
|
||||
if (argv)
|
||||
if (argv) {
|
||||
delete[] argv;
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
@ -2554,12 +2605,14 @@ bool CefV8ValueImpl::HasCaught(v8::Local<v8::Context> context,
|
||||
v8::TryCatch& try_catch) {
|
||||
if (try_catch.HasCaught()) {
|
||||
last_exception_ = new CefV8ExceptionImpl(context, try_catch.Message());
|
||||
if (rethrow_exceptions_)
|
||||
if (rethrow_exceptions_) {
|
||||
try_catch.ReThrow();
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
if (last_exception_.get())
|
||||
if (last_exception_.get()) {
|
||||
last_exception_ = nullptr;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -2574,8 +2627,9 @@ CefRefPtr<CefV8StackTrace> CefV8StackTrace::GetCurrent(int frame_limit) {
|
||||
v8::HandleScope handle_scope(isolate);
|
||||
v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(
|
||||
isolate, frame_limit, v8::StackTrace::kDetailed);
|
||||
if (stackTrace.IsEmpty())
|
||||
if (stackTrace.IsEmpty()) {
|
||||
return nullptr;
|
||||
}
|
||||
return new CefV8StackTraceImpl(isolate, stackTrace);
|
||||
}
|
||||
|
||||
@ -2587,9 +2641,10 @@ CefV8StackTraceImpl::CefV8StackTraceImpl(v8::Isolate* isolate,
|
||||
int frame_count = handle->GetFrameCount();
|
||||
if (frame_count > 0) {
|
||||
frames_.reserve(frame_count);
|
||||
for (int i = 0; i < frame_count; ++i)
|
||||
for (int i = 0; i < frame_count; ++i) {
|
||||
frames_.push_back(
|
||||
new CefV8StackFrameImpl(isolate, handle->GetFrame(isolate, i)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2605,8 +2660,9 @@ int CefV8StackTraceImpl::GetFrameCount() {
|
||||
}
|
||||
|
||||
CefRefPtr<CefV8StackFrame> CefV8StackTraceImpl::GetFrame(int index) {
|
||||
if (index < 0 || index >= static_cast<int>(frames_.size()))
|
||||
if (index < 0 || index >= static_cast<int>(frames_.size())) {
|
||||
return nullptr;
|
||||
}
|
||||
return frames_[index];
|
||||
}
|
||||
|
||||
@ -2615,8 +2671,9 @@ CefRefPtr<CefV8StackFrame> CefV8StackTraceImpl::GetFrame(int index) {
|
||||
CefV8StackFrameImpl::CefV8StackFrameImpl(v8::Isolate* isolate,
|
||||
v8::Local<v8::StackFrame> handle)
|
||||
: line_number_(0), column_(0), is_eval_(false), is_constructor_(false) {
|
||||
if (handle.IsEmpty())
|
||||
if (handle.IsEmpty()) {
|
||||
return;
|
||||
}
|
||||
GetCefString(isolate, handle->GetScriptName(), script_name_);
|
||||
GetCefString(isolate, handle->GetScriptNameOrSourceURL(),
|
||||
script_name_or_source_url_);
|
||||
|
Reference in New Issue
Block a user