当前位置: 首页>>代码示例>>C#>>正文


C# CefBrowser.GetFrame方法代码示例

本文整理汇总了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;
        }
开发者ID:whztt07,项目名称:SDK,代码行数:99,代码来源:CefMessageRouterBrowserSide.cs


注:本文中的CefBrowser.GetFrame方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。