LEFT | RIGHT |
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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 m_hTabWnd = NULL; | 62 m_hTabWnd = NULL; |
63 m_hStatusBarWnd = NULL; | 63 m_hStatusBarWnd = NULL; |
64 m_hPaneWnd = NULL; | 64 m_hPaneWnd = NULL; |
65 m_nPaneWidth = 0; | 65 m_nPaneWidth = 0; |
66 m_pWndProcStatus = NULL; | 66 m_pWndProcStatus = NULL; |
67 m_hTheme = NULL; | 67 m_hTheme = NULL; |
68 m_isInitializedOk = false; | 68 m_isInitializedOk = false; |
69 | 69 |
70 | 70 |
71 m_tab = new CPluginTab(this); | 71 m_tab = new CPluginTab(this); |
72 | |
73 // Load settings (fetch the available subscriptions, if still not fetched) | |
74 CPluginSettings* settings = CPluginSettings::GetInstance(); | |
75 | 72 |
76 CPluginSystem* system = CPluginSystem::GetInstance(); | 73 CPluginSystem* system = CPluginSystem::GetInstance(); |
77 | 74 |
78 std::wstring locale((LPCWSTR)system->GetBrowserLanguage()); | 75 std::wstring locale((LPCWSTR)system->GetBrowserLanguage()); |
79 Dictionary::Create(locale); | 76 Dictionary::Create(locale); |
80 } | 77 } |
81 | 78 |
82 CPluginClass::~CPluginClass() | 79 CPluginClass::~CPluginClass() |
83 { | 80 { |
84 delete m_tab; | 81 delete m_tab; |
(...skipping 1140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1225 | 1222 |
1226 return fRet; | 1223 return fRet; |
1227 } | 1224 } |
1228 | 1225 |
1229 void CPluginClass::DisplayPluginMenu(HMENU hMenu, int nToolbarCmdID, POINT pt, U
INT nMenuFlags) | 1226 void CPluginClass::DisplayPluginMenu(HMENU hMenu, int nToolbarCmdID, POINT pt, U
INT nMenuFlags) |
1230 { | 1227 { |
1231 CPluginClient* client = CPluginClient::GetInstance(); | 1228 CPluginClient* client = CPluginClient::GetInstance(); |
1232 | 1229 |
1233 CPluginSystem* system = CPluginSystem::GetInstance(); | 1230 CPluginSystem* system = CPluginSystem::GetInstance(); |
1234 | 1231 |
1235 CString url; | |
1236 int navigationErrorId = 0; | |
1237 | |
1238 // Create menu parent window | 1232 // Create menu parent window |
1239 HWND hMenuWnd = ::CreateWindowEx( | 1233 HWND hMenuWnd = ::CreateWindowEx( |
1240 NULL, | 1234 NULL, |
1241 MAKEINTATOM(GetAtomPaneClass()), | 1235 MAKEINTATOM(GetAtomPaneClass()), |
1242 _T(""), | 1236 _T(""), |
1243 0, | 1237 0, |
1244 0,0,0,0, | 1238 0,0,0,0, |
1245 NULL, | 1239 NULL, |
1246 NULL, | 1240 NULL, |
1247 _Module.m_hInst, | 1241 _Module.m_hInst, |
1248 NULL); | 1242 NULL); |
1249 | 1243 |
1250 if (!hMenuWnd) | 1244 if (!hMenuWnd) |
1251 { | 1245 { |
1252 DestroyMenu(hMenu); | 1246 DestroyMenu(hMenu); |
1253 return; | 1247 return; |
1254 } | 1248 } |
1255 | 1249 |
1256 // Display menu | 1250 // Display menu |
1257 nMenuFlags |= TPM_NONOTIFY | TPM_RETURNCMD | TPM_LEFTBUTTON; | 1251 nMenuFlags |= TPM_NONOTIFY | TPM_RETURNCMD | TPM_LEFTBUTTON; |
1258 | 1252 |
1259 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)
; |
1260 | 1254 |
1261 ::DestroyMenu(hMenu); | 1255 ::DestroyMenu(hMenu); |
1262 ::DestroyWindow(hMenuWnd); | 1256 ::DestroyWindow(hMenuWnd); |
1263 | 1257 |
1264 switch (nCommand) | 1258 switch (nCommand) |
1265 { | 1259 { |
1266 case ID_PLUGIN_ENABLE: | 1260 case ID_MENU_DISABLE: |
1267 { | 1261 { |
1268 CPluginSettings* settings = CPluginSettings::GetInstance(); | 1262 CPluginSettings* settings = CPluginSettings::GetInstance(); |
1269 | 1263 |
1270 settings->TogglePluginEnabled(); | 1264 settings->TogglePluginEnabled(); |
1271 | 1265 |
1272 // Enable / disable mime filter | 1266 // Enable / disable mime filter |
1273 s_criticalSectionLocal.Lock(); | 1267 s_criticalSectionLocal.Lock(); |
1274 { | 1268 { |
1275 if (settings->GetPluginEnabled()) | 1269 if (settings->GetPluginEnabled()) |
1276 { | 1270 { |
1277 s_mimeFilter = CPluginClientFactory::GetMimeFilterClientInstance(); | 1271 s_mimeFilter = CPluginClientFactory::GetMimeFilterClientInstance(); |
1278 } | 1272 } |
1279 else | 1273 else |
1280 { | 1274 { |
1281 s_mimeFilter = NULL; | 1275 s_mimeFilter = NULL; |
1282 | 1276 |
1283 CPluginClientFactory::ReleaseMimeFilterClientInstance(); | 1277 CPluginClientFactory::ReleaseMimeFilterClientInstance(); |
1284 } | 1278 } |
1285 } | 1279 } |
1286 s_criticalSectionLocal.Unlock(); | 1280 s_criticalSectionLocal.Unlock(); |
1287 } | 1281 } |
1288 break; | 1282 break; |
1289 case ID_SETTINGS: | 1283 case ID_MENU_SETTINGS: |
1290 { | 1284 { |
1291 CComQIPtr<IWebBrowser2> browser = GetAsyncBrowser(); | 1285 CComQIPtr<IWebBrowser2> browser = GetAsyncBrowser(); |
1292 if (browser) | 1286 if (browser) |
1293 { | 1287 { |
1294 VARIANT vFlags; | 1288 VARIANT vFlags; |
1295 vFlags.vt = VT_I4; | 1289 vFlags.vt = VT_I4; |
1296 vFlags.intVal = navOpenInNewTab; | 1290 vFlags.intVal = navOpenInNewTab; |
1297 | 1291 |
1298 HRESULT hr = browser->Navigate(BString(UserSettingsFileUrl()), &vFlags,
NULL, NULL, NULL); | 1292 BSTR urlToNavigate = BString(UserSettingsFileUrl()); |
| 1293 HRESULT hr = browser->Navigate(urlToNavigate, &vFlags, NULL, NULL, NULL)
; |
1299 if (FAILED(hr)) | 1294 if (FAILED(hr)) |
1300 { | 1295 { |
1301 vFlags.intVal = navOpenInNewWindow; | 1296 vFlags.intVal = navOpenInNewWindow; |
1302 | 1297 |
1303 hr = browser->Navigate(BString(UserSettingsFileUrl()), &vFlags, NULL,
NULL, NULL); | 1298 hr = browser->Navigate(urlToNavigate, &vFlags, NULL, NULL, NULL); |
1304 if (FAILED(hr)) | 1299 if (FAILED(hr)) |
1305 { | 1300 { |
1306 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") |
1307 } | 1302 } |
1308 } | 1303 } |
1309 } | 1304 } |
1310 break; | 1305 break; |
1311 } | 1306 } |
1312 case ID_WHITELISTDOMAIN: | 1307 case ID_MENU_DISABLE_ON_SITE: |
1313 { | 1308 { |
1314 CPluginSettings* settings = CPluginSettings::GetInstance(); | 1309 CPluginSettings* settings = CPluginSettings::GetInstance(); |
1315 CString urlString = GetTab()->GetDocumentUrl(); | 1310 CString urlString = GetTab()->GetDocumentUrl(); |
1316 if (client->IsWhitelistedUrl(std::wstring(urlString))) | 1311 if (client->IsWhitelistedUrl(std::wstring(urlString))) |
1317 { | 1312 { |
1318 settings->RemoveWhiteListedDomain(ExtractDomain(urlString)); | 1313 settings->RemoveWhiteListedDomain(ExtractDomain(urlString)); |
1319 | |
1320 } | 1314 } |
1321 else | 1315 else |
1322 { | 1316 { |
1323 settings->AddWhiteListedDomain(ExtractDomain(urlString)); | 1317 settings->AddWhiteListedDomain(ExtractDomain(urlString)); |
1324 } | 1318 } |
1325 GetBrowser()->Refresh(); | 1319 GetBrowser()->Refresh(); |
1326 } | 1320 } |
1327 default: | 1321 default: |
1328 break; | 1322 break; |
1329 } | 1323 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1362 miiSep.cbSize = sizeof(MENUITEMINFO); | 1356 miiSep.cbSize = sizeof(MENUITEMINFO); |
1363 miiSep.fMask = MIIM_TYPE | MIIM_FTYPE; | 1357 miiSep.fMask = MIIM_TYPE | MIIM_FTYPE; |
1364 miiSep.fType = MFT_SEPARATOR; | 1358 miiSep.fType = MFT_SEPARATOR; |
1365 | 1359 |
1366 CPluginClient* client = CPluginClient::GetInstance(); | 1360 CPluginClient* client = CPluginClient::GetInstance(); |
1367 | 1361 |
1368 CPluginSettings* settings = CPluginSettings::GetInstance(); | 1362 CPluginSettings* settings = CPluginSettings::GetInstance(); |
1369 | 1363 |
1370 #ifdef SUPPORT_WHITELIST | 1364 #ifdef SUPPORT_WHITELIST |
1371 { | 1365 { |
1372 // White list domain | 1366 ctext = dictionary->Lookup("menu", "menu-disable-on-site"); |
| 1367 // Is domain in white list? |
| 1368 ReplaceString(ctext, L"?1?", ExtractDomain(url).GetString()); |
1373 if (client->IsWhitelistedUrl(std::wstring(GetTab()->GetDocumentUrl()))) | 1369 if (client->IsWhitelistedUrl(std::wstring(GetTab()->GetDocumentUrl()))) |
1374 { | 1370 { |
1375 ctext = dictionary->Lookup("menu", "enable-on-site"); | 1371 fmii.fState = MFS_CHECKED | MFS_ENABLED; |
1376 } | 1372 } |
1377 else | 1373 else |
1378 { | 1374 { |
1379 ctext = dictionary->Lookup("menu", "disable-on-site"); | 1375 fmii.fState = MFS_UNCHECKED | MFS_ENABLED; |
1380 } | 1376 } |
1381 fmii.fMask = MIIM_STRING | MIIM_STATE; | 1377 fmii.fMask = MIIM_STRING | MIIM_STATE; |
1382 fmii.fState = MFS_ENABLED; | |
1383 fmii.dwTypeData = const_cast<LPWSTR>(ctext.c_str()); | 1378 fmii.dwTypeData = const_cast<LPWSTR>(ctext.c_str()); |
1384 fmii.cch = ctext.size(); | 1379 fmii.cch = ctext.size(); |
1385 | 1380 |
1386 ::SetMenuItemInfoW(hMenu, ID_WHITELISTDOMAIN, FALSE, &fmii); | 1381 ::SetMenuItemInfoW(hMenu, ID_MENU_DISABLE_ON_SITE, FALSE, &fmii); |
1387 } | 1382 } |
1388 #else | 1383 #else |
1389 { | 1384 { |
1390 ::DeleteMenu(hMenu, ID_WHITELISTDOMAIN, FALSE); | 1385 ::DeleteMenu(hMenu, ID_MENU_DISABLE_ON_SITE, FALSE); |
1391 } | 1386 } |
1392 #endif // SUPPORT_WHITELIST | 1387 #endif // SUPPORT_WHITELIST |
1393 | 1388 |
1394 // Plugin enable | 1389 // Plugin enable |
| 1390 ctext = dictionary->Lookup("menu", "menu-disable"); |
1395 if (settings->GetPluginEnabled()) | 1391 if (settings->GetPluginEnabled()) |
1396 { | 1392 { |
1397 ctext = dictionary->Lookup("menu", "disable"); | 1393 fmii.fState = MFS_UNCHECKED | MFS_ENABLED; |
1398 } | 1394 } |
1399 else | 1395 else |
1400 { | 1396 { |
1401 ctext = dictionary->Lookup("menu", "enable"); | 1397 fmii.fState = MFS_CHECKED | MFS_ENABLED; |
1402 } | 1398 } |
1403 fmii.fMask = MIIM_STATE | MIIM_STRING; | 1399 fmii.fMask = MIIM_STATE | MIIM_STRING; |
1404 fmii.fState = client ? MFS_ENABLED : MFS_DISABLED; | |
1405 fmii.dwTypeData = const_cast<LPWSTR>(ctext.c_str()); | 1400 fmii.dwTypeData = const_cast<LPWSTR>(ctext.c_str()); |
1406 fmii.cch = ctext.size(); | 1401 fmii.cch = ctext.size(); |
1407 ::SetMenuItemInfoW(hMenu, ID_PLUGIN_ENABLE, FALSE, &fmii); | 1402 ::SetMenuItemInfoW(hMenu, ID_MENU_DISABLE, FALSE, &fmii); |
1408 | 1403 |
1409 // Settings | 1404 // Settings |
1410 ctext = dictionary->Lookup("menu", "settings"); | 1405 ctext = dictionary->Lookup("menu", "menu-settings"); |
1411 fmii.fMask = MIIM_STATE | MIIM_STRING; | 1406 fmii.fMask = MIIM_STATE | MIIM_STRING; |
1412 fmii.fState = MFS_ENABLED; | 1407 fmii.fState = MFS_ENABLED; |
1413 fmii.dwTypeData = const_cast<LPWSTR>(ctext.c_str()); | 1408 fmii.dwTypeData = const_cast<LPWSTR>(ctext.c_str()); |
1414 fmii.cch = ctext.size(); | 1409 fmii.cch = ctext.size(); |
1415 ::SetMenuItemInfoW(hMenu, ID_SETTINGS, FALSE, &fmii); | 1410 ::SetMenuItemInfoW(hMenu, ID_MENU_SETTINGS, FALSE, &fmii); |
1416 | 1411 |
1417 return true; | 1412 return true; |
1418 } | 1413 } |
1419 | 1414 |
1420 | 1415 |
1421 STDMETHODIMP CPluginClass::Exec(const GUID*, DWORD nCmdID, DWORD, VARIANTARG*, V
ARIANTARG*) | 1416 STDMETHODIMP CPluginClass::Exec(const GUID*, DWORD nCmdID, DWORD, VARIANTARG*, V
ARIANTARG*) |
1422 { | 1417 { |
1423 HWND hBrowserWnd = GetBrowserHWND(); | 1418 HWND hBrowserWnd = GetBrowserHWND(); |
1424 if (!hBrowserWnd) | 1419 if (!hBrowserWnd) |
1425 { | 1420 { |
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1899 } | 1894 } |
1900 } | 1895 } |
1901 } | 1896 } |
1902 | 1897 |
1903 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT); | 1898 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT); |
1904 } | 1899 } |
1905 | 1900 |
1906 return hTabWnd; | 1901 return hTabWnd; |
1907 | 1902 |
1908 } | 1903 } |
LEFT | RIGHT |