本文整理汇总了C#中CefBrowser.GetFrame方法的典型用法代码示例。如果您正苦于以下问题:C# CefBrowser.GetFrame方法的具体用法?C# CefBrowser.GetFrame怎么用?C# CefBrowser.GetFrame使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CefBrowser
的用法示例。
在下文中一共展示了CefBrowser.GetFrame方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnProcessMessageReceived
/// <summary>
/// Call from CefClient::OnProcessMessageReceived. Returns true if the message
/// is handled by this router or false otherwise.
/// </summary>
public bool OnProcessMessageReceived(CefBrowser browser, CefProcessId sourceProcess, CefProcessMessage message)
{
Helpers.RequireUIThread();
var messageName = message.Name;
if (messageName == _queryMessageName)
{
var args = message.Arguments;
Debug.Assert(args.Count == 6);
var frameId = Helpers.Int64Set(args.GetInt(0), args.GetInt(1));
var contextId = args.GetInt(2);
var requestId = args.GetInt(3);
var request = args.GetString(4);
var persistent = args.GetBool(5);
if (_handlerSet.Count == 0)
{
// No handlers so cancel the query.
CancelUnhandledQuery(browser, contextId, requestId);
return true;
}
var browserId = browser.Identifier;
var queryId = _queryIdGenerator.GetNextId();
var frame = browser.GetFrame(frameId);
var callback = new Callback(this, browserId, queryId, persistent);
// Make a copy of the handler list in case the user adds or removes a
// handler while we're iterating.
var handlers = _handlerSet.ToArray();
var handled = false;
Handler handler = null;
foreach (var x in handlers)
{
handled = x.OnQuery(browser, frame, queryId, request, persistent, callback);
if (handled)
{
handler = x;
break;
}
}
// If the query isn't handled nothing should be keeping a reference to
// the callback.
// DCHECK(handled || callback->GetRefCt() == 1);
// Debug.Assert(handled && handler != null);
// We don't need this assertion, in GC environment.
// There is client responsibility to do not reference callback, if request is not handled.
if (handled)
{
// Persist the query information until the callback executes.
// It's safe to do this here because the callback will execute
// asynchronously.
var info = new QueryInfo
{
Browser = browser,
FrameId = frameId,
ContextId = contextId,
RequestId = requestId,
Persistent = persistent,
Callback = callback,
Handler = handler,
};
_browserQueryInfoMap.Add(browserId, queryId, info);
}
else
{
// Invalidate the callback.
callback.Detach();
// No one chose to handle the query so cancel it.
CancelUnhandledQuery(browser, contextId, requestId);
}
return true;
}
else if (messageName == _cancelMessageName)
{
var args = message.Arguments;
Debug.Assert(args.Count == 2);
var browserId = browser.Identifier;
var contextId = args.GetInt(0);
var requestId = args.GetInt(1);
CancelPendingRequest(browserId, contextId, requestId);
return true;
}
return false;
}