Index: src/plugin/PluginClass.cpp |
=================================================================== |
--- a/src/plugin/PluginClass.cpp |
+++ b/src/plugin/PluginClass.cpp |
@@ -1286,32 +1286,50 @@ |
s_criticalSectionLocal.Unlock(); |
} |
break; |
+ case ID_SETTINGS: |
+ { |
+ CComQIPtr<IWebBrowser2> browser = GetAsyncBrowser(); |
+ if (browser) |
+ { |
+ VARIANT vFlags; |
+ vFlags.vt = VT_I4; |
+ vFlags.intVal = navOpenInNewTab; |
+ |
+ HRESULT hr = browser->Navigate(BString(UserSettingsFileUrl()), &vFlags, NULL, NULL, NULL); |
+ if (FAILED(hr)) |
+ { |
+ vFlags.intVal = navOpenInNewWindow; |
+ |
+ hr = browser->Navigate(BString(UserSettingsFileUrl()), &vFlags, NULL, NULL, NULL); |
+ if (FAILED(hr)) |
+ { |
+ DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_NAVIGATION, PLUGIN_ERROR_NAVIGATION_SETTINGS, "Navigation::Failed") |
+ } |
+ } |
+ } |
+ break; |
+ } |
+ case ID_WHITELISTDOMAIN: |
+ { |
+ CPluginSettings* settings = CPluginSettings::GetInstance(); |
+ CString urlString = GetTab()->GetDocumentUrl(); |
+ if (client->IsWhitelistedUrl(std::wstring(urlString))) |
+ { |
+ settings->RemoveWhiteListedDomain(ExtractDomain(urlString)); |
+ |
+ } |
+ else |
+ { |
+ settings->AddWhiteListedDomain(ExtractDomain(urlString)); |
+ } |
+ GetBrowser()->Refresh(); |
+ } |
default: |
break; |
} |
// Invalidate and redraw the control |
UpdateStatusBar(); |
- |
- CComQIPtr<IWebBrowser2> browser = GetBrowser(); |
- if (!url.IsEmpty() && browser) |
- { |
- VARIANT vFlags; |
- vFlags.vt = VT_I4; |
- vFlags.intVal = navOpenInNewTab; |
- |
- HRESULT hr = browser->Navigate(CComBSTR(url), &vFlags, NULL, NULL, NULL); |
- if (FAILED(hr)) |
- { |
- vFlags.intVal = navOpenInNewWindow; |
- |
- hr = browser->Navigate(CComBSTR(url), &vFlags, NULL, NULL, NULL); |
- if (FAILED(hr)) |
- { |
- DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_NAVIGATION, navigationErrorId, "Navigation::Failed") |
- } |
- } |
- } |
} |
@@ -1352,14 +1370,19 @@ |
#ifdef SUPPORT_WHITELIST |
{ |
// White list domain |
- ctext = dictionary->Lookup("menu", "disable-on-site"); |
+ if (client->IsWhitelistedUrl(std::wstring(GetTab()->GetDocumentUrl()))) |
+ { |
+ ctext = dictionary->Lookup("menu", "enable-on-site"); |
+ } |
+ else |
+ { |
+ ctext = dictionary->Lookup("menu", "disable-on-site"); |
+ } |
fmii.fMask = MIIM_STRING | MIIM_STATE; |
- fmii.fState = MFS_DISABLED; |
+ fmii.fState = MFS_ENABLED; |
fmii.dwTypeData = const_cast<LPWSTR>(ctext.c_str()); |
fmii.cch = ctext.size(); |
- UINT index = WM_WHITELIST_DOMAIN; |
- |
::SetMenuItemInfoW(hMenu, ID_WHITELISTDOMAIN, FALSE, &fmii); |
} |
#else |
@@ -1581,12 +1604,7 @@ |
#endif // SUPPORT_WHITELIST |
else |
{ |
- //Deativate adblock icon if adblock limit reached |
CPluginSettings* settings = CPluginSettings::GetInstance(); |
- if (!settings->GetPluginEnabled()) { |
- hIcon = GetIcon(ICON_PLUGIN_DEACTIVATED); |
- return hIcon; |
- } |
hIcon = GetIcon(ICON_PLUGIN_ENABLED); |
} |
@@ -1708,7 +1726,6 @@ |
pClass->GetTab()->SetDocumentUrl(strURL); |
} |
-#ifdef SUPPORT_SHOW_PLUGIN_MENU |
// Create menu |
HMENU hMenu = pClass->CreatePluginMenu(strURL); |
if (!hMenu) |
@@ -1730,27 +1747,6 @@ |
} |
pClass->DisplayPluginMenu(hMenu, -1, pt, TPM_LEFTALIGN|TPM_BOTTOMALIGN); |
-#else |
- CComQIPtr<IWebBrowser2> browser = GetAsyncBrowser(); |
- if (browser) |
- { |
- VARIANT vFlags; |
- vFlags.vt = VT_I4; |
- vFlags.intVal = navOpenInNewTab; |
- |
- HRESULT hr = browser->Navigate(BString(UserSettingsFileUrl()), &vFlags, NULL, NULL, NULL); |
- if (FAILED(hr)) |
- { |
- vFlags.intVal = navOpenInNewWindow; |
- |
- hr = browser->Navigate(BString(UserSettingsFileUrl()), &vFlags, NULL, NULL, NULL); |
- if (FAILED(hr)) |
- { |
- DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_NAVIGATION, PLUGIN_ERROR_NAVIGATION_SETTINGS, "Navigation::Failed") |
- } |
- } |
- } |
-#endif |
} |
break; |
case WM_DESTROY: |