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

Delta Between Two Patch Sets: src/plugin/PluginClass.cpp

Issue 11292028: Status bar menu added (Closed)
Left Patch Set: Addressing comments. Actual functionality fixes Created Aug. 1, 2013, 10:28 p.m.
Right Patch Set: Comments addressed Created Aug. 5, 2013, 1:13 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/plugin/AdblockPlusClient.cpp ('k') | src/plugin/PluginSettings.cpp » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 1239 matching lines...) Expand 10 before | Expand all | Expand 10 after
1250 // Display menu 1250 // Display menu
1251 nMenuFlags |= TPM_NONOTIFY | TPM_RETURNCMD | TPM_LEFTBUTTON; 1251 nMenuFlags |= TPM_NONOTIFY | TPM_RETURNCMD | TPM_LEFTBUTTON;
1252 1252
1253 int nCommand = ::TrackPopupMenu(hMenu, nMenuFlags, pt.x, pt.y, 0, hMenuWnd, 0) ; 1253 int nCommand = ::TrackPopupMenu(hMenu, nMenuFlags, pt.x, pt.y, 0, hMenuWnd, 0) ;
1254 1254
1255 ::DestroyMenu(hMenu); 1255 ::DestroyMenu(hMenu);
1256 ::DestroyWindow(hMenuWnd); 1256 ::DestroyWindow(hMenuWnd);
1257 1257
1258 switch (nCommand) 1258 switch (nCommand)
1259 { 1259 {
1260 case ID_PLUGIN_ENABLE: 1260 case ID_MENU_DISABLE:
1261 { 1261 {
1262 CPluginSettings* settings = CPluginSettings::GetInstance(); 1262 CPluginSettings* settings = CPluginSettings::GetInstance();
1263 1263
1264 settings->TogglePluginEnabled(); 1264 settings->TogglePluginEnabled();
1265 1265
1266 // Enable / disable mime filter 1266 // Enable / disable mime filter
1267 s_criticalSectionLocal.Lock(); 1267 s_criticalSectionLocal.Lock();
1268 { 1268 {
1269 if (settings->GetPluginEnabled()) 1269 if (settings->GetPluginEnabled())
1270 { 1270 {
1271 s_mimeFilter = CPluginClientFactory::GetMimeFilterClientInstance(); 1271 s_mimeFilter = CPluginClientFactory::GetMimeFilterClientInstance();
1272 } 1272 }
1273 else 1273 else
1274 { 1274 {
1275 s_mimeFilter = NULL; 1275 s_mimeFilter = NULL;
1276 1276
1277 CPluginClientFactory::ReleaseMimeFilterClientInstance(); 1277 CPluginClientFactory::ReleaseMimeFilterClientInstance();
1278 } 1278 }
1279 } 1279 }
1280 s_criticalSectionLocal.Unlock(); 1280 s_criticalSectionLocal.Unlock();
1281 } 1281 }
1282 break; 1282 break;
1283 case ID_SETTINGS: 1283 case ID_MENU_SETTINGS:
1284 { 1284 {
1285 CComQIPtr<IWebBrowser2> browser = GetAsyncBrowser(); 1285 CComQIPtr<IWebBrowser2> browser = GetAsyncBrowser();
1286 if (browser) 1286 if (browser)
1287 { 1287 {
1288 VARIANT vFlags; 1288 VARIANT vFlags;
1289 vFlags.vt = VT_I4; 1289 vFlags.vt = VT_I4;
1290 vFlags.intVal = navOpenInNewTab; 1290 vFlags.intVal = navOpenInNewTab;
1291 1291
1292 HRESULT hr = browser->Navigate(BString(UserSettingsFileUrl()), &vFlags, NULL, NULL, NULL); 1292 BSTR urlToNavigate = BString(UserSettingsFileUrl());
Felix Dahlke 2013/08/02 13:52:58 While we're at it, I think we should store BString
1293 HRESULT hr = browser->Navigate(urlToNavigate, &vFlags, NULL, NULL, NULL) ;
1293 if (FAILED(hr)) 1294 if (FAILED(hr))
1294 { 1295 {
1295 vFlags.intVal = navOpenInNewWindow; 1296 vFlags.intVal = navOpenInNewWindow;
1296 1297
1297 hr = browser->Navigate(BString(UserSettingsFileUrl()), &vFlags, NULL, NULL, NULL); 1298 hr = browser->Navigate(urlToNavigate, &vFlags, NULL, NULL, NULL);
1298 if (FAILED(hr)) 1299 if (FAILED(hr))
1299 { 1300 {
1300 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_NAVIGATION, PLUGIN_ERROR_NAVIGATION _SETTINGS, "Navigation::Failed") 1301 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_NAVIGATION, PLUGIN_ERROR_NAVIGATION _SETTINGS, "Navigation::Failed")
1301 } 1302 }
1302 } 1303 }
1303 } 1304 }
1304 break; 1305 break;
1305 } 1306 }
1306 case ID_WHITELISTDOMAIN: 1307 case ID_MENU_DISABLE_ON_SITE:
1307 { 1308 {
1308 CPluginSettings* settings = CPluginSettings::GetInstance(); 1309 CPluginSettings* settings = CPluginSettings::GetInstance();
1309 CString urlString = GetTab()->GetDocumentUrl(); 1310 CString urlString = GetTab()->GetDocumentUrl();
1310 if (client->IsWhitelistedUrl(std::wstring(urlString))) 1311 if (client->IsWhitelistedUrl(std::wstring(urlString)))
1311 { 1312 {
1312 settings->RemoveWhiteListedDomain(ExtractDomain(urlString)); 1313 settings->RemoveWhiteListedDomain(ExtractDomain(urlString));
1313
Felix Dahlke 2013/08/02 13:52:58 Superfluous whitespace.
1314 } 1314 }
1315 else 1315 else
1316 { 1316 {
1317 settings->AddWhiteListedDomain(ExtractDomain(urlString)); 1317 settings->AddWhiteListedDomain(ExtractDomain(urlString));
1318 } 1318 }
1319 GetBrowser()->Refresh(); 1319 GetBrowser()->Refresh();
1320 } 1320 }
1321 default: 1321 default:
1322 break; 1322 break;
1323 } 1323 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1356 miiSep.cbSize = sizeof(MENUITEMINFO); 1356 miiSep.cbSize = sizeof(MENUITEMINFO);
1357 miiSep.fMask = MIIM_TYPE | MIIM_FTYPE; 1357 miiSep.fMask = MIIM_TYPE | MIIM_FTYPE;
1358 miiSep.fType = MFT_SEPARATOR; 1358 miiSep.fType = MFT_SEPARATOR;
1359 1359
1360 CPluginClient* client = CPluginClient::GetInstance(); 1360 CPluginClient* client = CPluginClient::GetInstance();
1361 1361
1362 CPluginSettings* settings = CPluginSettings::GetInstance(); 1362 CPluginSettings* settings = CPluginSettings::GetInstance();
1363 1363
1364 #ifdef SUPPORT_WHITELIST 1364 #ifdef SUPPORT_WHITELIST
1365 { 1365 {
1366 ctext = dictionary->Lookup("menu", "disable-on-site"); 1366 ctext = dictionary->Lookup("menu", "menu-disable-on-site");
Felix Dahlke 2013/08/02 13:52:58 Looks like the indentation is off here.
1367 // Is domain in white list? 1367 // Is domain in white list?
1368 ReplaceString(ctext, L"?1?", ExtractDomain(url).GetString()); 1368 ReplaceString(ctext, L"?1?", ExtractDomain(url).GetString());
1369 if (client->IsWhitelistedUrl(std::wstring(GetTab()->GetDocumentUrl()))) 1369 if (client->IsWhitelistedUrl(std::wstring(GetTab()->GetDocumentUrl())))
1370 { 1370 {
1371 fmii.fState = MFS_CHECKED | MFS_ENABLED; 1371 fmii.fState = MFS_CHECKED | MFS_ENABLED;
1372 } 1372 }
1373 else 1373 else
1374 { 1374 {
1375 fmii.fState = MFS_UNCHECKED | MFS_ENABLED; 1375 fmii.fState = MFS_UNCHECKED | MFS_ENABLED;
1376 } 1376 }
1377 fmii.fMask = MIIM_STRING | MIIM_STATE; 1377 fmii.fMask = MIIM_STRING | MIIM_STATE;
1378 fmii.dwTypeData = const_cast<LPWSTR>(ctext.c_str()); 1378 fmii.dwTypeData = const_cast<LPWSTR>(ctext.c_str());
1379 fmii.cch = ctext.size(); 1379 fmii.cch = ctext.size();
1380 1380
1381 ::SetMenuItemInfoW(hMenu, ID_WHITELISTDOMAIN, FALSE, &fmii); 1381 ::SetMenuItemInfoW(hMenu, ID_MENU_DISABLE_ON_SITE, FALSE, &fmii);
1382 } 1382 }
1383 #else 1383 #else
1384 { 1384 {
1385 ::DeleteMenu(hMenu, ID_WHITELISTDOMAIN, FALSE); 1385 ::DeleteMenu(hMenu, ID_MENU_DISABLE_ON_SITE, FALSE);
1386 } 1386 }
1387 #endif // SUPPORT_WHITELIST 1387 #endif // SUPPORT_WHITELIST
1388 1388
1389 // Plugin enable 1389 // Plugin enable
1390 ctext = dictionary->Lookup("menu", "disable"); 1390 ctext = dictionary->Lookup("menu", "menu-disable");
1391 if (settings->GetPluginEnabled()) 1391 if (settings->GetPluginEnabled())
1392 { 1392 {
1393 fmii.fState = MFS_UNCHECKED | MFS_ENABLED; 1393 fmii.fState = MFS_UNCHECKED | MFS_ENABLED;
1394 } 1394 }
1395 else 1395 else
1396 { 1396 {
1397 fmii.fState = MFS_CHECKED | MFS_ENABLED; 1397 fmii.fState = MFS_CHECKED | MFS_ENABLED;
1398 } 1398 }
1399 fmii.fMask = MIIM_STATE | MIIM_STRING; 1399 fmii.fMask = MIIM_STATE | MIIM_STRING;
1400 fmii.dwTypeData = const_cast<LPWSTR>(ctext.c_str()); 1400 fmii.dwTypeData = const_cast<LPWSTR>(ctext.c_str());
1401 fmii.cch = ctext.size(); 1401 fmii.cch = ctext.size();
1402 ::SetMenuItemInfoW(hMenu, ID_PLUGIN_ENABLE, FALSE, &fmii); 1402 ::SetMenuItemInfoW(hMenu, ID_MENU_DISABLE, FALSE, &fmii);
1403 1403
1404 // Settings 1404 // Settings
1405 ctext = dictionary->Lookup("menu", "settings"); 1405 ctext = dictionary->Lookup("menu", "menu-settings");
1406 fmii.fMask = MIIM_STATE | MIIM_STRING; 1406 fmii.fMask = MIIM_STATE | MIIM_STRING;
1407 fmii.fState = MFS_ENABLED; 1407 fmii.fState = MFS_ENABLED;
1408 fmii.dwTypeData = const_cast<LPWSTR>(ctext.c_str()); 1408 fmii.dwTypeData = const_cast<LPWSTR>(ctext.c_str());
1409 fmii.cch = ctext.size(); 1409 fmii.cch = ctext.size();
1410 ::SetMenuItemInfoW(hMenu, ID_SETTINGS, FALSE, &fmii); 1410 ::SetMenuItemInfoW(hMenu, ID_MENU_SETTINGS, FALSE, &fmii);
1411 1411
1412 return true; 1412 return true;
1413 } 1413 }
1414 1414
1415 1415
1416 STDMETHODIMP CPluginClass::Exec(const GUID*, DWORD nCmdID, DWORD, VARIANTARG*, V ARIANTARG*) 1416 STDMETHODIMP CPluginClass::Exec(const GUID*, DWORD nCmdID, DWORD, VARIANTARG*, V ARIANTARG*)
1417 { 1417 {
1418 HWND hBrowserWnd = GetBrowserHWND(); 1418 HWND hBrowserWnd = GetBrowserHWND();
1419 if (!hBrowserWnd) 1419 if (!hBrowserWnd)
1420 { 1420 {
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
1894 } 1894 }
1895 } 1895 }
1896 } 1896 }
1897 1897
1898 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT); 1898 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT);
1899 } 1899 }
1900 1900
1901 return hTabWnd; 1901 return hTabWnd;
1902 1902
1903 } 1903 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld