LEFT | RIGHT |
1 #include "PluginStdAfx.h" | 1 #include "PluginStdAfx.h" |
2 | 2 |
3 #include "PluginClass.h" | 3 #include "PluginClass.h" |
4 #include "COM_Value.h" | |
5 #include "PluginSettings.h" | 4 #include "PluginSettings.h" |
6 #include "PluginSystem.h" | 5 #include "PluginSystem.h" |
7 #ifdef SUPPORT_FILTER | 6 #ifdef SUPPORT_FILTER |
8 #include "PluginFilter.h" | 7 #include "PluginFilter.h" |
9 #endif | 8 #endif |
10 #include "PluginMimeFilterClient.h" | 9 #include "PluginMimeFilterClient.h" |
11 #include "PluginClient.h" | 10 #include "PluginClient.h" |
12 #include "PluginClientFactory.h" | 11 #include "PluginClientFactory.h" |
13 #include "PluginMutex.h" | 12 #include "PluginMutex.h" |
14 #include "sddl.h" | 13 #include "sddl.h" |
15 #include "PluginUtil.h" | 14 #include "PluginUtil.h" |
16 #include "PluginUserSettings.h" | 15 #include "PluginUserSettings.h" |
17 #include "../shared/Utils.h" | 16 #include "../shared/Utils.h" |
18 #include "../shared/Dictionary.h" | 17 #include "../shared/Dictionary.h" |
19 #include "../shared/IE_version.h" | |
20 #include <thread> | 18 #include <thread> |
21 | 19 |
22 #ifdef DEBUG_HIDE_EL | 20 #ifdef DEBUG_HIDE_EL |
23 DWORD profileTime = 0; | 21 DWORD profileTime = 0; |
24 #endif | 22 #endif |
25 | 23 |
26 typedef HANDLE (WINAPI *OPENTHEMEDATA)(HWND, LPCWSTR); | 24 typedef HANDLE (WINAPI *OPENTHEMEDATA)(HWND, LPCWSTR); |
27 typedef HRESULT (WINAPI *DRAWTHEMEBACKGROUND)(HANDLE, HDC, INT, INT, LPRECT, LPR
ECT); | 25 typedef HRESULT (WINAPI *DRAWTHEMEBACKGROUND)(HANDLE, HDC, INT, INT, LPRECT, LPR
ECT); |
28 typedef HRESULT (WINAPI *CLOSETHEMEDATA)(HANDLE); | 26 typedef HRESULT (WINAPI *CLOSETHEMEDATA)(HANDLE); |
29 | 27 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 m_hStatusBarWnd = NULL; | 85 m_hStatusBarWnd = NULL; |
88 m_hPaneWnd = NULL; | 86 m_hPaneWnd = NULL; |
89 m_nPaneWidth = 0; | 87 m_nPaneWidth = 0; |
90 m_pWndProcStatus = NULL; | 88 m_pWndProcStatus = NULL; |
91 m_hTheme = NULL; | 89 m_hTheme = NULL; |
92 m_isInitializedOk = false; | 90 m_isInitializedOk = false; |
93 | 91 |
94 | 92 |
95 m_tab = new CPluginTab(this); | 93 m_tab = new CPluginTab(this); |
96 | 94 |
97 CPluginSystem* system = CPluginSystem::GetInstance(); | 95 Dictionary::Create(GetBrowserLanguage()); |
98 | |
99 std::wstring locale((LPCWSTR)system->GetBrowserLanguage()); | |
100 Dictionary::Create(locale); | |
101 } | 96 } |
102 | 97 |
103 CPluginClass::~CPluginClass() | 98 CPluginClass::~CPluginClass() |
104 { | 99 { |
105 delete m_tab; | 100 delete m_tab; |
106 } | 101 } |
107 | 102 |
108 | 103 |
109 ///////////////////////////////////////////////////////////////////////////// | 104 ///////////////////////////////////////////////////////////////////////////// |
110 // Initialization | 105 // Initialization |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 return browser; | 207 return browser; |
213 } | 208 } |
214 | 209 |
215 CString CPluginClass::GetBrowserUrl() const | 210 CString CPluginClass::GetBrowserUrl() const |
216 { | 211 { |
217 CString url; | 212 CString url; |
218 | 213 |
219 CComQIPtr<IWebBrowser2> browser = GetBrowser(); | 214 CComQIPtr<IWebBrowser2> browser = GetBrowser(); |
220 if (browser) | 215 if (browser) |
221 { | 216 { |
222 AdblockPlus::COM::BSTR_Argument result; | 217 CComBSTR bstrURL; |
223 if (SUCCEEDED(browser->get_LocationURL(&result))) | 218 |
224 { | 219 if (SUCCEEDED(browser->get_LocationURL(&bstrURL))) |
225 url = to_CString(result); | 220 { |
| 221 url = bstrURL; |
226 CPluginClient::UnescapeUrl(url); | 222 CPluginClient::UnescapeUrl(url); |
227 } | 223 } |
228 } | 224 } |
229 else | 225 else |
230 { | 226 { |
231 url = m_tab->GetDocumentUrl(); | 227 url = m_tab->GetDocumentUrl(); |
232 } | 228 } |
233 | 229 |
234 return url; | 230 return url; |
235 } | 231 } |
(...skipping 13 matching lines...) Expand all Loading... |
249 | 245 |
250 | 246 |
251 // This gets called when a new browser window is created (which also triggers th
e | 247 // This gets called when a new browser window is created (which also triggers th
e |
252 // creation of this object). The pointer passed in should be to a IWebBrowser2 | 248 // creation of this object). The pointer passed in should be to a IWebBrowser2 |
253 // interface that represents the browser for the window. | 249 // interface that represents the browser for the window. |
254 // it is also called when a tab is closed, this unknownSite will be null | 250 // it is also called when a tab is closed, this unknownSite will be null |
255 // so we should handle that it is called this way several times during a session | 251 // so we should handle that it is called this way several times during a session |
256 STDMETHODIMP CPluginClass::SetSite(IUnknown* unknownSite) | 252 STDMETHODIMP CPluginClass::SetSite(IUnknown* unknownSite) |
257 { | 253 { |
258 CPluginSettings* settings = CPluginSettings::GetInstance(); | 254 CPluginSettings* settings = CPluginSettings::GetInstance(); |
259 CPluginSystem* system = CPluginSystem::GetInstance(); | |
260 | 255 |
261 MULTIPLE_VERSIONS_CHECK(); | 256 MULTIPLE_VERSIONS_CHECK(); |
262 | 257 |
263 if (unknownSite) | 258 if (unknownSite) |
264 { | 259 { |
265 | 260 |
266 DEBUG_GENERAL(L"============================================================
====================\nNEW TAB UI\n==============================================
==================================") | 261 DEBUG_GENERAL(L"============================================================
====================\nNEW TAB UI\n==============================================
==================================") |
267 | 262 |
268 HRESULT hr = ::CoInitialize(NULL); | 263 HRESULT hr = ::CoInitialize(NULL); |
269 if (FAILED(hr)) | 264 if (FAILED(hr)) |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 { | 495 { |
501 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_PUT_STATUSBAR,
"Class::Enable statusbar"); | 496 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_PUT_STATUSBAR,
"Class::Enable statusbar"); |
502 } | 497 } |
503 CreateStatusBarPane(); | 498 CreateStatusBarPane(); |
504 | 499 |
505 // We need to restart the tab now, to enable the status bar properly | 500 // We need to restart the tab now, to enable the status bar properly |
506 VARIANT vFlags; | 501 VARIANT vFlags; |
507 vFlags.vt = VT_I4; | 502 vFlags.vt = VT_I4; |
508 vFlags.intVal = navOpenInNewTab; | 503 vFlags.intVal = navOpenInNewTab; |
509 | 504 |
510 AdblockPlus::COM::BSTR_Argument curLoc; | 505 CComBSTR curLoc; |
511 browser->get_LocationURL(&curLoc); | 506 browser->get_LocationURL(&curLoc); |
512 HRESULT hr = browser->Navigate(curLoc, &vFlags, NULL, NULL, NULL); | 507 HRESULT hr = browser->Navigate(curLoc, &vFlags, NULL, NULL, NULL); |
513 if (FAILED(hr)) | 508 if (FAILED(hr)) |
514 { | 509 { |
515 vFlags.intVal = navOpenInNewWindow; | 510 vFlags.intVal = navOpenInNewWindow; |
516 | 511 |
517 hr = browser->Navigate(curLoc, &vFlags, NULL, NULL, NULL); | 512 hr = browser->Navigate(CComBSTR(curLoc), &vFlags, NULL, NULL, NULL); |
518 if (FAILED(hr)) | 513 if (FAILED(hr)) |
519 { | 514 { |
520 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_NAVIGATION, PLUGIN_ERROR_NAVIGATI
ON, "Navigation::Failed") | 515 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_NAVIGATION, PLUGIN_ERROR_NAVIGATI
ON, "Navigation::Failed") |
521 } | 516 } |
522 } | 517 } |
523 browser->Quit(); | 518 browser->Quit(); |
524 } | 519 } |
525 } | 520 } |
526 } | 521 } |
527 else | 522 else |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
678 case DISPID_BEFORENAVIGATE: | 673 case DISPID_BEFORENAVIGATE: |
679 DEBUG_NAVI("Navi::BeforeNavigate") | 674 DEBUG_NAVI("Navi::BeforeNavigate") |
680 return VARIANT_TRUE; | 675 return VARIANT_TRUE; |
681 case DISPID_COMMANDSTATECHANGE: | 676 case DISPID_COMMANDSTATECHANGE: |
682 if (m_hPaneWnd == NULL) | 677 if (m_hPaneWnd == NULL) |
683 { | 678 { |
684 CreateStatusBarPane(); | 679 CreateStatusBarPane(); |
685 } | 680 } |
686 else | 681 else |
687 { | 682 { |
688 if (AdblockPlus::IE::installed_major_version() > 6) | 683 if (CPluginClient::GetInstance()->GetIEVersion() > 6) |
689 { | 684 { |
690 RECT rect; | 685 RECT rect; |
691 BOOL rectRes = GetClientRect(m_hStatusBarWnd, &rect); | 686 BOOL rectRes = GetClientRect(m_hStatusBarWnd, &rect); |
692 if (rectRes == TRUE) | 687 if (rectRes == TRUE) |
693 { | 688 { |
694 MoveWindow(m_hPaneWnd, rect.right - 200, 0, m_nPaneWidth, rect.bottom
- rect.top, TRUE); | 689 MoveWindow(m_hPaneWnd, rect.right - 200, 0, m_nPaneWidth, rect.bottom
- rect.top, TRUE); |
695 } | 690 } |
696 } | 691 } |
697 } | 692 } |
698 break; | 693 break; |
(...skipping 27 matching lines...) Expand all Loading... |
726 DEBUG_NAVI("Navi::Document Complete") | 721 DEBUG_NAVI("Navi::Document Complete") |
727 | 722 |
728 CComQIPtr<IWebBrowser2> browser = GetBrowser(); | 723 CComQIPtr<IWebBrowser2> browser = GetBrowser(); |
729 | 724 |
730 if (browser && pDispParams->cArgs >= 2 && pDispParams->rgvarg[1].vt == VT_
DISPATCH) | 725 if (browser && pDispParams->cArgs >= 2 && pDispParams->rgvarg[1].vt == VT_
DISPATCH) |
731 { | 726 { |
732 CComQIPtr<IWebBrowser2> pBrowser = pDispParams->rgvarg[1].pdispVal; | 727 CComQIPtr<IWebBrowser2> pBrowser = pDispParams->rgvarg[1].pdispVal; |
733 if (pBrowser) | 728 if (pBrowser) |
734 { | 729 { |
735 CString url; | 730 CString url; |
736 AdblockPlus::COM::BSTR_Argument result; | 731 CComBSTR bstrUrl; |
737 if (SUCCEEDED(pBrowser->get_LocationURL(&result)) && !result.operator
std::wstring().empty()) | 732 if (SUCCEEDED(pBrowser->get_LocationURL(&bstrUrl)) && ::SysStringLen(b
strUrl) > 0) |
738 { | 733 { |
739 url = to_CString(result); | 734 url = bstrUrl; |
740 | 735 |
741 CPluginClient::UnescapeUrl(url); | 736 CPluginClient::UnescapeUrl(url); |
742 | 737 |
743 m_tab->OnDocumentComplete(browser, url, browser.IsEqualObject(pBrows
er)); | 738 m_tab->OnDocumentComplete(browser, url, browser.IsEqualObject(pBrows
er)); |
744 } | 739 } |
745 } | 740 } |
746 } | 741 } |
747 } | 742 } |
748 break; | 743 break; |
749 | 744 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
837 } | 832 } |
838 s_criticalSectionLocal.Unlock(); | 833 s_criticalSectionLocal.Unlock(); |
839 | 834 |
840 if (!GetAtomPaneClass()) | 835 if (!GetAtomPaneClass()) |
841 { | 836 { |
842 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_REGISTE
R_PANE_CLASS, "Class::InitObject - RegisterClassEx"); | 837 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_REGISTE
R_PANE_CLASS, "Class::InitObject - RegisterClassEx"); |
843 return false; | 838 return false; |
844 } | 839 } |
845 } | 840 } |
846 | 841 |
847 int ieVersion = AdblockPlus::IE::installed_major_version(); | 842 |
| 843 int ieVersion = CPluginClient::GetInstance()->GetIEVersion(); |
848 // Create status pane | 844 // Create status pane |
849 if (bBHO && ieVersion > 6 && !CreateStatusBarPane()) | 845 if (bBHO && ieVersion > 6 && !CreateStatusBarPane()) |
850 { | 846 { |
851 return false; | 847 return false; |
852 } | 848 } |
853 | 849 |
854 if (CPluginClient::GetInstance()->IsFirstRun()) | 850 if (CPluginClient::GetInstance()->IsFirstRun()) |
855 { | 851 { |
856 // IE6 can't be accessed from another thread, execute in current thread | 852 // IE6 can't be accessed from another thread, execute in current thread |
857 if (ieVersion < 7) | 853 if (ieVersion < 7) |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1035 return true; | 1031 return true; |
1036 } | 1032 } |
1037 | 1033 |
1038 void CPluginClass::FirstRunThread() | 1034 void CPluginClass::FirstRunThread() |
1039 { | 1035 { |
1040 CoInitialize(NULL); | 1036 CoInitialize(NULL); |
1041 VARIANT vFlags; | 1037 VARIANT vFlags; |
1042 vFlags.vt = VT_I4; | 1038 vFlags.vt = VT_I4; |
1043 vFlags.intVal = navOpenInNewTab; | 1039 vFlags.intVal = navOpenInNewTab; |
1044 | 1040 |
1045 AdblockPlus::COM::BSTR_Argument navigatePath(FirstRunPageFileUrl()); | 1041 CComBSTR navigatePath = CComBSTR(FirstRunPageFileUrl().c_str()); |
| 1042 |
1046 HRESULT hr = GetAsyncBrowser()->Navigate(navigatePath, &vFlags, NULL, NULL, NU
LL); | 1043 HRESULT hr = GetAsyncBrowser()->Navigate(navigatePath, &vFlags, NULL, NULL, NU
LL); |
1047 if (FAILED(hr)) | 1044 if (FAILED(hr)) |
1048 { | 1045 { |
1049 vFlags.intVal = navOpenInNewWindow; | 1046 vFlags.intVal = navOpenInNewWindow; |
1050 hr = GetAsyncBrowser()->Navigate(navigatePath, &vFlags, NULL, NULL, NULL); | 1047 hr = GetAsyncBrowser()->Navigate(navigatePath, &vFlags, NULL, NULL, NULL); |
1051 } | 1048 } |
1052 | 1049 |
1053 if (FAILED(hr)) | 1050 if (FAILED(hr)) |
1054 { | 1051 { |
1055 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_NAVIGATION, PLUGIN_ERROR_NAVIGATION_WELCOME
, "Navigation::Welcome page failed") | 1052 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_NAVIGATION, PLUGIN_ERROR_NAVIGATION_WELCOME
, "Navigation::Welcome page failed") |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1256 CloseHandle(hToken); | 1253 CloseHandle(hToken); |
1257 } | 1254 } |
1258 | 1255 |
1259 return fRet; | 1256 return fRet; |
1260 } | 1257 } |
1261 | 1258 |
1262 void CPluginClass::DisplayPluginMenu(HMENU hMenu, int nToolbarCmdID, POINT pt, U
INT nMenuFlags) | 1259 void CPluginClass::DisplayPluginMenu(HMENU hMenu, int nToolbarCmdID, POINT pt, U
INT nMenuFlags) |
1263 { | 1260 { |
1264 CPluginClient* client = CPluginClient::GetInstance(); | 1261 CPluginClient* client = CPluginClient::GetInstance(); |
1265 | 1262 |
1266 CPluginSystem* system = CPluginSystem::GetInstance(); | |
1267 | |
1268 // Create menu parent window | 1263 // Create menu parent window |
1269 HWND hMenuWnd = ::CreateWindowEx( | 1264 HWND hMenuWnd = ::CreateWindowEx( |
1270 NULL, | 1265 NULL, |
1271 MAKEINTATOM(GetAtomPaneClass()), | 1266 MAKEINTATOM(GetAtomPaneClass()), |
1272 L"", | 1267 L"", |
1273 0, | 1268 0, |
1274 0,0,0,0, | 1269 0,0,0,0, |
1275 NULL, | 1270 NULL, |
1276 NULL, | 1271 NULL, |
1277 _Module.m_hInst, | 1272 _Module.m_hInst, |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1665 | 1660 |
1666 LRESULT CALLBACK CPluginClass::PaneWindowProc(HWND hWnd, UINT message, WPARAM wP
aram, LPARAM lParam) | 1661 LRESULT CALLBACK CPluginClass::PaneWindowProc(HWND hWnd, UINT message, WPARAM wP
aram, LPARAM lParam) |
1667 { | 1662 { |
1668 // Find tab | 1663 // Find tab |
1669 CPluginClass *pClass = FindInstance(GetParent(hWnd)); | 1664 CPluginClass *pClass = FindInstance(GetParent(hWnd)); |
1670 if (!pClass) | 1665 if (!pClass) |
1671 { | 1666 { |
1672 return ::DefWindowProc(hWnd, message, wParam, lParam); | 1667 return ::DefWindowProc(hWnd, message, wParam, lParam); |
1673 } | 1668 } |
1674 | 1669 |
1675 CPluginSystem* system = CPluginSystem::GetInstance(); | |
1676 | |
1677 // Process message | 1670 // Process message |
1678 switch (message) | 1671 switch (message) |
1679 { | 1672 { |
1680 | 1673 |
1681 case WM_SETCURSOR: | 1674 case WM_SETCURSOR: |
1682 { | 1675 { |
1683 ::SetCursor(::LoadCursor(NULL, IDC_ARROW)); | 1676 ::SetCursor(::LoadCursor(NULL, IDC_ARROW)); |
1684 return TRUE; | 1677 return TRUE; |
1685 } | 1678 } |
1686 case WM_PAINT: | 1679 case WM_PAINT: |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1992 } | 1985 } |
1993 } | 1986 } |
1994 } | 1987 } |
1995 | 1988 |
1996 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT); | 1989 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT); |
1997 } | 1990 } |
1998 | 1991 |
1999 return hTabWnd; | 1992 return hTabWnd; |
2000 | 1993 |
2001 } | 1994 } |
LEFT | RIGHT |