// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights // reserved. Use of this source code is governed by a BSD-style license that // can be found in the LICENSE file. #ifndef CEF_LIBCEF_DOM_DOCUMENT_IMPL_H_ #define CEF_LIBCEF_DOM_DOCUMENT_IMPL_H_ #pragma once #include #include "include/cef_dom.h" namespace blink { class WebLocalFrame; class WebNode; } // namespace blink class CefBrowserImpl; class CefDOMDocumentImpl : public CefDOMDocument { public: CefDOMDocumentImpl(CefBrowserImpl* browser, blink::WebLocalFrame* frame); ~CefDOMDocumentImpl() override; // CefDOMDocument methods. Type GetType() override; CefRefPtr GetDocument() override; CefRefPtr GetBody() override; CefRefPtr GetHead() override; CefString GetTitle() override; CefRefPtr GetElementById(const CefString& id) override; CefRefPtr GetFocusedNode() override; bool HasSelection() override; int GetSelectionStartOffset() override; int GetSelectionEndOffset() override; CefString GetSelectionAsMarkup() override; CefString GetSelectionAsText() override; CefString GetBaseURL() override; CefString GetCompleteURL(const CefString& partialURL) override; CefBrowserImpl* GetBrowser() { return browser_; } blink::WebLocalFrame* GetFrame() { return frame_; } // The document maintains a map of all existing node objects. CefRefPtr GetOrCreateNode(const blink::WebNode& node); void RemoveNode(const blink::WebNode& node); // Must be called before the object is destroyed. void Detach(); // Verify that the object exists and is being accessed on the UI thread. bool VerifyContext(); protected: CefBrowserImpl* browser_; blink::WebLocalFrame* frame_; using NodeMap = std::map; NodeMap node_map_; IMPLEMENT_REFCOUNTING(CefDOMDocumentImpl); }; #endif // CEF_LIBCEF_DOM_DOCUMENT_IMPL_H_