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

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

Issue 29332959: Issue #1173 - Protect more entry points with try-catch blocks (Closed)
Patch Set: Created Dec. 22, 2015, 2:13 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 953 matching lines...) Expand 10 before | Expand all | Expand 10 after
964 if (it != s_threadInstances.end()) 964 if (it != s_threadInstances.end())
965 { 965 {
966 tab = it->second->m_tab; 966 tab = it->second->m_tab;
967 } 967 }
968 } 968 }
969 s_criticalSectionLocal.Unlock(); 969 s_criticalSectionLocal.Unlock();
970 970
971 return tab; 971 return tab;
972 } 972 }
973 973
974 974 // Entry point
975 STDMETHODIMP CPluginClass::QueryStatus(const GUID* pguidCmdGroup, ULONG cCmds, O LECMD prgCmds[], OLECMDTEXT* pCmdText) 975 STDMETHODIMP CPluginClass::QueryStatus(const GUID* pguidCmdGroup, ULONG cCmds, O LECMD prgCmds[], OLECMDTEXT* pCmdText)
976 { 976 {
977 if (cCmds == 0) return E_INVALIDARG; 977 try
978 if (prgCmds == 0) return E_POINTER; 978 {
979 if (cCmds == 0) return E_INVALIDARG;
980 if (prgCmds == 0) return E_POINTER;
979 981
980 prgCmds[0].cmdf = OLECMDF_ENABLED; 982 prgCmds[0].cmdf = OLECMDF_ENABLED;
981 983 }
984 catch (...)
985 {
986 return E_FAIL;
987 }
982 return S_OK; 988 return S_OK;
983 } 989 }
984 990
985 HMENU CPluginClass::CreatePluginMenu(const std::wstring& url) 991 HMENU CPluginClass::CreatePluginMenu(const std::wstring& url)
986 { 992 {
987 DEBUG_GENERAL("CreatePluginMenu"); 993 DEBUG_GENERAL("CreatePluginMenu");
988 HINSTANCE hInstance = _AtlBaseModule.GetModuleInstance(); 994 HINSTANCE hInstance = _AtlBaseModule.GetModuleInstance();
989 995
990 HMENU hMenu = ::LoadMenu(hInstance, MAKEINTRESOURCE(IDR_MENU1)); 996 HMENU hMenu = ::LoadMenu(hInstance, MAKEINTRESOURCE(IDR_MENU1));
991 997
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
1173 ctext = dictionary->Lookup("menu", "menu-settings"); 1179 ctext = dictionary->Lookup("menu", "menu-settings");
1174 fmii.fMask = MIIM_STATE | MIIM_STRING; 1180 fmii.fMask = MIIM_STATE | MIIM_STRING;
1175 fmii.fState = MFS_ENABLED; 1181 fmii.fState = MFS_ENABLED;
1176 fmii.dwTypeData = const_cast<LPWSTR>(ctext.c_str()); 1182 fmii.dwTypeData = const_cast<LPWSTR>(ctext.c_str());
1177 fmii.cch = static_cast<UINT>(ctext.size()); 1183 fmii.cch = static_cast<UINT>(ctext.size());
1178 ::SetMenuItemInfoW(hMenu, ID_MENU_SETTINGS, FALSE, &fmii); 1184 ::SetMenuItemInfoW(hMenu, ID_MENU_SETTINGS, FALSE, &fmii);
1179 1185
1180 return true; 1186 return true;
1181 } 1187 }
1182 1188
1183 1189 // Entry point
1184 STDMETHODIMP CPluginClass::Exec(const GUID*, DWORD nCmdID, DWORD, VARIANTARG*, V ARIANTARG*) 1190 STDMETHODIMP CPluginClass::Exec(const GUID*, DWORD nCmdID, DWORD, VARIANTARG*, V ARIANTARG*)
1185 { 1191 {
1186 HWND hBrowserWnd = GetBrowserHWND(); 1192 try
1187 if (!hBrowserWnd)
1188 { 1193 {
1189 return E_FAIL; 1194 HWND hBrowserWnd = GetBrowserHWND();
1190 } 1195 if (!hBrowserWnd)
1196 {
1197 return E_FAIL;
1198 }
1191 1199
1192 // Create menu 1200 // Create menu
1193 HMENU hMenu = CreatePluginMenu(m_tab->GetDocumentUrl()); 1201 HMENU hMenu = CreatePluginMenu(m_tab->GetDocumentUrl());
1194 if (!hMenu) 1202 if (!hMenu)
1195 { 1203 {
1196 return E_FAIL; 1204 return E_FAIL;
1197 } 1205 }
1198 1206
1199 // Check if button in toolbar was pressed 1207 // Check if button in toolbar was pressed
1200 int nIDCommand = -1; 1208 int nIDCommand = -1;
1201 BOOL bRightAlign = FALSE; 1209 BOOL bRightAlign = FALSE;
1202 1210
1203 POINT pt; 1211 POINT pt;
1204 GetCursorPos(&pt); 1212 GetCursorPos(&pt);
1205 1213
1206 HWND hWndToolBar = ::WindowFromPoint(pt); 1214 HWND hWndToolBar = ::WindowFromPoint(pt);
1207 1215
1208 DWORD nProcessId; 1216 DWORD nProcessId;
1209 ::GetWindowThreadProcessId(hWndToolBar, &nProcessId); 1217 ::GetWindowThreadProcessId(hWndToolBar, &nProcessId);
1210 1218
1211 if (hWndToolBar && ::GetCurrentProcessId() == nProcessId) 1219 if (hWndToolBar && ::GetCurrentProcessId() == nProcessId)
1212 { 1220 {
1213 ::ScreenToClient(hWndToolBar, &pt); 1221 ::ScreenToClient(hWndToolBar, &pt);
1214 int nButton = (int)::SendMessage(hWndToolBar, TB_HITTEST, 0, (LPARAM)&pt); 1222 int nButton = (int)::SendMessage(hWndToolBar, TB_HITTEST, 0, (LPARAM)&pt);
1215 1223
1216 if (nButton > 0) 1224 if (nButton > 0)
1217 { 1225 {
1218 TBBUTTON pTBBtn = {}; 1226 TBBUTTON pTBBtn = {};
1219 1227
1220 if (SendMessage(hWndToolBar, TB_GETBUTTON, nButton, (LPARAM)&pTBBtn)) 1228 if (SendMessage(hWndToolBar, TB_GETBUTTON, nButton, (LPARAM)&pTBBtn))
1221 { 1229 {
1222 RECT rcButton; 1230 RECT rcButton;
1223 nIDCommand = pTBBtn.idCommand; 1231 nIDCommand = pTBBtn.idCommand;
1224 1232
1225 if (SendMessage(hWndToolBar, TB_GETRECT, nIDCommand, (LPARAM)&rcButton)) 1233 if (SendMessage(hWndToolBar, TB_GETRECT, nIDCommand, (LPARAM)&rcButton ))
1226 {
1227 pt.x = rcButton.left;
1228 pt.y = rcButton.bottom;
1229 ClientToScreen(hWndToolBar, &pt);
1230
1231 RECT rcWorkArea;
1232 SystemParametersInfo(SPI_GETWORKAREA, 0, (LPVOID)&rcWorkArea, 0);
1233 if (rcWorkArea.right - pt.x < 150)
1234 { 1234 {
1235 bRightAlign = TRUE; 1235 pt.x = rcButton.left;
1236 pt.x = rcButton.right;
1237 pt.y = rcButton.bottom; 1236 pt.y = rcButton.bottom;
1238 ClientToScreen(hWndToolBar, &pt); 1237 ClientToScreen(hWndToolBar, &pt);
1238
1239 RECT rcWorkArea;
1240 SystemParametersInfo(SPI_GETWORKAREA, 0, (LPVOID)&rcWorkArea, 0);
1241 if (rcWorkArea.right - pt.x < 150)
1242 {
1243 bRightAlign = TRUE;
1244 pt.x = rcButton.right;
1245 pt.y = rcButton.bottom;
1246 ClientToScreen(hWndToolBar, &pt);
1247 }
1239 } 1248 }
1240 } 1249 }
1241 } 1250 }
1251 else
1252 {
1253 GetCursorPos(&pt);
1254 }
1255 }
1256
1257 // Display menu
1258 UINT nFlags = 0;
1259 if (bRightAlign)
1260 {
1261 nFlags |= TPM_RIGHTALIGN;
1242 } 1262 }
1243 else 1263 else
1244 { 1264 {
1245 GetCursorPos(&pt); 1265 nFlags |= TPM_LEFTALIGN;
1246 } 1266 }
1267
1268 DisplayPluginMenu(hMenu, nIDCommand, pt, nFlags);
1247 } 1269 }
1248 1270 catch (...)
1249 // Display menu
1250 UINT nFlags = 0;
1251 if (bRightAlign)
1252 { 1271 {
1253 nFlags |= TPM_RIGHTALIGN; 1272 return E_FAIL; //
Oleksandr 2016/01/04 10:46:13 Nit: there was a comment intended here?
Eric 2016/01/04 16:44:24 Yes. Added.
1254 } 1273 }
1255 else
1256 {
1257 nFlags |= TPM_LEFTALIGN;
1258 }
1259
1260 DisplayPluginMenu(hMenu, nIDCommand, pt, nFlags);
1261 1274
1262 return S_OK; 1275 return S_OK;
1263 } 1276 }
1264 1277
1265 ///////////////////////////////////////////////////////////////////////////// 1278 // Entry point
1266 // Window procedures
1267
1268 LRESULT CALLBACK CPluginClass::NewStatusProc(HWND hWnd, UINT message, WPARAM wPa ram, LPARAM lParam) 1279 LRESULT CALLBACK CPluginClass::NewStatusProc(HWND hWnd, UINT message, WPARAM wPa ram, LPARAM lParam)
1269 { 1280 {
1270 // Find tab 1281 try
1271 CPluginClass *pClass = FindInstance(hWnd);
1272 if (!pClass)
1273 { 1282 {
1274 return DefWindowProc(hWnd, message, wParam, lParam); 1283 // Find tab
1275 } 1284 CPluginClass *pClass = FindInstance(hWnd);
1285 if (!pClass)
1286 {
1287 return DefWindowProc(hWnd, message, wParam, lParam);
Eric 2016/01/04 16:44:24 Race condition here.
1288 }
1276 1289
1277 // Process message 1290 // Process message
1278 switch (message) 1291 switch (message)
1279 { 1292 {
1280 case SB_SIMPLE: 1293 case SB_SIMPLE:
1281 { 1294 {
1282 ShowWindow(pClass->m_hPaneWnd, !wParam); 1295 ShowWindow(pClass->m_hPaneWnd, !wParam);
1283 break; 1296 break;
1284 } 1297 }
1285 1298
1286 case WM_SYSCOLORCHANGE: 1299 case WM_SYSCOLORCHANGE:
1287 { 1300 {
1288 pClass->UpdateTheme(); 1301 pClass->UpdateTheme();
1289 break; 1302 break;
1290 } 1303 }
1291 1304
1292 case SB_SETPARTS: 1305 case SB_SETPARTS:
1293 { 1306 {
1294 if (!lParam || !wParam || wParam > 30 || !IsWindow(pClass->m_hPaneWnd)) 1307 if (!lParam || !wParam || wParam > 30 || !IsWindow(pClass->m_hPaneWnd))
1295 { 1308 {
1296 return CallWindowProc(pClass->m_pWndProcStatus, hWnd, message, wParam, l Param); 1309 return CallWindowProc(pClass->m_pWndProcStatus, hWnd, message, wParam, l Param);
1297 } 1310 }
1298 1311
1299 WPARAM nParts = wParam; 1312 WPARAM nParts = wParam;
1300 if (STATUSBAR_PANE_NUMBER >= nParts) 1313 if (STATUSBAR_PANE_NUMBER >= nParts)
1301 { 1314 {
1302 return CallWindowProc(pClass->m_pWndProcStatus, hWnd, message, wParam, l Param); 1315 return CallWindowProc(pClass->m_pWndProcStatus, hWnd, message, wParam, l Param);
1303 } 1316 }
1304 1317
1305 HLOCAL hLocal = LocalAlloc(LHND, sizeof(int) * (nParts+1)); 1318 HLOCAL hLocal = LocalAlloc(LHND, sizeof(int) * (nParts + 1));
1306 LPINT lpParts = (LPINT)LocalLock(hLocal); 1319 LPINT lpParts = (LPINT)LocalLock(hLocal);
1307 memcpy(lpParts, (void*)lParam, wParam*sizeof(int)); 1320 memcpy(lpParts, (void*)lParam, wParam*sizeof(int));
1308 1321
1309 for (unsigned i = 0; i < STATUSBAR_PANE_NUMBER; i++) 1322 for (unsigned i = 0; i < STATUSBAR_PANE_NUMBER; i++)
1310 { 1323 {
1311 lpParts[i] -= pClass->m_nPaneWidth; 1324 lpParts[i] -= pClass->m_nPaneWidth;
1312 } 1325 }
1313 LRESULT hRet = CallWindowProc(pClass->m_pWndProcStatus, hWnd, message, wPa ram, (LPARAM)lpParts); 1326 LRESULT hRet = CallWindowProc(pClass->m_pWndProcStatus, hWnd, message, wPa ram, (LPARAM)lpParts);
1314 1327
1315 AdblockPlus::Rectangle rcPane; 1328 AdblockPlus::Rectangle rcPane;
1316 ::SendMessage(hWnd, SB_GETRECT, STATUSBAR_PANE_NUMBER, (LPARAM)&rcPane); 1329 ::SendMessage(hWnd, SB_GETRECT, STATUSBAR_PANE_NUMBER, (LPARAM)&rcPane);
1317 1330
1318 AdblockPlus::Rectangle rcClient; 1331 AdblockPlus::Rectangle rcClient;
1319 ::GetClientRect(hWnd, &rcClient); 1332 ::GetClientRect(hWnd, &rcClient);
1320 1333
1321 ::MoveWindow( 1334 ::MoveWindow(
1322 pClass->m_hPaneWnd, 1335 pClass->m_hPaneWnd,
1323 lpParts[STATUSBAR_PANE_NUMBER] - pClass->m_nPaneWidth, 1336 lpParts[STATUSBAR_PANE_NUMBER] - pClass->m_nPaneWidth,
1324 0, 1337 0,
1325 pClass->m_nPaneWidth, 1338 pClass->m_nPaneWidth,
1326 rcClient.Height(), 1339 rcClient.Height(),
1327 TRUE); 1340 TRUE);
1328 1341
1329 ::LocalFree(hLocal); 1342 ::LocalFree(hLocal);
1330 1343
1331 1344
1332 return hRet; 1345 return hRet;
1333 } 1346 }
1334 1347
1335 default: 1348 default:
1336 break; 1349 break;
1337 } 1350 }
1338 1351
1339 LRESULT result = CallWindowProc(pClass->m_pWndProcStatus, hWnd, message, wPara m, lParam); 1352 LRESULT result = CallWindowProc(pClass->m_pWndProcStatus, hWnd, message, wPa ram, lParam);
1340 1353
1341 1354
1342 return result; 1355 return result;
1343 1356 }
1357 catch (...)
1358 {
1359 return E_FAIL;
Oleksandr 2016/01/04 10:46:13 I think we should call: return DefWindowProc(hWnd,
sergei 2016/01/04 11:27:36 It's better to use CallWindowProc instead of DefWi
Eric 2016/01/04 16:44:24 Sergei's right. This observation also points out
1360 }
1344 } 1361 }
1345 1362
1346 1363
1347 HICON CPluginClass::GetStatusBarIcon(const std::wstring& url) 1364 HICON CPluginClass::GetStatusBarIcon(const std::wstring& url)
1348 { 1365 {
1349 // use the disable icon as defualt, if the client doesn't exists 1366 // use the disable icon as defualt, if the client doesn't exists
1350 HICON hIcon = GetIcon(ICON_PLUGIN_DEACTIVATED); 1367 HICON hIcon = GetIcon(ICON_PLUGIN_DEACTIVATED);
1351 1368
1352 CPluginTab* tab = GetTab(::GetCurrentThreadId()); 1369 CPluginTab* tab = GetTab(::GetCurrentThreadId());
1353 if (tab) 1370 if (tab)
1354 { 1371 {
1355 CPluginClient* client = CPluginClient::GetInstance(); 1372 CPluginClient* client = CPluginClient::GetInstance();
1356 if (CPluginSettings::GetInstance()->IsPluginEnabled()) 1373 if (CPluginSettings::GetInstance()->IsPluginEnabled())
1357 { 1374 {
1358 if (client->IsWhitelistedUrl(url)) 1375 if (client->IsWhitelistedUrl(url))
1359 { 1376 {
1360 hIcon = GetIcon(ICON_PLUGIN_DISABLED); 1377 hIcon = GetIcon(ICON_PLUGIN_DISABLED);
1361 } 1378 }
1362 else 1379 else
1363 { 1380 {
1364 CPluginSettings* settings = CPluginSettings::GetInstance(); 1381 CPluginSettings* settings = CPluginSettings::GetInstance();
1365 hIcon = GetIcon(ICON_PLUGIN_ENABLED); 1382 hIcon = GetIcon(ICON_PLUGIN_ENABLED);
1366 } 1383 }
1367 } 1384 }
1368 } 1385 }
1369 return hIcon; 1386 return hIcon;
1370 } 1387 }
1371 1388
1372 1389 // Entry point
1373 LRESULT CALLBACK CPluginClass::PaneWindowProc(HWND hWnd, UINT message, WPARAM wP aram, LPARAM lParam) 1390 LRESULT CALLBACK CPluginClass::PaneWindowProc(HWND hWnd, UINT message, WPARAM wP aram, LPARAM lParam)
1374 { 1391 {
1375 // Find tab 1392 try
1376 CPluginClass *pClass = FindInstance(GetParent(hWnd));
1377 if (!pClass)
1378 { 1393 {
1379 return ::DefWindowProc(hWnd, message, wParam, lParam); 1394 // Find tab
1380 } 1395 CPluginClass *pClass = FindInstance(GetParent(hWnd));
1396 if (!pClass)
1397 {
1398 return ::DefWindowProc(hWnd, message, wParam, lParam);
1399 }
1381 1400
1382 // Process message 1401 // Process message
1383 switch (message) 1402 switch (message)
1384 { 1403 {
1385 1404
1386 case WM_SETCURSOR: 1405 case WM_SETCURSOR:
1387 { 1406 {
1388 ::SetCursor(::LoadCursor(NULL, IDC_ARROW)); 1407 ::SetCursor(::LoadCursor(NULL, IDC_ARROW));
1389 return TRUE; 1408 return TRUE;
1390 } 1409 }
1391 case WM_PAINT: 1410 case WM_PAINT:
1392 { 1411 {
1393 PAINTSTRUCT ps; 1412 PAINTSTRUCT ps;
1394 HDC hDC = ::BeginPaint(hWnd, &ps); 1413 HDC hDC = ::BeginPaint(hWnd, &ps);
1395 1414
1396 AdblockPlus::Rectangle rcClient; 1415 AdblockPlus::Rectangle rcClient;
1397 ::GetClientRect(hWnd, &rcClient); 1416 ::GetClientRect(hWnd, &rcClient);
1398 1417
1399 int nDrawEdge = 0; 1418 int nDrawEdge = 0;
1400 1419
1401 // Old Windows background drawing 1420 // Old Windows background drawing
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1449 { 1468 {
1450 //Get the RECT for the leftmost pane (the status text pane) 1469 //Get the RECT for the leftmost pane (the status text pane)
1451 RECT rect; 1470 RECT rect;
1452 BOOL rectRes = ::SendMessage(pClass->m_hStatusBarWnd, SB_GETRECT, 0, ( LPARAM)&rect); 1471 BOOL rectRes = ::SendMessage(pClass->m_hStatusBarWnd, SB_GETRECT, 0, ( LPARAM)&rect);
1453 ::DrawIconEx(hDC, 0, rect.bottom - rect.top - iconHeight, hIcon, iconW idth, iconHeight, NULL, NULL, DI_NORMAL); 1472 ::DrawIconEx(hDC, 0, rect.bottom - rect.top - iconHeight, hIcon, iconW idth, iconHeight, NULL, NULL, DI_NORMAL);
1454 offx += iconWidth; 1473 offx += iconWidth;
1455 } 1474 }
1456 #ifdef _DEBUG 1475 #ifdef _DEBUG
1457 // Display version 1476 // Display version
1458 HFONT hFont = (HFONT)::SendMessage(pClass->m_hStatusBarWnd, WM_GETFONT, 0, 0); 1477 HFONT hFont = (HFONT)::SendMessage(pClass->m_hStatusBarWnd, WM_GETFONT, 0, 0);
1459 HGDIOBJ hOldFont = ::SelectObject(hDC,hFont); 1478 HGDIOBJ hOldFont = ::SelectObject(hDC, hFont);
1460 1479
1461 AdblockPlus::Rectangle rcText = rcClient; 1480 AdblockPlus::Rectangle rcText = rcClient;
1462 rcText.left += offx; 1481 rcText.left += offx;
1463 ::SetBkMode(hDC, TRANSPARENT); 1482 ::SetBkMode(hDC, TRANSPARENT);
1464 ::DrawTextW(hDC, IEPLUGIN_VERSION, -1, &rcText, DT_WORD_ELLIPSIS|DT_LEFT |DT_SINGLELINE|DT_VCENTER); 1483 ::DrawTextW(hDC, IEPLUGIN_VERSION, -1, &rcText, DT_WORD_ELLIPSIS | DT_LE FT | DT_SINGLELINE | DT_VCENTER);
1465 1484
1466 ::SelectObject(hDC, hOldFont); 1485 ::SelectObject(hDC, hOldFont);
1467 #endif // _DEBUG 1486 #endif // _DEBUG
1468 } 1487 }
1469 1488
1470 // Done! 1489 // Done!
1471 EndPaint(hWnd, &ps); 1490 EndPaint(hWnd, &ps);
1472 1491
1473 return 0; 1492 return 0;
1474 } 1493 }
1475 1494
1476 case WM_LBUTTONUP: 1495 case WM_LBUTTONUP:
1477 case WM_RBUTTONUP: 1496 case WM_RBUTTONUP:
1478 { 1497 {
1479 std::wstring url = pClass->GetBrowserUrl(); 1498 std::wstring url = pClass->GetBrowserUrl();
1480 if (url != pClass->GetTab()->GetDocumentUrl()) 1499 if (url != pClass->GetTab()->GetDocumentUrl())
1481 { 1500 {
1482 pClass->GetTab()->SetDocumentUrl(url); 1501 pClass->GetTab()->SetDocumentUrl(url);
1483 } 1502 }
1484 1503
1485 // Create menu 1504 // Create menu
1486 HMENU hMenu = pClass->CreatePluginMenu(url); 1505 HMENU hMenu = pClass->CreatePluginMenu(url);
1487 if (!hMenu) 1506 if (!hMenu)
1488 { 1507 {
1489 return 0; 1508 return 0;
1490 } 1509 }
1491 1510
1492 // Display menu 1511 // Display menu
1493 POINT pt; 1512 POINT pt;
1494 ::GetCursorPos(&pt); 1513 ::GetCursorPos(&pt);
1495 1514
1496 RECT rc; 1515 RECT rc;
1497 ::GetWindowRect(hWnd, &rc); 1516 ::GetWindowRect(hWnd, &rc);
1498 1517
1499 if (rc.left >= 0 && rc.top >= 0) 1518 if (rc.left >= 0 && rc.top >= 0)
1500 { 1519 {
1501 pt.x = rc.left; 1520 pt.x = rc.left;
1502 pt.y = rc.top; 1521 pt.y = rc.top;
1503 } 1522 }
1504 1523
1505 pClass->DisplayPluginMenu(hMenu, -1, pt, TPM_LEFTALIGN|TPM_BOTTOMALIGN); 1524 pClass->DisplayPluginMenu(hMenu, -1, pt, TPM_LEFTALIGN | TPM_BOTTOMALIGN);
1506 } 1525 }
1507 break; 1526 break;
1508 case WM_DESTROY: 1527 case WM_DESTROY:
1509 break; 1528 break;
1510 case SC_CLOSE: 1529 case SC_CLOSE:
1511 break; 1530 break;
1512 1531
1513 case WM_UPDATEUISTATE: 1532 case WM_UPDATEUISTATE:
1514 { 1533 {
1515 CPluginTab* tab = GetTab(::GetCurrentThreadId()); 1534 CPluginTab* tab = GetTab(::GetCurrentThreadId());
1516 if (tab) 1535 if (tab)
1517 { 1536 {
1518 tab->OnActivate(); 1537 tab->OnActivate();
1519 RECT rect; 1538 RECT rect;
1520 GetWindowRect(pClass->m_hPaneWnd, &rect); 1539 GetWindowRect(pClass->m_hPaneWnd, &rect);
1521 pClass->notificationMessage.Move(rect.left + (rect.right - rect.left) / 2, rect.top + (rect.bottom - rect.top) / 2); 1540 pClass->notificationMessage.Move(rect.left + (rect.right - rect.left) / 2, rect.top + (rect.bottom - rect.top) / 2);
1522 } 1541 }
1523 if (LOWORD(wParam) == UIS_CLEAR) 1542 if (LOWORD(wParam) == UIS_CLEAR)
1524 { 1543 {
1525 pClass->notificationMessage.Hide(); 1544 pClass->notificationMessage.Hide();
1526 } 1545 }
1527 } 1546 }
1528 break; 1547 break;
1529 case WM_WINDOWPOSCHANGING: 1548 case WM_WINDOWPOSCHANGING:
1530 { 1549 {
1531 RECT rect; 1550 RECT rect;
1532 GetWindowRect(pClass->m_hPaneWnd, &rect); 1551 GetWindowRect(pClass->m_hPaneWnd, &rect);
1533 if (pClass->notificationMessage.IsVisible()) 1552 if (pClass->notificationMessage.IsVisible())
1534 { 1553 {
1535 pClass->notificationMessage.Move(rect.left + (rect.right - rect.left) / 2, rect.top + (rect.bottom - rect.top) / 2); 1554 pClass->notificationMessage.Move(rect.left + (rect.right - rect.left) / 2, rect.top + (rect.bottom - rect.top) / 2);
1536 } 1555 }
1537 } 1556 }
1538 break; 1557 break;
1539 case WM_WINDOWPOSCHANGED: 1558 case WM_WINDOWPOSCHANGED:
1540 { 1559 {
1541 WINDOWPOS* wndPos = reinterpret_cast<WINDOWPOS*>(lParam); 1560 WINDOWPOS* wndPos = reinterpret_cast<WINDOWPOS*>(lParam);
1542 if (wndPos->flags & SWP_HIDEWINDOW) 1561 if (wndPos->flags & SWP_HIDEWINDOW)
1543 { 1562 {
1544 pClass->notificationMessage.Hide(); 1563 pClass->notificationMessage.Hide();
1545 } 1564 }
1546 } 1565 }
1547 break; 1566 break;
1548 case WM_ALREADY_UP_TO_DATE: 1567 case WM_ALREADY_UP_TO_DATE:
1549 { 1568 {
1550 Dictionary* dictionary = Dictionary::GetInstance(); 1569 Dictionary* dictionary = Dictionary::GetInstance();
1551 std::wstring upToDateText = dictionary->Lookup("updater", "update-already- up-to-date-text"); 1570 std::wstring upToDateText = dictionary->Lookup("updater", "update-already- up-to-date-text");
1552 std::wstring upToDateTitle = dictionary->Lookup("updater", "update-already -up-to-date-title"); 1571 std::wstring upToDateTitle = dictionary->Lookup("updater", "update-already -up-to-date-title");
1553 pClass->notificationMessage.SetTextAndIcon(upToDateText, upToDateTitle, TT I_INFO); 1572 pClass->notificationMessage.SetTextAndIcon(upToDateText, upToDateTitle, TT I_INFO);
1554 } 1573 }
1555 break; 1574 break;
1556 case WM_UPDATE_CHECK_ERROR: 1575 case WM_UPDATE_CHECK_ERROR:
1557 { 1576 {
1558 Dictionary* dictionary = Dictionary::GetInstance(); 1577 Dictionary* dictionary = Dictionary::GetInstance();
1559 std::wstring errorText = dictionary->Lookup("updater", "update-error-text" ); 1578 std::wstring errorText = dictionary->Lookup("updater", "update-error-text" );
1560 std::wstring errorTitle = dictionary->Lookup("updater", "update-error-titl e"); 1579 std::wstring errorTitle = dictionary->Lookup("updater", "update-error-titl e");
1561 pClass->notificationMessage.SetTextAndIcon(errorText, errorText, TTI_ERROR ); 1580 pClass->notificationMessage.SetTextAndIcon(errorText, errorText, TTI_ERROR );
1562 } 1581 }
1563 break; 1582 break;
1564 case WM_DOWNLOADING_UPDATE: 1583 case WM_DOWNLOADING_UPDATE:
1565 { 1584 {
1566 Dictionary* dictionary = Dictionary::GetInstance(); 1585 Dictionary* dictionary = Dictionary::GetInstance();
1567 std::wstring downloadingText = dictionary->Lookup("updater", "downloading- update-text"); 1586 std::wstring downloadingText = dictionary->Lookup("updater", "downloading- update-text");
1568 std::wstring downloadingTitle = dictionary->Lookup("updater", "downloading -update-title"); 1587 std::wstring downloadingTitle = dictionary->Lookup("updater", "downloading -update-title");
1569 pClass->notificationMessage.SetTextAndIcon(downloadingText, downloadingTit le, TTI_INFO); 1588 pClass->notificationMessage.SetTextAndIcon(downloadingText, downloadingTit le, TTI_INFO);
1570 } 1589 }
1571 break; 1590 break;
1591 }
1592
1593 return DefWindowProc(hWnd, message, wParam, lParam);
1572 } 1594 }
1573 1595 catch (...)
1574 return DefWindowProc(hWnd, message, wParam, lParam); 1596 {
1597 return E_FAIL;
Oleksandr 2016/01/04 10:46:13 Same here. I think we should do 'return DefWindowP
Eric 2016/01/04 16:44:24 Done. Replace with a comment. Moved call to 'DefW
1598 }
1575 } 1599 }
1576 1600
1577 1601
1578 void CPluginClass::UpdateStatusBar() 1602 void CPluginClass::UpdateStatusBar()
1579 { 1603 {
1580 DEBUG_GENERAL("*** Updating statusbar") 1604 DEBUG_GENERAL("*** Updating statusbar")
1581 if (m_hPaneWnd == NULL) 1605 if (m_hPaneWnd == NULL)
1582 { 1606 {
1583 CreateStatusBarPane(); 1607 CreateStatusBarPane();
1584 } 1608 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1633 s_criticalSectionLocal.Unlock(); 1657 s_criticalSectionLocal.Unlock();
1634 1658
1635 return icon; 1659 return icon;
1636 } 1660 }
1637 1661
1638 ATOM CPluginClass::GetAtomPaneClass() 1662 ATOM CPluginClass::GetAtomPaneClass()
1639 { 1663 {
1640 return s_atomPaneClass; 1664 return s_atomPaneClass;
1641 } 1665 }
1642 1666
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld