Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: src/plugin/WebBrowserEventsListener.h

Issue 6567422169448448: Issue 119 - Switch to injecting CSS for element hiding (Closed)
Patch Set: rebase and address comments Created April 13, 2015, 8:04 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/plugin/PluginTabBase.cpp ('k') | src/plugin/WebBrowserEventsListener.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/plugin/WebBrowserEventsListener.h
diff --git a/src/plugin/WebBrowserEventsListener.h b/src/plugin/WebBrowserEventsListener.h
new file mode 100644
index 0000000000000000000000000000000000000000..d162a1f828e5a1a4044bffcac3ed59681597fc9b
--- /dev/null
+++ b/src/plugin/WebBrowserEventsListener.h
@@ -0,0 +1,56 @@
+#pragma once
+#include <functional>
+#include <memory>
+
+class WebBrowserEventsListener;
+
+typedef ATL::IDispEventImpl <1, WebBrowserEventsListener,
+ &__uuidof(DWebBrowserEvents2), &LIBID_SHDocVw, 1, 1> WebBrowserEvents2Listener;
+
+typedef ATL::IDispEventImpl <2, WebBrowserEventsListener,
+ &__uuidof(HTMLDocumentEvents2), &LIBID_MSHTML, 4, 0> HTMLDocumentEvents2Listener;
+
+class ATL_NO_VTABLE WebBrowserEventsListener :
+ public ATL::CComObjectRootEx<ATL::CComSingleThreadModel>,
+ public WebBrowserEvents2Listener,
+ public HTMLDocumentEvents2Listener,
+ public IUnknown
+{
+ enum class State
+ {
+ FirstTimeLoading, Loading, Loaded
+ };
+public:
+ typedef std::function<void()> OnDestroy;
+ typedef std::function<void()> OnReloaded;
+
+ WebBrowserEventsListener();
+ ~WebBrowserEventsListener();
+ BEGIN_COM_MAP(WebBrowserEventsListener)
+ COM_INTERFACE_ENTRY(IUnknown)
+ END_COM_MAP()
+
+ DECLARE_NOT_AGGREGATABLE(WebBrowserEventsListener)
+ BEGIN_SINK_MAP(WebBrowserEventsListener)
+ SINK_ENTRY_EX(1, __uuidof(DWebBrowserEvents2), DISPID_DOCUMENTCOMPLETE, OnDocumentComplete)
+ SINK_ENTRY_EX(2, __uuidof(HTMLDocumentEvents2), DISPID_HTMLDOCUMENTEVENTS2_ONREADYSTATECHANGE, OnReadyStateChange)
+ END_SINK_MAP()
+
+ STDMETHOD(OnDocumentComplete)(IDispatch* pDisp, VARIANT* urlVariant);
+ STDMETHOD_(void, OnReadyStateChange)(IHTMLEventObj* pEvtObj);
+
+ DECLARE_PROTECT_FINAL_CONSTRUCT()
+
+ HRESULT FinalConstruct(){ return S_OK; }
+ void FinalRelease(){}
+ HRESULT Init(IWebBrowser2* webBrowser, const OnDestroy& onDestroy);
+
+ OnReloaded reloaded;
+private:
+ void emitReloaded();
+private:
+ ATL::CComPtr<IWebBrowser2> m_browser;
+ OnDestroy m_onDestroy;
+ bool m_isDocumentEvents2Connected;
+ State m_state;
+};
« no previous file with comments | « src/plugin/PluginTabBase.cpp ('k') | src/plugin/WebBrowserEventsListener.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld