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: Created July 11, 2013, 9:49 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 980 matching lines...) Expand 10 before | Expand all | Expand 10 after
991 INT *pData = new INT[nPartCount]; 991 INT *pData = new INT[nPartCount];
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
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
1001 return true; 1007 return true;
1002 } 1008 }
1003 1009
1010 void CPluginClass::FirstRunThread()
1011 {
1012 // IE may still be not ready to navigate. Try until it is.
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;
1019 vFlags.vt = VT_I4;
1020 vFlags.intVal = navOpenInNewTab;
1021
1022 READYSTATE readyState;
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
1030 //Try 10 times, or until successful
1031 int numberOfAttempts = 0;
1032 while ((hr != S_OK) && (numberOfAttempts < 10))
1033 {
1034 hr = GetAsyncBrowser()->Navigate(bTest, &vFlags, NULL, NULL, NULL);
1035 if (FAILED(hr))
1036 {
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))
1048 {
1049 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_NAVIGATION, PLUGIN_ERROR_NAVIGATION_WELCOME , "Navigation::Welcome page failed")
1050 }
1051 }
1004 void CPluginClass::CloseTheme() 1052 void CPluginClass::CloseTheme()
1005 { 1053 {
1006 if (m_hTheme) 1054 if (m_hTheme)
1007 { 1055 {
1008 if (pfnClose) 1056 if (pfnClose)
1009 { 1057 {
1010 pfnClose(m_hTheme); 1058 pfnClose(m_hTheme);
1011 } 1059 }
1012 1060
1013 m_hTheme = NULL; 1061 m_hTheme = NULL;
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after
1724 hr = browser->Navigate(BString(UserSettingsFileUrl()), &vFlags, NULL, NULL, NULL); 1772 hr = browser->Navigate(BString(UserSettingsFileUrl()), &vFlags, NULL, NULL, NULL);
1725 if (FAILED(hr)) 1773 if (FAILED(hr))
1726 { 1774 {
1727 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_NAVIGATION, PLUGIN_ERROR_NAVIGATION _SETTINGS, "Navigation::Failed") 1775 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_NAVIGATION, PLUGIN_ERROR_NAVIGATION _SETTINGS, "Navigation::Failed")
1728 } 1776 }
1729 } 1777 }
1730 } 1778 }
1731 #endif 1779 #endif
1732 } 1780 }
1733 break; 1781 break;
1734
1735
1736 // First run page
1737 case WM_LAUNCH_INFO:
Wladimir Palant 2013/07/11 11:58:10 You probably want to remove the definition of that
1738 {
1739 // Set the status bar visible, if it isn't
1740 // Otherwise the user won't see the icon the first time
1741
1742 if (wParam == 1)
1743 {
1744 // Redirect to welcome page
1745 VARIANT_BOOL isVisible;
1746 CComQIPtr<IWebBrowser2> browser = GetAsyncBrowser();
1747 if (browser)
1748 {
1749 HRESULT hr = S_OK;
1750
1751 hr = browser->get_StatusBar(&isVisible);
1752 if (SUCCEEDED(hr))
1753 {
1754 if (!isVisible)
1755 {
1756 Dictionary* dictionary = Dictionary::GetInstance();
1757
1758 LRESULT res = MessageBox(NULL,
1759 dictionary->Lookup("status-bar", "question").c_str(),
1760 dictionary->Lookup("status-bar", "title").c_str(),
1761 MB_YESNO);
1762 if (res == IDYES)
1763 {
1764 hr = browser->put_StatusBar(TRUE);
1765 if (FAILED(hr))
1766 {
1767 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_PUT_STATU SBAR, "Class::Enable statusbar");
1768 }
1769 }
1770 }
1771 }
1772 else
1773 {
1774 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_GET_STATUSBAR, "Class::Get statusbar state");
1775 }
1776
1777 CPluginSettings* settings = CPluginSettings::GetInstance();
1778
1779 //TODO: Navigate to first run page here
1780 /* hr = browser->Navigate(CComBSTR("FIRST_RUN_PAGE_URL"), NULL, NULL, NUL L, NULL);
1781 if (FAILED(hr))
1782 {
1783 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_NAVIGATION, PLUGIN_ERROR_NAVIGATION _WELCOME, "Navigation::Welcome page failed")
1784 }
1785 */
1786 }
1787 }
1788 else
1789 {
1790 // Redirect to info page
1791 CComQIPtr<IWebBrowser2> browser = GetAsyncBrowser();
1792 if (browser)
1793 {
1794 VARIANT vFlags;
1795 vFlags.vt = VT_I4;
1796 vFlags.intVal = navOpenInNewTab;
1797
1798 // TODO: Navigate to info page here or remove this clause
1799 /* HRESULT hr = browser->Navigate(CComBSTR(INFO_PAGE_URL), &vFlags, NUL L, NULL, NULL);
1800 if (FAILED(hr))
1801 {
1802 vFlags.intVal = navOpenInNewWindow;
1803
1804 hr = browser->Navigate(CComBSTR(httpRequest.GetUrl()), &vFlags, NULL , NULL, NULL);
1805 if (FAILED(hr))
1806 {
1807 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_NAVIGATION, PLUGIN_ERROR_NAVIGATI ON_INFO, "Navigation::Info page failed")
1808 }
1809 }
1810 */
1811 }
1812 }
1813 }
1814 break;
1815
1816 case WM_DESTROY: 1782 case WM_DESTROY:
1817 break; 1783 break;
1818 case SC_CLOSE: 1784 case SC_CLOSE:
1819 break; 1785 break;
1820 1786
1821 case WM_UPDATEUISTATE: 1787 case WM_UPDATEUISTATE:
1822 { 1788 {
1823 CPluginTab* tab = GetTab(::GetCurrentThreadId()); 1789 CPluginTab* tab = GetTab(::GetCurrentThreadId());
1824 if (tab) 1790 if (tab)
1825 { 1791 {
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
1963 } 1929 }
1964 } 1930 }
1965 } 1931 }
1966 1932
1967 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT); 1933 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT);
1968 } 1934 }
1969 1935
1970 return hTabWnd; 1936 return hTabWnd;
1971 1937
1972 } 1938 }
OLDNEW

Powered by Google App Engine
This is Rietveld