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

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

Issue 11043057: First run page triggering (Closed)
Patch Set: Ditching the statusbarasked Created July 22, 2013, 9:01 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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;
Oleksandr 2013/07/22 09:04:51 Just removed this if and fixed the formatting
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(),
452 MB_OK);
453 return;
454 }
455 // Ask if a user wants to enable a status bar automatically
456 LRESULT res = MessageBox((HWND)m_hTabWnd,
457 dictionary->Lookup("status-bar", "question").c_str(),
458 dictionary->Lookup("status-bar", "title").c_str(),
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))
471 {
472 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_PUT_STATUSBAR, "Class::Enable statusbar");
473 }
474 CreateStatusBarPane();
447 475
448 HKEY pHkey; 476 // We need to restart the tab now, to enable the status bar properly
449 HKEY pHkeySub; 477 VARIANT vFlags;
450 LSTATUS regRes = 0; 478 vFlags.vt = VT_I4;
451 regRes = RegOpenCurrentUser(KEY_WRITE, &pHkey); 479 vFlags.intVal = navOpenInNewTab;
452 480
453 // Do we have enough rights to enable a status bar? 481 CComBSTR curLoc;
454 if (regRes != 0) 482 browser->get_LocationURL(&curLoc);
483 HRESULT hr = browser->Navigate(curLoc, &vFlags, NULL, NULL, NULL);
484 if (FAILED(hr))
455 { 485 {
456 // We use the tab window here and in the next few calls, since the b rowser window may still not be available 486 vFlags.intVal = navOpenInNewWindow;
457 LRESULT res = MessageBox((HWND)m_hTabWnd, 487
458 dictionary->Lookup("status-bar", "error-text").c_str(), 488 hr = browser->Navigate(CComBSTR(curLoc), &vFlags, NULL, NULL, NULL);
459 dictionary->Lookup("status-bar", "error-title").c_str(),
460 MB_OK);
461 return;
462 }
463 // Ask if a user wants to enable a status bar automatically
464 LRESULT res = MessageBox((HWND)m_hTabWnd,
465 dictionary->Lookup("status-bar", "question").c_str(),
466 dictionary->Lookup("status-bar", "title").c_str(),
467 MB_YESNO);
468 if (res == IDYES)
469 {
470 DWORD trueth = 1;
471 regRes = RegOpenKey(pHkey, L"Software\\Microsoft\\Internet Explorer\ \MINIE", &pHkeySub);
472 regRes = RegSetValueEx(pHkeySub, L"ShowStatusBar", 0, REG_DWORD, (BY TE*)&trueth, sizeof(DWORD));
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 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
818 { 808 {
819 if (!CreateStatusBarPane()) 809 if (!CreateStatusBarPane())
820 { 810 {
821 return false; 811 return false;
822 } 812 }
823 } 813 }
824 814
825 if (CPluginClient::GetInstance()->IsFirstRun()) 815 if (CPluginClient::GetInstance()->IsFirstRun())
826 { 816 {
827 CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)CPluginClass::FirstRunThrea d, NULL, NULL, NULL); 817 CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)CPluginClass::FirstRunThrea d, NULL, NULL, NULL);
818 if ((m_hPaneWnd == NULL) || (!IsStatusBarEnabled()))
819 {
820 ShowStatusBar();
821 }
822
828 } 823 }
829 824
830 CPluginSettings* settings = CPluginSettings::GetInstance(); 825 CPluginSettings* settings = CPluginSettings::GetInstance();
831 return true; 826 return true;
832 } 827 }
833 828
834 bool CPluginClass::CreateStatusBarPane() 829 bool CPluginClass::CreateStatusBarPane()
835 { 830 {
836 DEBUG_GENERAL(L"Getting client"); 831 DEBUG_GENERAL(L"Getting client");
837 832
(...skipping 1074 matching lines...) Expand 10 before | Expand all | Expand 10 after
1912 } 1907 }
1913 } 1908 }
1914 } 1909 }
1915 1910
1916 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT); 1911 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT);
1917 } 1912 }
1918 1913
1919 return hTabWnd; 1914 return hTabWnd;
1920 1915
1921 } 1916 }
OLDNEW

Powered by Google App Engine
This is Rietveld