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

Unified Diff: src/plugin/PluginClass.cpp

Issue 11043057: First run page triggering (Closed)
Patch Set: Created July 11, 2013, 9:49 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/plugin/PluginClass.cpp
===================================================================
--- a/src/plugin/PluginClass.cpp
+++ b/src/plugin/PluginClass.cpp
@@ -998,9 +998,57 @@
HDC hdc = GetWindowDC(m_hStatusBarWnd);
SendMessage(m_hStatusBarWnd, WM_PAINT, (WPARAM)hdc, 0);
ReleaseDC(m_hStatusBarWnd, hdc);
+
+ if (CPluginClient::GetInstance()->GetIsFirstRun())
Wladimir Palant 2013/07/11 11:58:10 Is CreateStatusBarPane() really the best place for
+ {
+ CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)CPluginClass::FirstRunThread, NULL, NULL, NULL);
+ }
+
return true;
}
+void CPluginClass::FirstRunThread()
+{
+ // IE may still be not ready to navigate. Try until it is.
+ VARIANT_BOOL isBusy = VARIANT_FALSE;
+ while (GetAsyncBrowser()->get_Busy(&isBusy) == S_OK && isBusy != VARIANT_FALSE)
+ {
+ Sleep(100);
+ }
+ VARIANT vFlags;
+ vFlags.vt = VT_I4;
+ vFlags.intVal = navOpenInNewTab;
+
+ READYSTATE readyState;
+ HRESULT hr;
+ while ((hr = GetAsyncBrowser()->get_ReadyState(&readyState) == S_OK) && (readyState <= READYSTATE_LOADED))
Wladimir Palant 2013/07/11 11:58:10 We are opening in a new tab, why do we care about
+ {
+ Sleep(100);
+ }
+ CComBSTR bTest = CComBSTR(UserSettingsFirstRunPageUrl().c_str());
+
+ //Try 10 times, or until successful
+ int numberOfAttempts = 0;
+ while ((hr != S_OK) && (numberOfAttempts < 10))
+ {
+ hr = GetAsyncBrowser()->Navigate(bTest, &vFlags, NULL, NULL, NULL);
+ if (FAILED(hr))
+ {
+ vFlags.intVal = navOpenInNewWindow;
+
+ hr = GetAsyncBrowser()->Navigate(bTest, &vFlags, NULL, NULL, NULL);
+ if (FAILED(hr))
+ {
+ DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_NAVIGATION, PLUGIN_ERROR_NAVIGATION_SETTINGS, "Navigation::Failed")
Wladimir Palant 2013/07/11 11:58:10 This should probably be PLUGIN_ERROR_NAVIGATION_WE
+ }
+ }
+ Sleep(100);
+ }
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
+ if (FAILED(hr))
+ {
+ DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_NAVIGATION, PLUGIN_ERROR_NAVIGATION_WELCOME, "Navigation::Welcome page failed")
+ }
+}
void CPluginClass::CloseTheme()
{
if (m_hTheme)
@@ -1731,88 +1779,6 @@
#endif
}
break;
-
-
- // First run page
- case WM_LAUNCH_INFO:
Wladimir Palant 2013/07/11 11:58:10 You probably want to remove the definition of that
- {
- // Set the status bar visible, if it isn't
- // Otherwise the user won't see the icon the first time
-
- if (wParam == 1)
- {
- // Redirect to welcome page
- VARIANT_BOOL isVisible;
- CComQIPtr<IWebBrowser2> browser = GetAsyncBrowser();
- if (browser)
- {
- HRESULT hr = S_OK;
-
- hr = browser->get_StatusBar(&isVisible);
- if (SUCCEEDED(hr))
- {
- if (!isVisible)
- {
- Dictionary* dictionary = Dictionary::GetInstance();
-
- LRESULT res = MessageBox(NULL,
- dictionary->Lookup("status-bar", "question").c_str(),
- dictionary->Lookup("status-bar", "title").c_str(),
- MB_YESNO);
- if (res == IDYES)
- {
- hr = browser->put_StatusBar(TRUE);
- if (FAILED(hr))
- {
- DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_PUT_STATUSBAR, "Class::Enable statusbar");
- }
- }
- }
- }
- else
- {
- DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_GET_STATUSBAR, "Class::Get statusbar state");
- }
-
- CPluginSettings* settings = CPluginSettings::GetInstance();
-
- //TODO: Navigate to first run page here
-/* hr = browser->Navigate(CComBSTR("FIRST_RUN_PAGE_URL"), NULL, NULL, NULL, NULL);
- if (FAILED(hr))
- {
- DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_NAVIGATION, PLUGIN_ERROR_NAVIGATION_WELCOME, "Navigation::Welcome page failed")
- }
- */
- }
- }
- else
- {
- // Redirect to info page
- CComQIPtr<IWebBrowser2> browser = GetAsyncBrowser();
- if (browser)
- {
- VARIANT vFlags;
- vFlags.vt = VT_I4;
- vFlags.intVal = navOpenInNewTab;
-
- // TODO: Navigate to info page here or remove this clause
-/* HRESULT hr = browser->Navigate(CComBSTR(INFO_PAGE_URL), &vFlags, NULL, NULL, NULL);
- if (FAILED(hr))
- {
- vFlags.intVal = navOpenInNewWindow;
-
- hr = browser->Navigate(CComBSTR(httpRequest.GetUrl()), &vFlags, NULL, NULL, NULL);
- if (FAILED(hr))
- {
- DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_NAVIGATION, PLUGIN_ERROR_NAVIGATION_INFO, "Navigation::Info page failed")
- }
- }
- */
- }
- }
- }
- break;
-
case WM_DESTROY:
break;
case SC_CLOSE:

Powered by Google App Engine
This is Rietveld