Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 #include "PluginStdAfx.h" | 1 #include "PluginStdAfx.h" |
2 | 2 |
3 #include "PluginClass.h" | 3 #include "PluginClass.h" |
4 #include "PluginSettings.h" | 4 #include "PluginSettings.h" |
5 #include "PluginSystem.h" | 5 #include "PluginSystem.h" |
6 #ifdef SUPPORT_FILTER | 6 #ifdef SUPPORT_FILTER |
7 #include "PluginFilter.h" | 7 #include "PluginFilter.h" |
8 #endif | 8 #endif |
9 #include "PluginMimeFilterClient.h" | 9 #include "PluginMimeFilterClient.h" |
10 #include "PluginClient.h" | 10 #include "PluginClient.h" |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
216 | 216 |
217 DWORD WINAPI CPluginClass::StartInitObject(LPVOID thisPtr) | 217 DWORD WINAPI CPluginClass::StartInitObject(LPVOID thisPtr) |
218 { | 218 { |
219 if (thisPtr == NULL) | 219 if (thisPtr == NULL) |
220 return 0; | 220 return 0; |
221 if (!((CPluginClass*)thisPtr)->InitObject(true)) | 221 if (!((CPluginClass*)thisPtr)->InitObject(true)) |
222 { | 222 { |
223 ((CPluginClass*)thisPtr)->Unadvice(); | 223 ((CPluginClass*)thisPtr)->Unadvice(); |
224 } | 224 } |
225 | 225 |
226 if ((((CPluginClass*)thisPtr)->m_hPaneWnd == NULL) || (!((CPluginClass*)thisPt r)->IsStatusBarEnabled())) | |
227 { | |
228 ((CPluginClass*)thisPtr)->ShowStatusBar(); | |
229 } | |
230 return 0; | 226 return 0; |
231 } | 227 } |
232 | 228 |
233 | 229 |
234 | 230 |
235 // This gets called when a new browser window is created (which also triggers th e | 231 // This gets called when a new browser window is created (which also triggers th e |
236 // creation of this object). The pointer passed in should be to a IWebBrowser2 | 232 // creation of this object). The pointer passed in should be to a IWebBrowser2 |
237 // interface that represents the browser for the window. | 233 // interface that represents the browser for the window. |
238 // it is also called when a tab is closed, this unknownSite will be null | 234 // it is also called when a tab is closed, this unknownSite will be null |
239 // so we should handle that it is called this way several times during a session | 235 // so we should handle that it is called this way several times during a session |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
420 } | 416 } |
421 } | 417 } |
422 } | 418 } |
423 return trueth == 1; | 419 return trueth == 1; |
424 } | 420 } |
425 | 421 |
426 void CPluginClass::ShowStatusBar() | 422 void CPluginClass::ShowStatusBar() |
427 { | 423 { |
428 VARIANT_BOOL isVisible; | 424 VARIANT_BOOL isVisible; |
429 | 425 |
430 CPluginSettings* settings = CPluginSettings::GetInstance(); | |
431 | 426 |
432 CComQIPtr<IWebBrowser2> browser = GetAsyncBrowser(); | 427 CComQIPtr<IWebBrowser2> browser = GetAsyncBrowser(); |
433 if (browser) | 428 if (browser) |
434 { | 429 { |
435 HRESULT hr = S_OK; | 430 HRESULT hr = S_OK; |
436 hr = browser->get_StatusBar(&isVisible); | 431 hr = browser->get_StatusBar(&isVisible); |
437 if (SUCCEEDED(hr)) | 432 if (SUCCEEDED(hr)) |
438 { | 433 { |
439 if (!isVisible) | 434 if (!isVisible) |
440 { | 435 { |
441 if (!settings->GetStatusBarAsked()) | 436 SHANDLE_PTR pBrowserHWnd; |
437 browser->get_HWND((SHANDLE_PTR*)&pBrowserHWnd); | |
438 Dictionary* dictionary = Dictionary::GetInstance(); | |
439 | |
440 HKEY pHkey; | |
441 HKEY pHkeySub; | |
442 LSTATUS regRes = 0; | |
443 regRes = RegOpenCurrentUser(KEY_WRITE, &pHkey); | |
444 | |
445 // Do we have enough rights to enable a status bar? | |
446 if (regRes != 0) | |
442 { | 447 { |
443 SHANDLE_PTR pBrowserHWnd; | 448 // We use the tab window here and in the next few calls, since the bro wser window may still not be available |
444 browser->get_HWND((SHANDLE_PTR*)&pBrowserHWnd); | 449 LRESULT res = MessageBox((HWND)m_hTabWnd, |
445 Dictionary* dictionary = Dictionary::GetInstance(); | 450 dictionary->Lookup("status-bar", "error-text").c_str(), |
446 settings->SetStatusBarAsked(); | 451 dictionary->Lookup("status-bar", "error-title").c_str(), |
447 | 452 MB_OK); |
448 HKEY pHkey; | 453 return; |
449 HKEY pHkeySub; | 454 } |
450 LSTATUS regRes = 0; | 455 // Ask if a user wants to enable a status bar automatically |
451 regRes = RegOpenCurrentUser(KEY_WRITE, &pHkey); | 456 LRESULT res = MessageBox((HWND)m_hTabWnd, |
452 | 457 dictionary->Lookup("status-bar", "question").c_str(), |
453 // Do we have enough rights to enable a status bar? | 458 dictionary->Lookup("status-bar", "title").c_str(), |
454 if (regRes != 0) | 459 MB_YESNO); |
460 if (res == IDYES) | |
461 { | |
462 DWORD trueth = 1; | |
463 regRes = RegOpenKey(pHkey, L"Software\\Microsoft\\Internet Explorer\\M INIE", &pHkeySub); | |
464 regRes = RegSetValueEx(pHkeySub, L"ShowStatusBar", 0, REG_DWORD, (BYTE *)&trueth, sizeof(DWORD)); | |
465 regRes = RegCloseKey(pHkeySub); | |
466 regRes = RegOpenKey(pHkey, L"Software\\Microsoft\\Internet Explorer\\M ain", &pHkeySub); | |
467 regRes = RegSetValueEx(pHkeySub, L"StatusBarWeb", 0, REG_DWORD, (BYTE* )&trueth, sizeof(DWORD)); | |
468 regRes = RegCloseKey(pHkeySub); | |
469 hr = browser->put_StatusBar(TRUE); | |
470 if (FAILED(hr)) | |
455 { | 471 { |
456 // We use the tab window here and in the next few calls, since the b rowser window may still not be available | 472 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_PUT_STATUSBAR, "Class::Enable statusbar"); |
457 LRESULT res = MessageBox((HWND)m_hTabWnd, | |
458 dictionary->Lookup("status-bar", "error-text").c_str(), | |
459 dictionary->Lookup("status-bar", "error-title").c_str(), | |
460 MB_OK); | |
461 return; | |
462 } | 473 } |
463 // Ask if a user wants to enable a status bar automatically | 474 CreateStatusBarPane(); |
464 LRESULT res = MessageBox((HWND)m_hTabWnd, | 475 |
465 dictionary->Lookup("status-bar", "question").c_str(), | 476 // We need to restart the tab now, to enable the status bar properly |
466 dictionary->Lookup("status-bar", "title").c_str(), | 477 VARIANT vFlags; |
467 MB_YESNO); | 478 vFlags.vt = VT_I4; |
468 if (res == IDYES) | 479 vFlags.intVal = navOpenInNewTab; |
480 | |
481 CComBSTR curLoc; | |
482 browser->get_LocationURL(&curLoc); | |
483 HRESULT hr = browser->Navigate(curLoc, &vFlags, NULL, NULL, NULL); | |
484 if (FAILED(hr)) | |
469 { | 485 { |
470 DWORD trueth = 1; | 486 vFlags.intVal = navOpenInNewWindow; |
471 regRes = RegOpenKey(pHkey, L"Software\\Microsoft\\Internet Explorer\ \MINIE", &pHkeySub); | 487 |
472 regRes = RegSetValueEx(pHkeySub, L"ShowStatusBar", 0, REG_DWORD, (BY TE*)&trueth, sizeof(DWORD)); | 488 hr = browser->Navigate(CComBSTR(curLoc), &vFlags, NULL, NULL, NULL); |
473 regRes = RegCloseKey(pHkeySub); | |
474 regRes = RegOpenKey(pHkey, L"Software\\Microsoft\\Internet Explorer\ \Main", &pHkeySub); | |
475 regRes = RegSetValueEx(pHkeySub, L"StatusBarWeb", 0, REG_DWORD, (BYT E*)&trueth, sizeof(DWORD)); | |
476 regRes = RegCloseKey(pHkeySub); | |
477 hr = browser->put_StatusBar(TRUE); | |
478 if (FAILED(hr)) | 489 if (FAILED(hr)) |
479 { | 490 { |
480 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_PUT_STATUSBAR , "Class::Enable statusbar"); | 491 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_NAVIGATION, PLUGIN_ERROR_NAVIGATI ON, "Navigation::Failed") |
481 } | 492 } |
482 CreateStatusBarPane(); | |
483 | |
484 // We need to restart the tab now, to enable the status bar properly | |
485 VARIANT vFlags; | |
486 vFlags.vt = VT_I4; | |
487 vFlags.intVal = navOpenInNewTab; | |
488 | |
489 CComBSTR curLoc; | |
490 browser->get_LocationURL(&curLoc); | |
491 HRESULT hr = browser->Navigate(curLoc, &vFlags, NULL, NULL, NULL); | |
492 if (FAILED(hr)) | |
493 { | |
494 vFlags.intVal = navOpenInNewWindow; | |
495 | |
496 hr = browser->Navigate(CComBSTR(curLoc), &vFlags, NULL, NULL, NULL ); | |
497 if (FAILED(hr)) | |
498 { | |
499 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_NAVIGATION, PLUGIN_ERROR_NAVIGA TION, "Navigation::Failed") | |
500 } | |
501 } | |
502 browser->Quit(); | |
503 | |
504 } | 493 } |
494 browser->Quit(); | |
505 } | 495 } |
506 } | 496 } |
507 } | 497 } |
508 else | 498 else |
509 { | 499 { |
510 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_GET_STATUSBAR, "Class ::Get statusbar state"); | 500 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_GET_STATUSBAR, "Class ::Get statusbar state"); |
511 } | 501 } |
512 } | 502 } |
513 } | 503 } |
514 | 504 |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
815 | 805 |
816 // Create status pane | 806 // Create status pane |
817 if (bBHO) | 807 if (bBHO) |
818 { | 808 { |
819 if (!CreateStatusBarPane()) | 809 if (!CreateStatusBarPane()) |
820 { | 810 { |
821 return false; | 811 return false; |
822 } | 812 } |
823 } | 813 } |
824 | 814 |
815 if (CPluginClient::GetInstance()->IsFirstRun()) | |
816 { | |
817 CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)CPluginClass::FirstRunThrea d, NULL, NULL, NULL); | |
818 if ((m_hPaneWnd == NULL) || (!IsStatusBarEnabled())) | |
819 { | |
820 ShowStatusBar(); | |
821 } | |
822 | |
823 } | |
824 | |
825 CPluginSettings* settings = CPluginSettings::GetInstance(); | 825 CPluginSettings* settings = CPluginSettings::GetInstance(); |
826 return true; | 826 return true; |
827 } | 827 } |
828 | 828 |
829 bool CPluginClass::CreateStatusBarPane() | 829 bool CPluginClass::CreateStatusBarPane() |
830 { | 830 { |
831 DEBUG_GENERAL(L"Getting client"); | 831 DEBUG_GENERAL(L"Getting client"); |
832 | 832 |
833 CPluginClient* client = CPluginClient::GetInstance(); | 833 CPluginClient* client = CPluginClient::GetInstance(); |
834 | 834 |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
992 | 992 |
993 ::SendMessage(m_hStatusBarWnd, SB_GETPARTS, nPartCount, (LPARAM)pData); | 993 ::SendMessage(m_hStatusBarWnd, SB_GETPARTS, nPartCount, (LPARAM)pData); |
994 ::SendMessage(m_hStatusBarWnd, SB_SETPARTS, nPartCount, (LPARAM)pData); | 994 ::SendMessage(m_hStatusBarWnd, SB_SETPARTS, nPartCount, (LPARAM)pData); |
995 | 995 |
996 delete[] pData; | 996 delete[] pData; |
997 } | 997 } |
998 HDC hdc = GetWindowDC(m_hStatusBarWnd); | 998 HDC hdc = GetWindowDC(m_hStatusBarWnd); |
999 SendMessage(m_hStatusBarWnd, WM_PAINT, (WPARAM)hdc, 0); | 999 SendMessage(m_hStatusBarWnd, WM_PAINT, (WPARAM)hdc, 0); |
1000 ReleaseDC(m_hStatusBarWnd, hdc); | 1000 ReleaseDC(m_hStatusBarWnd, hdc); |
1001 | 1001 |
1002 if (CPluginClient::GetInstance()->GetIsFirstRun()) | |
Wladimir Palant
2013/07/11 11:58:10
Is CreateStatusBarPane() really the best place for
| |
1003 { | |
1004 CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)CPluginClass::FirstRunThrea d, NULL, NULL, NULL); | |
1005 } | |
1006 | |
1007 return true; | 1002 return true; |
1008 } | 1003 } |
1009 | 1004 |
1010 void CPluginClass::FirstRunThread() | 1005 void CPluginClass::FirstRunThread() |
1011 { | 1006 { |
1012 // IE may still be not ready to navigate. Try until it is. | 1007 CoInitialize(NULL); |
1013 VARIANT_BOOL isBusy = VARIANT_FALSE; | |
1014 while (GetAsyncBrowser()->get_Busy(&isBusy) == S_OK && isBusy != VARIANT_FALSE ) | |
1015 { | |
1016 Sleep(100); | |
1017 } | |
1018 VARIANT vFlags; | 1008 VARIANT vFlags; |
1019 vFlags.vt = VT_I4; | 1009 vFlags.vt = VT_I4; |
1020 vFlags.intVal = navOpenInNewTab; | 1010 vFlags.intVal = navOpenInNewTab; |
1021 | 1011 |
1022 READYSTATE readyState; | 1012 CComBSTR navigatePath = CComBSTR(FirstRunPageFileUrl().c_str()); |
1023 HRESULT hr; | |
1024 while ((hr = GetAsyncBrowser()->get_ReadyState(&readyState) == S_OK) && (ready State <= READYSTATE_LOADED)) | |
Wladimir Palant
2013/07/11 11:58:10
We are opening in a new tab, why do we care about
| |
1025 { | |
1026 Sleep(100); | |
1027 } | |
1028 CComBSTR bTest = CComBSTR(UserSettingsFirstRunPageUrl().c_str()); | |
1029 | 1013 |
1030 //Try 10 times, or until successful | 1014 HRESULT hr = GetAsyncBrowser()->Navigate(navigatePath, &vFlags, NULL, NULL, NU LL); |
1031 int numberOfAttempts = 0; | 1015 if (FAILED(hr)) |
1032 while ((hr != S_OK) && (numberOfAttempts < 10)) | 1016 { |
1033 { | 1017 vFlags.intVal = navOpenInNewWindow; |
1034 hr = GetAsyncBrowser()->Navigate(bTest, &vFlags, NULL, NULL, NULL); | 1018 hr = GetAsyncBrowser()->Navigate(navigatePath, &vFlags, NULL, NULL, NULL); |
1035 if (FAILED(hr)) | 1019 } |
1036 { | 1020 |
1037 vFlags.intVal = navOpenInNewWindow; | |
1038 | |
1039 hr = GetAsyncBrowser()->Navigate(bTest, &vFlags, NULL, NULL, NULL); | |
1040 if (FAILED(hr)) | |
1041 { | |
1042 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_NAVIGATION, PLUGIN_ERROR_NAVIGATION_SET TINGS, "Navigation::Failed") | |
Wladimir Palant
2013/07/11 11:58:10
This should probably be PLUGIN_ERROR_NAVIGATION_WE
| |
1043 } | |
1044 } | |
1045 Sleep(100); | |
1046 } | |
Wladimir Palant
2013/07/11 11:58:10
Does it really have to be that complicated? No oth
Oleksandr
2013/07/20 20:22:30
This turned out to be unnecessary after all. I've
| |
1047 if (FAILED(hr)) | 1021 if (FAILED(hr)) |
1048 { | 1022 { |
1049 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_NAVIGATION, PLUGIN_ERROR_NAVIGATION_WELCOME , "Navigation::Welcome page failed") | 1023 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_NAVIGATION, PLUGIN_ERROR_NAVIGATION_WELCOME , "Navigation::Welcome page failed") |
1050 } | 1024 } |
1051 } | 1025 } |
1052 void CPluginClass::CloseTheme() | 1026 void CPluginClass::CloseTheme() |
1053 { | 1027 { |
1054 if (m_hTheme) | 1028 if (m_hTheme) |
1055 { | 1029 { |
1056 if (pfnClose) | 1030 if (pfnClose) |
(...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1929 } | 1903 } |
1930 } | 1904 } |
1931 } | 1905 } |
1932 | 1906 |
1933 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT); | 1907 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT); |
1934 } | 1908 } |
1935 | 1909 |
1936 return hTabWnd; | 1910 return hTabWnd; |
1937 | 1911 |
1938 } | 1912 } |
LEFT | RIGHT |