home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2008 February / PCWFEB08.iso / Software / Freeware / Miro 1.0 / Miro_Installer.exe / components / mycontentpolicy.py < prev    next >
Encoding:
Python Source  |  2007-11-12  |  2.2 KB  |  54 lines

  1. # Miro - an RSS based video player application
  2. # Copyright (C) 2005-2007 Participatory Culture Foundation
  3. #
  4. # This program is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation; either version 2 of the License, or
  7. # (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program; if not, write to the Free Software
  16. # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  17.  
  18. from xpcom import components
  19. import traceback
  20. import sys
  21. import config
  22. import prefs
  23.  
  24. from frontend_implementation import urlcallbacks
  25.  
  26. nsIContentPolicy = components.interfaces.nsIContentPolicy
  27.  
  28. class MyContentPolicy:
  29.     _com_interfaces_ = [nsIContentPolicy]
  30.     _reg_clsid_ = "{CFECB6A2-24AE-48f4-9A7A-87E62B972795}"
  31.     _reg_contractid_ = "@participatoryculture.org/dtv/mycontentpolicy;1"
  32.     _reg_desc_ = "Democracy content policy"
  33.  
  34.     def __init__(self):
  35.         pass
  36.  
  37.     def shouldLoad(self, contentType, contentLocation, requestOrigin, context, mimeTypeGuess,  extra):
  38.         rv = nsIContentPolicy.ACCEPT
  39.         if (requestOrigin is not None and 
  40.                 contentType in (nsIContentPolicy.TYPE_DOCUMENT,
  41.                     nsIContentPolicy.TYPE_SUBDOCUMENT)):
  42.             url = contentLocation.spec
  43.             referrer = requestOrigin.spec
  44.             if not urlcallbacks.runCallback(referrer, url):
  45.                 rv = nsIContentPolicy.REJECT_REQUEST
  46.         return rv
  47.  
  48.     def shouldProcess(self, contentType, contentLocation, requestOrigin, context, mimeType,  extra):
  49.         return nsIContentPolicy.ACCEPT
  50.  
  51. catman = components.classes["@mozilla.org/categorymanager;1"].getService()
  52. catman.queryInterface(components.interfaces.nsICategoryManager)
  53. catman.addCategoryEntry("content-policy", "@participatoryculture.org/dtv/mycontentpolicy;1", "@participatoryculture.org/dtv/mycontentpolicy;1", True, True)
  54.