All users were logged out of Bugzilla on October 13th, 2018

Add a nsIAboutModule flag to hide about: pages from about:about

RESOLVED FIXED

Status

()

RESOLVED FIXED
9 years ago
7 years ago

People

(Reporter: steffen.wilberg, Assigned: steffen.wilberg)

Tracking

Trunk
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(URL)

Attachments

(1 attachment, 1 obsolete attachment)

(Assignee)

Description

9 years ago
about:about (aboutAbout.xhtml) uses a hardcoded blacklist for "about" pages which aren't useful to show because they require query strings ("blank", "blocked", "cache-entry", "certerror", "feeds", "neterror").

bz suggested to add a new nsIAboutModule flag instead.
(Assignee)

Comment 1

9 years ago
Created attachment 420629 [details] [diff] [review]
doesn't build

I added the flag HIDE_FROM_ABOUTABOUT to nsIAboutModule.idl and the respective protocol handlers.

But how do I access this flag from script?
Error: Components.classes['@mozilla.org/network/protocol/about;1'] is undefined
Source file: about:about
Line: 21

I experimented a bit with nsNetCID.h and nsNetModule.cpp, but the build fails with this error:
m:/trunk/netwerk/build/nsNetModule.cpp(1033) : error C2065: 'nsIAboutModuleConst
ructor' : undeclared identifier

That's not really surprising, but I don't know how to continue from here.
Assignee: nobody → steffen.wilberg
I don't think you need the nsNetCID/nsNetModule changes.

Once you've added the flags, I think this should work in the js:

  if (result) {
    var aboutType = result[1];
    var contract = "@mozilla.org/network/protocol/about;1?what=" + aboutType;
    try {
      var am = Components.classes[contract]
                         .getService(Components.interfaces.nsIAboutModule);
      var uri = newURI("about:"+aboutType);
      var flags = am.getURIFlags(uri);
      if (!(flags & 
            Components.interfaces.nsIAboutModule.HIDE_FROM_ABOUTABOUT)) {
        gProtocols.push(aboutType);
      }
    } catch (e) {
      // getService might have thrown if the component doesn't actually
      // implement nsIAboutModule
    }
  }

where "newURI" is whatever the current best way of doing that in JS is (using NetUtil or manually via ioservice or whatever).
(Assignee)

Comment 3

9 years ago
Created attachment 420831 [details] [diff] [review]
v1

Thanks for your help, Boris!
I don't think using NetUtil.jsm to call newURI provides much benefit here, apart from making the second and third argument optional.
Attachment #420629 - Attachment is obsolete: true
Attachment #420831 - Flags: superreview?(bzbarsky)
Attachment #420831 - Flags: review?(mano)
Comment on attachment 420831 [details] [diff] [review]
v1

Looks good.  Thanks for doing this!
Attachment #420831 - Flags: superreview?(bzbarsky) → superreview+
Please add nsIAboutModule::HIDE_FROM_ABOUTABOUT to "licence" (with a 'c') so that both "license" and "licence" aren't displayed. This will fix bug 538926.
Blocks: 538926
(Assignee)

Comment 7

9 years ago
http://hg.mozilla.org/mozilla-central/rev/97c7954d972d
Status: NEW → RESOLVED
Last Resolved: 9 years ago
Resolution: --- → FIXED
(Assignee)

Updated

7 years ago
No longer blocks: 538926
You need to log in before you can comment on or make changes to this bug.