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

Delta Between Two Patch Sets: src/plugin/PluginClass.h

Issue 29323611: Issue #1234, #2058 - Rewrite log facility, improving thread implementation
Left Patch Set: rebase only Created Nov. 26, 2015, 1:07 p.m.
Right Patch Set: rebase only Created July 27, 2016, 9:11 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/plugin/Placeholder.h ('k') | src/plugin/PluginClass.cpp » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2015 Eyeo GmbH 3 * Copyright (C) 2006-2016 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
(...skipping 20 matching lines...) Expand all
34 #include "NotificationMessage.h" 34 #include "NotificationMessage.h"
35 35
36 #define ICON_PLUGIN_DISABLED 0 36 #define ICON_PLUGIN_DISABLED 0
37 #define ICON_PLUGIN_ENABLED 1 37 #define ICON_PLUGIN_ENABLED 1
38 #define ICON_PLUGIN_DEACTIVATED 2 38 #define ICON_PLUGIN_DEACTIVATED 2
39 #define ICON_MAX 3 39 #define ICON_MAX 3
40 40
41 #define WM_LAUNCH_INFO (WM_APP + 10) 41 #define WM_LAUNCH_INFO (WM_APP + 10)
42 42
43 class CPluginMimeFilterClient; 43 class CPluginMimeFilterClient;
44
45 44
46 class ATL_NO_VTABLE CPluginClass : 45 class ATL_NO_VTABLE CPluginClass :
47 public ATL::CComObjectRootEx<ATL::CComMultiThreadModel>, 46 public ATL::CComObjectRootEx<ATL::CComMultiThreadModel>,
48 public ATL::CComCoClass<CPluginClass, &CLSID_PluginClass>, 47 public ATL::CComCoClass<CPluginClass, &CLSID_PluginClass>,
49 public ATL::IObjectWithSiteImpl<CPluginClass>, 48 public ATL::IObjectWithSiteImpl<CPluginClass>,
50 public IOleCommandTarget, 49 public IOleCommandTarget,
51 public ATL::IDispEventImpl<1, CPluginClass, &DIID_DWebBrowserEvents2, &LIBID_S HDocVw, 1, 1> 50 public ATL::IDispEventImpl<1, CPluginClass, &DIID_DWebBrowserEvents2, &LIBID_S HDocVw, 1, 1>
52 { 51 {
53 52
54 friend class CPluginTab; 53 friend class CPluginTab;
(...skipping 23 matching lines...) Expand all
78 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_DOWNLOADCOMPLETE, OnDownloa dComplete) 77 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_DOWNLOADCOMPLETE, OnDownloa dComplete)
79 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_DOCUMENTCOMPLETE, OnDocumen tComplete) 78 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_DOCUMENTCOMPLETE, OnDocumen tComplete)
80 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_WINDOWSTATECHANGED, OnWindo wStateChanged) 79 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_WINDOWSTATECHANGED, OnWindo wStateChanged)
81 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_COMMANDSTATECHANGE, OnComma ndStateChange) 80 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_COMMANDSTATECHANGE, OnComma ndStateChange)
82 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_ONQUIT, OnOnQuit) 81 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_ONQUIT, OnOnQuit)
83 END_SINK_MAP() 82 END_SINK_MAP()
84 83
85 CPluginClass(); 84 CPluginClass();
86 ~CPluginClass(); 85 ~CPluginClass();
87 86
88 HRESULT FinalConstruct();
89 void FinalRelease();
90
91 // IObjectWithSite 87 // IObjectWithSite
92
93 STDMETHOD(SetSite)(IUnknown *pUnkSite); 88 STDMETHOD(SetSite)(IUnknown *pUnkSite);
94 89
95 // IOleCommandTarget 90 // IOleCommandTarget
96
97 STDMETHOD(QueryStatus)(const GUID* pguidCmdGroup, ULONG cCmds, OLECMD prgCmds[ ], OLECMDTEXT* pCmdText); 91 STDMETHOD(QueryStatus)(const GUID* pguidCmdGroup, ULONG cCmds, OLECMD prgCmds[ ], OLECMDTEXT* pCmdText);
98 STDMETHOD(Exec)(const GUID*, DWORD nCmdID, DWORD, VARIANTARG*, VARIANTARG* pva Out); 92 STDMETHOD(Exec)(const GUID*, DWORD nCmdID, DWORD, VARIANTARG*, VARIANTARG* pva Out);
99 93
100 94
101 static CPluginTab* GetTab(DWORD dwThreadId); 95 static CPluginTab* GetTabForCurrentThread();
102 CPluginTab* GetTab(); 96 CPluginTab* GetTab();
103 97
104 void UpdateStatusBar(); 98 void UpdateStatusBar();
105 static DWORD WINAPI MainThreadProc(LPVOID pParam);
106 99
107 private: 100 private:
108 101
109 bool SetMenuBar(HMENU hMenu, const std::wstring& url); 102 bool SetMenuBar(HMENU hMenu, const std::wstring& url);
110 HMENU CreatePluginMenu(const std::wstring& url); 103 HMENU CreatePluginMenu(const std::wstring& url);
111 104
112 void DisplayPluginMenu(HMENU hMenu, int nToolbarCmdID, POINT pt, UINT nMenuFla gs); 105 void DisplayPluginMenu(HMENU hMenu, int nToolbarCmdID, POINT pt, UINT nMenuFla gs);
113 bool CreateStatusBarPane(); 106 bool CreateStatusBarPane();
114 107
115 public: 108 public:
116 HWND GetBrowserHWND() const; 109 HWND GetBrowserHWND() const;
117 HWND GetTabHWND() const; 110 bool IsRootBrowser(IWebBrowser2*);
118 CComQIPtr<IWebBrowser2> GetBrowser() const;
119
120 111
121 static CPluginMimeFilterClient* s_mimeFilter; 112 static CPluginMimeFilterClient* s_mimeFilter;
122 113
123 private: 114 private:
124 115
125 std::wstring GetBrowserUrl() const; 116 std::wstring GetBrowserUrl() const;
126 117
127 static DWORD WINAPI StartInitObject(LPVOID thisPtr); 118 static DWORD WINAPI StartInitObject(LPVOID thisPtr);
128 bool InitObject(); 119 bool InitObject();
129 void CloseTheme(); 120 void CloseTheme();
(...skipping 15 matching lines...) Expand all
145 void STDMETHODCALLTYPE OnDownloadComplete(); 136 void STDMETHODCALLTYPE OnDownloadComplete();
146 void STDMETHODCALLTYPE OnDocumentComplete(IDispatch* frameBrowserDisp, VARIANT * /*urlOrPidl*/); 137 void STDMETHODCALLTYPE OnDocumentComplete(IDispatch* frameBrowserDisp, VARIANT * /*urlOrPidl*/);
147 void STDMETHODCALLTYPE OnWindowStateChanged(unsigned long flags, unsigned long validFlagsMask); 138 void STDMETHODCALLTYPE OnWindowStateChanged(unsigned long flags, unsigned long validFlagsMask);
148 void STDMETHODCALLTYPE OnCommandStateChange(long command, VARIANT_BOOL enable) ; 139 void STDMETHODCALLTYPE OnCommandStateChange(long command, VARIANT_BOOL enable) ;
149 void STDMETHODCALLTYPE OnOnQuit(); 140 void STDMETHODCALLTYPE OnOnQuit();
150 void Unadvise(); 141 void Unadvise();
151 142
152 void ShowStatusBar(); 143 void ShowStatusBar();
153 bool IsStatusBarEnabled(); 144 bool IsStatusBarEnabled();
154 145
155 public: 146 /**
156 CComQIPtr<IWebBrowser2> m_webBrowser2; 147 * A browser interface pointer to our site object
157 private: 148 *
149 * It's values are set and reset solely in SetSite().
150 */
151 CComPtr<IWebBrowser2> m_webBrowser2;
158 HWND m_hBrowserWnd; 152 HWND m_hBrowserWnd;
159 HWND m_hTabWnd; 153 HWND m_hTabWnd;
160 HWND m_hStatusBarWnd; 154 HWND m_hStatusBarWnd;
161 HWND m_hPaneWnd; 155 HWND m_hPaneWnd;
162 156
163 WNDPROC m_pWndProcStatus; 157 WNDPROC m_pWndProcStatus;
164 int m_nPaneWidth; 158 int m_nPaneWidth;
165 HANDLE m_hTheme; 159 HANDLE m_hTheme;
166 160
167 CriticalSection m_csStatusBar; 161 CriticalSection m_csStatusBar;
(...skipping 11 matching lines...) Expand all
179 // Icons 173 // Icons
180 static HICON s_hIcons[ICON_MAX]; 174 static HICON s_hIcons[ICON_MAX];
181 static DWORD s_hIconTypes[ICON_MAX]; 175 static DWORD s_hIconTypes[ICON_MAX];
182 176
183 static HICON GetIcon(int type); 177 static HICON GetIcon(int type);
184 178
185 // Main thread 179 // Main thread
186 static HANDLE s_hMainThread; 180 static HANDLE s_hMainThread;
187 static bool s_isMainThreadDone; 181 static bool s_isMainThreadDone;
188 182
189 static HANDLE GetMainThreadHandle();
190 static bool IsMainThreadDone(HANDLE mainThread);
191
192 static HINSTANCE s_hUxtheme; 183 static HINSTANCE s_hUxtheme;
193 static std::set<CPluginClass*> s_instances; 184 static std::set<CPluginClass*> s_instances;
194 static std::map<DWORD,CPluginClass*> s_threadInstances;
195 static CComAutoCriticalSection s_criticalSectionLocal; 185 static CComAutoCriticalSection s_criticalSectionLocal;
196 static CComAutoCriticalSection s_criticalSectionBrowser;
197 static CComAutoCriticalSection s_criticalSectionWindow; 186 static CComAutoCriticalSection s_criticalSectionWindow;
198 187
199 // Async browser 188 // Async browser
200 static CComQIPtr<IWebBrowser2> s_asyncWebBrowser2; 189 static CComQIPtr<IWebBrowser2> s_asyncWebBrowser2;
201 static CComQIPtr<IWebBrowser2> GetAsyncBrowser(); 190 static CComQIPtr<IWebBrowser2> GetAsyncBrowser();
202 }; 191 };
203 192
204 OBJECT_ENTRY_AUTO(__uuidof(PluginClass), CPluginClass) 193 OBJECT_ENTRY_AUTO(__uuidof(PluginClass), CPluginClass)
205 194
206
207 #endif // _PLUGIN_CLASS_H_ 195 #endif // _PLUGIN_CLASS_H_
LEFTRIGHT

Powered by Google App Engine
This is Rietveld