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: initialization; shorten comment Created Dec. 3, 2015, 2:23 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') | no next file with comments »
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 * A browser interface pointer to our site object
151 private: 143 *
144 * It's values are set and reset solely in SetSite().
145 */
146 CComPtr<IWebBrowser2> m_webBrowser2;
152 HWND m_hBrowserWnd; 147 HWND m_hBrowserWnd;
153 HWND m_hTabWnd; 148 HWND m_hTabWnd;
154 HWND m_hStatusBarWnd; 149 HWND m_hStatusBarWnd;
155 HWND m_hPaneWnd; 150 HWND m_hPaneWnd;
156 151
157 WNDPROC m_pWndProcStatus; 152 WNDPROC m_pWndProcStatus;
158 int m_nPaneWidth; 153 int m_nPaneWidth;
159 HANDLE m_hTheme; 154 HANDLE m_hTheme;
160 155
161 CriticalSection m_csStatusBar; 156 CriticalSection m_csStatusBar;
(...skipping 11 matching lines...) Expand all
173 // Icons 168 // Icons
174 static HICON s_hIcons[ICON_MAX]; 169 static HICON s_hIcons[ICON_MAX];
175 static DWORD s_hIconTypes[ICON_MAX]; 170 static DWORD s_hIconTypes[ICON_MAX];
176 171
177 static HICON GetIcon(int type); 172 static HICON GetIcon(int type);
178 173
179 // Main thread 174 // Main thread
180 static HANDLE s_hMainThread; 175 static HANDLE s_hMainThread;
181 static bool s_isMainThreadDone; 176 static bool s_isMainThreadDone;
182 177
183 static HANDLE GetMainThreadHandle();
184 static bool IsMainThreadDone(HANDLE mainThread);
185
186 static HINSTANCE s_hUxtheme; 178 static HINSTANCE s_hUxtheme;
187 static std::set<CPluginClass*> s_instances; 179 static std::set<CPluginClass*> s_instances;
188 static std::map<DWORD,CPluginClass*> s_threadInstances; 180 static std::map<DWORD,CPluginClass*> s_threadInstances;
189 static CComAutoCriticalSection s_criticalSectionLocal; 181 static CComAutoCriticalSection s_criticalSectionLocal;
190 static CComAutoCriticalSection s_criticalSectionBrowser;
191 static CComAutoCriticalSection s_criticalSectionWindow; 182 static CComAutoCriticalSection s_criticalSectionWindow;
192 183
193 // Async browser 184 // Async browser
194 static CComQIPtr<IWebBrowser2> s_asyncWebBrowser2; 185 static CComQIPtr<IWebBrowser2> s_asyncWebBrowser2;
195 static CComQIPtr<IWebBrowser2> GetAsyncBrowser(); 186 static CComQIPtr<IWebBrowser2> GetAsyncBrowser();
196 }; 187 };
197 188
198 OBJECT_ENTRY_AUTO(__uuidof(PluginClass), CPluginClass) 189 OBJECT_ENTRY_AUTO(__uuidof(PluginClass), CPluginClass)
199 190
200 191
201 #endif // _PLUGIN_CLASS_H_ 192 #endif // _PLUGIN_CLASS_H_
OLDNEW
« no previous file with comments | « no previous file | src/plugin/PluginClass.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld