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

Unified Diff: src/plugin/PluginClass.cpp

Issue 11292028: Status bar menu added (Closed)
Patch Set: Addressing comments. Actual functionality fixes Created Aug. 1, 2013, 10:28 p.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
@@ -1229,9 +1229,6 @@
CPluginSystem* system = CPluginSystem::GetInstance();
- CString url;
- int navigationErrorId = 0;
-
// Create menu parent window
HWND hMenuWnd = ::CreateWindowEx(
NULL,
@@ -1283,32 +1280,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);
Felix Dahlke 2013/08/02 13:52:58 While we're at it, I think we should store BString
+ 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));
+
Felix Dahlke 2013/08/02 13:52:58 Superfluous whitespace.
+ }
+ 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")
- }
- }
- }
}
@@ -1348,15 +1363,21 @@
#ifdef SUPPORT_WHITELIST
{
- // White list domain
- ctext = dictionary->Lookup("menu", "disable-on-site");
+ ctext = dictionary->Lookup("menu", "disable-on-site");
Felix Dahlke 2013/08/02 13:52:58 Looks like the indentation is off here.
+ // Is domain in white list?
+ ReplaceString(ctext, L"?1?", ExtractDomain(url).GetString());
+ if (client->IsWhitelistedUrl(std::wstring(GetTab()->GetDocumentUrl())))
+ {
+ fmii.fState = MFS_CHECKED | MFS_ENABLED;
+ }
+ else
+ {
+ fmii.fState = MFS_UNCHECKED | MFS_ENABLED;
+ }
fmii.fMask = MIIM_STRING | MIIM_STATE;
- fmii.fState = MFS_DISABLED;
fmii.dwTypeData = const_cast<LPWSTR>(ctext.c_str());
fmii.cch = ctext.size();
- UINT index = WM_WHITELIST_DOMAIN;
-
::SetMenuItemInfoW(hMenu, ID_WHITELISTDOMAIN, FALSE, &fmii);
}
#else
@@ -1366,16 +1387,16 @@
#endif // SUPPORT_WHITELIST
// Plugin enable
+ ctext = dictionary->Lookup("menu", "disable");
if (settings->GetPluginEnabled())
{
- ctext = dictionary->Lookup("menu", "disable");
+ fmii.fState = MFS_UNCHECKED | MFS_ENABLED;
}
else
{
- ctext = dictionary->Lookup("menu", "enable");
+ fmii.fState = MFS_CHECKED | MFS_ENABLED;
}
fmii.fMask = MIIM_STATE | MIIM_STRING;
- fmii.fState = client ? MFS_ENABLED : MFS_DISABLED;
fmii.dwTypeData = const_cast<LPWSTR>(ctext.c_str());
fmii.cch = ctext.size();
::SetMenuItemInfoW(hMenu, ID_PLUGIN_ENABLE, FALSE, &fmii);
@@ -1578,12 +1599,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);
}
@@ -1705,7 +1721,6 @@
pClass->GetTab()->SetDocumentUrl(strURL);
}
-#ifdef SUPPORT_SHOW_PLUGIN_MENU
// Create menu
HMENU hMenu = pClass->CreatePluginMenu(strURL);
if (!hMenu)
@@ -1727,27 +1742,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:

Powered by Google App Engine
This is Rietveld