Skip to content
Browse files

Issue 5539: New option in the Console panel: Show Cookie Events

  • Loading branch information...
1 parent 2f1b253 commit 16c3a36bc705a99440997cab740ad4ca443fac61 @janodvarko janodvarko committed Jul 12, 2012
View
43 extension/content/firebug/cookies/cookieModule.js
@@ -149,6 +149,8 @@ Firebug.CookieModule = Obj.extend(Firebug.ActivableModule,
image.setAttribute("src", "chrome://firebug/skin/cookies/breakOnCookieSingle.png");
bonStack.appendChild(image);
}
+
+ Firebug.registerUIListener(this);
},
initializeUI: function()
@@ -165,7 +167,7 @@ Firebug.CookieModule = Obj.extend(Firebug.ActivableModule,
* Peforms clean up when Firebug is destroyed.
* Called by the framework when Firebug is closed for an existing Firefox window.
*/
- shutdown: function()
+ shutdown: function()
{
this.unregisterObservers();
@@ -178,6 +180,8 @@ Firebug.CookieModule = Obj.extend(Firebug.ActivableModule,
//Firebug.Console.removeListener(this.ConsoleListener);
//Firebug.Debugger.removeListener(this.DebuggerListener);
+
+ Firebug.unregisterUIListener(this);
},
registerObservers: function()
@@ -1044,7 +1048,42 @@ Firebug.CookieModule = Obj.extend(Firebug.ActivableModule,
parent.openDialog("chrome://browser/content/preferences/permissions.xul",
"_blank","chrome,resizable=yes", params);
},
-});
+
+ // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ // Console Panel Options
+
+ /**
+ * Extend Console panel's option menu.
+ */
+ onOptionsMenu: function(context, panel, items)
+ {
+ if (panel.name != "console")
+ return;
+
+ var cookies = [
+ MenuUtils.optionMenu(context, "cookies.showCookieEvents",
+ "cookies.tip.showCookieEvents", Firebug.prefDomain, "cookies.logEvents"),
+ ];
+
+ // The option is disabled if the panel is disabled.
+ if (!this.isEnabled(context))
+ cookies[0].disabled = true;
+
+ // Append new option at the right position.
+ for (var i=0; i<items.length; i++)
+ {
+ var item = items[i];
+ if (item.option == "showStackTrace")
+ {
+ Arr.arrayInsert(items, i+1, cookies);
+ return;
+ }
+ }
+
+ // If "showStackTrace" is not there append at the end.
+ Arr.arrayInsert(items, items.length, cookies);
+ },
+});
// ********************************************************************************************* //
// Custom info tab within Net panel
View
6 extension/content/firebug/cookies/cookiePanel.js
@@ -37,7 +37,6 @@ const Cc = Components.classes;
const Ci = Components.interfaces;
// Cookies preferences
-const logEventsPref = "cookies.logEvents";
const showRejectedCookies = "cookies.showRejectedCookies";
const lastSortedColumn = "cookies.lastSortedColumn";
const hiddenColsPref = "cookies.hiddenColumns";
@@ -297,16 +296,16 @@ CookiePanel.prototype = Obj.extend(Firebug.ActivablePanel,
this.showToolbarButtons("fbCookieButtons", false);
},
+ // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// Options menu
+
getOptionsMenuItems: function(context)
{
return [
MenuUtils.optionAllowGlobally(context, "cookies.AllowGlobally",
"cookies.tip.AllowGlobally", "network.cookie", "cookieBehavior"),
/*MenuUtils.optionMenu(context, "cookies.clearWhenDeny",
"cookies.tip.clearWhenDeny", Firebug.prefDomain, clearWhenDeny),*/
- MenuUtils.optionMenu(context, "cookies.LogEvents",
- "cookies.tip.LogEvents", Firebug.prefDomain, logEventsPref),
MenuUtils.optionMenu(context, "cookies.Confirm cookie removal",
"cookies.tip.Confirm cookie removal", Firebug.prefDomain, removeConfirmation)
];
@@ -455,6 +454,7 @@ CookiePanel.prototype = Obj.extend(Firebug.ActivablePanel,
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// Console Panel Listeners
+
onFilterSet: function(logTypes)
{
logTypes.cookies = 1;
View
7 extension/content/firebug/firebug.js
@@ -1188,6 +1188,13 @@ window.Firebug =
},
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+ dispatch: function(listeners, eventId, args)
+ {
+ Events.dispatch(listeners, eventId, args);
+ },
+
+ // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// URL mapping
getObjectByURL: function(context, url)
View
24 extension/content/firebug/firefox/bindings.xml
@@ -807,8 +807,9 @@
var panel = this.panelBar.selectedPanel;
if (!panel)
return;
-
- var panelItems = panel ? panel.getOptionsMenuItems(Firebug.currentContext) : null;
+
+ var panelItems = this.getOptionsMenuItems(panel);
+
if (!panel.activable && !(panelItems && panelItems.length))
this.setAttribute("collapsed", "true");
else
@@ -828,6 +829,23 @@
rtlLanguage ? "topright" : "topleft");
]]></body>
</method>
+
+ <method name="getOptionsMenuItems">
+ <parameter name="panel"/>
+ <body><![CDATA[
+ if (!panel)
+ return null;
+
+ // Get menu items from the current panel.
+ var context = Firebug.currentContext;
+ var items = panel.getOptionsMenuItems(context);
+
+ // Distribute to listeners so, other modules/extensions can extend the menu.
+ Firebug.dispatch(Firebug.uiListeners, "onOptionsMenu", [context, panel, items]);
+
+ return items;
+ ]]></body>
+ </method>
</implementation>
<handlers>
@@ -860,7 +878,7 @@
if (panel)
{
// Get panel's option items
- var panelItems = panel.getOptionsMenuItems(Firebug.currentContext);
+ var panelItems = this.getOptionsMenuItems(panel);
if (panelItems && panelItems.length > 0)
items.push("-");
}
View
6 extension/locale/en-US/cookies.properties
@@ -10,11 +10,11 @@ cookies.Session=Session
cookies.AllowGlobally=Accept Cookies From Sites
cookies.tip.AllowGlobally=Accept all cookies by default or block all cookies by default
-# LOCALIZATION NOTE (cookies.LogEvents, cookies.tip.LogEvents):
+# LOCALIZATION NOTE (cookies.showCookieEvents, cookies.tip.showCookieEvents):
# Label used in Cookies panel options menu (the small arrow next to the Cookies panel label).
# If checked, various cookies events are displayed in Firebug's Console panel.
-cookies.LogEvents=Show Logs in Console
-cookies.tip.LogEvents=Use to display various cookie events (changed, deleted) in the Console panel
+cookies.showCookieEvents=Show Cookie Events
+cookies.tip.showCookieEvents=Log cookie events (changed, deleted) into the console
# LOCALIZATION NOTE (cookies.clearWhenDeny): Label used in Cookies panel options menu (the
# small arrow next to the Cookies panel label). If checked, cookies are automatically removed

0 comments on commit 16c3a36

Please sign in to comment.
Something went wrong with that request. Please try again.