博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
CEF3 笔记三(常用类的介绍)
阅读量:5939 次
发布时间:2019-06-19

本文共 6928 字,大约阅读时间需要 23 分钟。

接上文《CEF3 笔记二(常用的类介绍)》

CefBrowserHost 类介绍

CefBrowserHost: 该类在浏览器窗口来看代表了 browser 进程,同时也暴露了与浏览器窗口相关的接口,该类的方法只能在 browser 进程中调用,但可以在 browser 进程的任意线程中被调用。该类的主要方法如下:

  • 创建浏览器对象。

需要传入的参数包括 CefWindowInfo 对象,CefClient 对象,默认的 URL, 以及浏览器启动时参数设置。

public static bool CreateBrowser(const CefWindowInfo& windowInfo,                        CefRefPtr
client, const CefString& url,                       const CefBrowserSettings& settings);
public static CefRefPtr
CreateBrowserSync(                  const CefWindowInfo& windowInfo,                   CefRefPtr< CefClient > client,                  const CefString& url, const CefBrowserSettings& settings);
  • 请求关闭浏览器对象。该函数被调用是会触发 JS 'onbeforeunload' 事件,如果参数 force_close为 false,并且提供了 onbeforeunload 事件的回调函数,则提示用户是否关闭浏览器,此时用户可以选取取消操作。如果 force_close为 true,则直接关闭浏览器。
public virtual void CloseBrowser(bool force_close)= 0;
  • 获取浏览器对象(在 CefBrowser 类中可以通过调用 GetHost() 获取与之对应的 CefBrowserHost)
public virtual CefRefPtr< CefBrowser > GetBrowser()= 0;
  • 获取 CefClient 对象
public virtual CefRefPtr< CefClient > GetClient()= 0;
  • 获取该浏览器对象的窗口句柄,如果是弹出窗口,则返回 NULL。
public virtual CefWindowHandle GetOpenerWindowHandle()= 0;

 

CefBrowser 类介绍

CefBrowser: 该类代表一个浏览器对象,在 browser 进程中该类的方法可以被任意线程调用。在 render 进程中只能在主线程被调用。该类的主要方法包括:

// Returns the browser host object. This method can only be called in the  // browser process.  virtual CefRefPtr
GetHost() =0; // Returns true if the browser can navigate backwards. virtual bool CanGoBack() =0; // Navigate backwards. virtual void GoBack() =0; // Returns true if the browser can navigate forwards. virtual bool CanGoForward() =0; // Navigate forwards. virtual void GoForward() =0; // Returns true if the browser is currently loading. virtual bool IsLoading() =0; // Reload the current page. virtual void Reload() =0; // Reload the current page ignoring any cached data. virtual void ReloadIgnoreCache() =0; // Stop loading the page. virtual void StopLoad() =0; // Returns the globally unique identifier for this browser. virtual int GetIdentifier() =0; // Returns true if this object is pointing to the same handle as |that| // object. virtual bool IsSame(CefRefPtr
that) =0; // Returns true if the window is a popup window. virtual bool IsPopup() =0; // Returns true if a document has been loaded in the browser. virtual bool HasDocument() =0; // Returns the main (top-level) frame for the browser window. virtual CefRefPtr
GetMainFrame() =0; // Returns the focused frame for the browser window. virtual CefRefPtr
GetFocusedFrame() =0; // Returns the frame with the specified identifier, or NULL if not found. virtual CefRefPtr
GetFrame(int64 identifier) =0; // Returns the frame with the specified name, or NULL if not found. virtual CefRefPtr
GetFrame(const CefString& name) =0; // Returns the number of frames that currently exist. virtual size_t GetFrameCount() =0; // Returns the identifiers of all existing frames. virtual void GetFrameIdentifiers(std::vector
& identifiers) =0; // Returns the names of all existing frames. virtual void GetFrameNames(std::vector
& names) =0; // Send a message to the specified |target_process|. Returns true if the // message was sent successfully. virtual bool SendProcessMessage(CefProcessId target_process, CefRefPtr
message) =0;

CefFrame 类介绍

CefFrame: 表示浏览器窗口中的一个 frame,在 browser 进程中该类的方法可以被任意线程调用(简单理解就是 Frame 标识一个页面,通过该类开发者可以加载某一URL 或者一段 HTML 代码,获取页面的源码和文本,URL,V8 执行上下文,访问页面中的 DOM)。该类的主要方法如下:

// True if this object is currently attached to a valid frame.  virtual bool IsValid() =0;  // Execute undo in this frame.  virtual void Undo() =0;  // Execute redo in this frame.  virtual void Redo() =0;  // Execute cut in this frame.  virtual void Cut() =0;  // Execute copy in this frame.  virtual void Copy() =0;  // Execute paste in this frame.  virtual void Paste() =0;  // Execute delete in this frame.  virtual void Delete() =0;  // Execute select all in this frame.  virtual void SelectAll() =0;  // Save this frame's HTML source to a temporary file and open it in the  // default text viewing application. This method can only be called from the  // browser process.  virtual void ViewSource() =0;  // Retrieve this frame's HTML source as a string sent to the specified  // visitor.  virtual void GetSource(CefRefPtr
visitor) =0; // Retrieve this frame's display text as a string sent to the specified // visitor. virtual void GetText(CefRefPtr
visitor) =0; // Load the request represented by the |request| object. virtual void LoadRequest(CefRefPtr
request) =0; // Load the specified |url|. virtual void LoadURL(const CefString& url) =0; // Load the contents of |string_val| with the specified dummy |url|. |url| // should have a standard scheme (for example, http scheme) or behaviors like // link clicks and web security restrictions may not behave as expected. virtual void LoadString(const CefString& string_val, const CefString& url) =0; // Execute a string of JavaScript code in this frame. The |script_url| // parameter is the URL where the script in question can be found, if any. // The renderer may request this URL to show the developer the source of the // error. The |start_line| parameter is the base line number to use for error // reporting. virtual void ExecuteJavaScript(const CefString& code, const CefString& script_url, int start_line) =0; // Returns true if this is the main (top-level) frame. virtual bool IsMain() =0; // Returns true if this is the focused frame. virtual bool IsFocused() =0; // Returns the name for this frame. If the frame has an assigned name (for // example, set via the iframe "name" attribute) then that value will be // returned. Otherwise a unique name will be constructed based on the frame // parent hierarchy. The main (top-level) frame will always have an empty name // value. virtual CefString GetName() =0; // Returns the globally unique identifier for this frame. virtual int64 GetIdentifier() =0; // Returns the parent of this frame or NULL if this is the main (top-level) // frame. virtual CefRefPtr
GetParent() =0; // Returns the URL currently loaded in this frame. virtual CefString GetURL() =0; // Returns the browser that this frame belongs to. virtual CefRefPtr
GetBrowser() =0; // Get the V8 context associated with the frame. This method can only be // called from the render process. virtual CefRefPtr
GetV8Context() =0; // Visit the DOM document. This method can only be called from the render // process. virtual void VisitDOM(CefRefPtr
visitor) =0;

 

转载于:https://www.cnblogs.com/haippy/archive/2013/06/10/3131253.html

你可能感兴趣的文章
世界银行拨款2293万美元支持印度并网屋顶太阳能
查看>>
中国电信制定物联网策略:规模市场自主经营 长尾市场集成
查看>>
希捷撤离 硬盘的那些风花雪月记忆
查看>>
人工智能数据中心
查看>>
QA请勿忘初心
查看>>
协作与大数据构建新型打假模式
查看>>
崛起的中国服务器市场迎来旺盛的SPEC测试需求
查看>>
7月17日云栖精选夜读:深度 | 两个案例,掌握AI在大数据领域的前沿应用
查看>>
蚂蚁财富联手百会CRM全面升级金融服务
查看>>
视频转成flv格式
查看>>
英特尔分拆McAfee:31亿美元将多数股权卖给投资公司TPG
查看>>
AWS S3宕机的启发: 云必须分散化
查看>>
零基础学习SVN之(二):CVS与SVN的区别
查看>>
HP Webinspect 10 访问wap的url
查看>>
单元测试Struts2的Action(包含源码)
查看>>
Linux存储入门:简易数据恢复方案--分区和LVM实战
查看>>
客服运营三部曲
查看>>
思科分析引擎助力大型数据中心应用发展
查看>>
7 种常用的排序算法直观感受
查看>>
程序员,告诉他们被打断的真实代价
查看>>