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: rename OnQuit Created Sept. 30, 2016, 3:25 p.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..37f178977caa1cf4e96e3707b92bcc54cabd98ad
--- /dev/null
+++ b/src/plugin/WebBrowserEventsListener.h
@@ -0,0 +1,75 @@
+/*
+ * This file is part of Adblock Plus <https://adblockplus.org/>,
+ * Copyright (C) 2006-2016 Eyeo GmbH
+ *
+ * Adblock Plus is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3 as
+ * published by the Free Software Foundation.
+ *
+ * Adblock Plus is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#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::CComMultiThreadModel>,
+ 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(1, __uuidof(DWebBrowserEvents2), DISPID_ONQUIT, OnQuit)
+ SINK_ENTRY_EX(2, __uuidof(HTMLDocumentEvents2), DISPID_HTMLDOCUMENTEVENTS2_ONREADYSTATECHANGE, OnReadyStateChange)
+ END_SINK_MAP()
+
+ STDMETHOD(OnDocumentComplete)(IDispatch* pDisp, VARIANT* urlVariant);
+ STDMETHOD_(void, OnQuit)();
+ STDMETHOD_(void, OnReadyStateChange)(IHTMLEventObj* pEvtObj);
+
+ DECLARE_PROTECT_FINAL_CONSTRUCT()
+
+ HRESULT FinalConstruct(){ return S_OK; }
+ void FinalRelease();
+ HRESULT Init(IWebBrowser2* webBrowser, const OnDestroy& onDestroy, const OnReloaded& onReloaded);
+
+private:
+ void emitReloaded();
+private:
+ ATL::CComPtr<IWebBrowser2> m_browser;
+ OnDestroy m_onDestroy;
+ OnReloaded m_onReloaded;
+ 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