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

Side by Side Diff: src/plugin/PluginClass.h

Issue 29323561: Issue #3383 - Rewrite and simplify browser-site handling in CPluginClass (Closed)
Patch Set: address comments Created Nov. 30, 2015, 4:30 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/plugin/PluginClass.cpp » ('j') | src/plugin/PluginClass.cpp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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-2015 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
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_DOWNLOADCOMPLETE, OnDownloa dComplete) 72 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_DOWNLOADCOMPLETE, OnDownloa dComplete)
73 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_DOCUMENTCOMPLETE, OnDocumen tComplete) 73 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_DOCUMENTCOMPLETE, OnDocumen tComplete)
74 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_WINDOWSTATECHANGED, OnWindo wStateChanged) 74 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_WINDOWSTATECHANGED, OnWindo wStateChanged)
75 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_COMMANDSTATECHANGE, OnComma ndStateChange) 75 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_COMMANDSTATECHANGE, OnComma ndStateChange)
76 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_ONQUIT, OnOnQuit) 76 SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_ONQUIT, OnOnQuit)
77 END_SINK_MAP() 77 END_SINK_MAP()
78 78
79 CPluginClass(); 79 CPluginClass();
80 ~CPluginClass(); 80 ~CPluginClass();
81 81
82 HRESULT FinalConstruct();
83 void FinalRelease();
84
85 // IObjectWithSite 82 // IObjectWithSite
86
87 STDMETHOD(SetSite)(IUnknown *pUnkSite); 83 STDMETHOD(SetSite)(IUnknown *pUnkSite);
88 84
89 // IOleCommandTarget 85 // IOleCommandTarget
90
91 STDMETHOD(QueryStatus)(const GUID* pguidCmdGroup, ULONG cCmds, OLECMD prgCmds[ ], OLECMDTEXT* pCmdText); 86 STDMETHOD(QueryStatus)(const GUID* pguidCmdGroup, ULONG cCmds, OLECMD prgCmds[ ], OLECMDTEXT* pCmdText);
92 STDMETHOD(Exec)(const GUID*, DWORD nCmdID, DWORD, VARIANTARG*, VARIANTARG* pva Out); 87 STDMETHOD(Exec)(const GUID*, DWORD nCmdID, DWORD, VARIANTARG*, VARIANTARG* pva Out);
93 88
94 89
95 static CPluginTab* GetTab(DWORD dwThreadId); 90 static CPluginTab* GetTab(DWORD dwThreadId);
96 CPluginTab* GetTab(); 91 CPluginTab* GetTab();
97 92
98 void UpdateStatusBar(); 93 void UpdateStatusBar();
99 static DWORD WINAPI MainThreadProc(LPVOID pParam);
100 94
101 private: 95 private:
102 96
103 bool SetMenuBar(HMENU hMenu, const std::wstring& url); 97 bool SetMenuBar(HMENU hMenu, const std::wstring& url);
104 HMENU CreatePluginMenu(const std::wstring& url); 98 HMENU CreatePluginMenu(const std::wstring& url);
105 99
106 void DisplayPluginMenu(HMENU hMenu, int nToolbarCmdID, POINT pt, UINT nMenuFla gs); 100 void DisplayPluginMenu(HMENU hMenu, int nToolbarCmdID, POINT pt, UINT nMenuFla gs);
107 bool CreateStatusBarPane(); 101 bool CreateStatusBarPane();
108 102
109 public: 103 public:
110 HWND GetBrowserHWND() const; 104 HWND GetBrowserHWND() const;
111 HWND GetTabHWND() const; 105 bool IsRootBrowser(IWebBrowser2*);
112 CComQIPtr<IWebBrowser2> GetBrowser() const;
113
114 106
115 static CPluginMimeFilterClient* s_mimeFilter; 107 static CPluginMimeFilterClient* s_mimeFilter;
116 108
117 private: 109 private:
118 110
119 std::wstring GetBrowserUrl() const; 111 std::wstring GetBrowserUrl() const;
120 112
121 static DWORD WINAPI StartInitObject(LPVOID thisPtr); 113 static DWORD WINAPI StartInitObject(LPVOID thisPtr);
122 bool InitObject(); 114 bool InitObject();
123 void CloseTheme(); 115 void CloseTheme();
(...skipping 15 matching lines...) Expand all
139 void STDMETHODCALLTYPE OnDownloadComplete(); 131 void STDMETHODCALLTYPE OnDownloadComplete();
140 void STDMETHODCALLTYPE OnDocumentComplete(IDispatch* frameBrowserDisp, VARIANT * /*urlOrPidl*/); 132 void STDMETHODCALLTYPE OnDocumentComplete(IDispatch* frameBrowserDisp, VARIANT * /*urlOrPidl*/);
141 void STDMETHODCALLTYPE OnWindowStateChanged(unsigned long flags, unsigned long validFlagsMask); 133 void STDMETHODCALLTYPE OnWindowStateChanged(unsigned long flags, unsigned long validFlagsMask);
142 void STDMETHODCALLTYPE OnCommandStateChange(long command, VARIANT_BOOL enable) ; 134 void STDMETHODCALLTYPE OnCommandStateChange(long command, VARIANT_BOOL enable) ;
143 void STDMETHODCALLTYPE OnOnQuit(); 135 void STDMETHODCALLTYPE OnOnQuit();
144 void Unadvise(); 136 void Unadvise();
145 137
146 void ShowStatusBar(); 138 void ShowStatusBar();
147 bool IsStatusBarEnabled(); 139 bool IsStatusBarEnabled();
148 140
149 public: 141 /**
150 CComQIPtr<IWebBrowser2> m_webBrowser2; 142 * Our site object as a browser.
151 private: 143 *
144 * It's values are set and reset solely in SetSite().
145 * The declaration as CComPtr is defensive programming;
146 * it ensures that the site keeps this interface alive for us in the
147 * unlikely case that the site is different from a browser.
148 */
149 CComPtr<IWebBrowser2> m_webBrowser2;
152 HWND m_hBrowserWnd; 150 HWND m_hBrowserWnd;
153 HWND m_hTabWnd; 151 HWND m_hTabWnd;
154 HWND m_hStatusBarWnd; 152 HWND m_hStatusBarWnd;
155 HWND m_hPaneWnd; 153 HWND m_hPaneWnd;
156 154
157 WNDPROC m_pWndProcStatus; 155 WNDPROC m_pWndProcStatus;
158 int m_nPaneWidth; 156 int m_nPaneWidth;
159 HANDLE m_hTheme; 157 HANDLE m_hTheme;
160 158
161 CriticalSection m_csStatusBar; 159 CriticalSection m_csStatusBar;
(...skipping 11 matching lines...) Expand all
173 // Icons 171 // Icons
174 static HICON s_hIcons[ICON_MAX]; 172 static HICON s_hIcons[ICON_MAX];
175 static DWORD s_hIconTypes[ICON_MAX]; 173 static DWORD s_hIconTypes[ICON_MAX];
176 174
177 static HICON GetIcon(int type); 175 static HICON GetIcon(int type);
178 176
179 // Main thread 177 // Main thread
180 static HANDLE s_hMainThread; 178 static HANDLE s_hMainThread;
181 static bool s_isMainThreadDone; 179 static bool s_isMainThreadDone;
182 180
183 static HANDLE GetMainThreadHandle();
184 static bool IsMainThreadDone(HANDLE mainThread);
185
186 static HINSTANCE s_hUxtheme; 181 static HINSTANCE s_hUxtheme;
187 static std::set<CPluginClass*> s_instances; 182 static std::set<CPluginClass*> s_instances;
188 static std::map<DWORD,CPluginClass*> s_threadInstances; 183 static std::map<DWORD,CPluginClass*> s_threadInstances;
189 static CComAutoCriticalSection s_criticalSectionLocal; 184 static CComAutoCriticalSection s_criticalSectionLocal;
190 static CComAutoCriticalSection s_criticalSectionBrowser;
191 static CComAutoCriticalSection s_criticalSectionWindow; 185 static CComAutoCriticalSection s_criticalSectionWindow;
192 186
193 // Async browser 187 // Async browser
194 static CComQIPtr<IWebBrowser2> s_asyncWebBrowser2; 188 static CComQIPtr<IWebBrowser2> s_asyncWebBrowser2;
195 static CComQIPtr<IWebBrowser2> GetAsyncBrowser(); 189 static CComQIPtr<IWebBrowser2> GetAsyncBrowser();
196 }; 190 };
197 191
198 OBJECT_ENTRY_AUTO(__uuidof(PluginClass), CPluginClass) 192 OBJECT_ENTRY_AUTO(__uuidof(PluginClass), CPluginClass)
199 193
200 194
201 #endif // _PLUGIN_CLASS_H_ 195 #endif // _PLUGIN_CLASS_H_
OLDNEW
« no previous file with comments | « no previous file | src/plugin/PluginClass.cpp » ('j') | src/plugin/PluginClass.cpp » ('J')

Powered by Google App Engine
This is Rietveld