Changeset 2526
- Timestamp:
- 11/14/08 13:38:37 (8 weeks ago)
- Location:
- trunk/digitalme/launchers/firefox-addon
- Files:
-
- 5 added
- 7 modified
-
CMakeLists.txt (modified) (2 diffs)
-
xul/chrome/content/DigitalMe.xul (added)
-
xul/chrome/content/IdentitySelector.js (modified) (80 diffs)
-
xul/chrome/content/IdentitySelector.xul (modified) (1 diff)
-
xul/chrome/content/IdentitySelectorDiag.js (added)
-
xul/chrome/content/IdentitySelectorPrefs.js (added)
-
xul/chrome/content/IdentitySelectorUtil.js (added)
-
xul/chrome/content/Intercept.js (modified) (3 diffs)
-
xul/chrome/content/NoIdentitySelector.js (added)
-
xul/chrome/content/cbis.js (modified) (36 diffs)
-
xul/chrome/content/cbisPrefs.js (modified) (5 diffs)
-
xul/chrome/content/cbisPrefs.xul (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/digitalme/launchers/firefox-addon/CMakeLists.txt
r2525 r2526  66 66 COMMAND ${CMAKE_COMMAND} -E echo " <em:version>0.4.${PROJECT_REVISION}</em:version>" >> ${INSTALL_RDF_FILE} 67 67 COMMAND ${CMAKE_COMMAND} -E echo " <em:description>Enables browser support for websites that use information cards</em:description>" >> ${INSTALL_RDF_FILE} 68  COMMAND ${CMAKE_COMMAND} -E echo " <em:iconURL>chrome://identityselector/content/ cbisicon.png</em:iconURL>" >> ${INSTALL_RDF_FILE}Â69  COMMAND ${CMAKE_COMMAND} -E echo " <em:optionsURL>chrome://identityselector/content/ cbisPrefs.xul</em:optionsURL>" >> ${INSTALL_RDF_FILE} 68 COMMAND ${CMAKE_COMMAND} -E echo " <em:iconURL>chrome://identityselector/content/DigitalMeIcon.png</em:iconURL>" >> ${INSTALL_RDF_FILE}  69 COMMAND ${CMAKE_COMMAND} -E echo " <em:optionsURL>chrome://identityselector/content/DigitalMePrefs.xul</em:optionsURL>" >> ${INSTALL_RDF_FILE} 70 70 COMMAND ${CMAKE_COMMAND} -E echo " <!-- Firefox -->" >> ${INSTALL_RDF_FILE} 71 71 COMMAND ${CMAKE_COMMAND} -E echo " <em:targetApplication>" >> ${INSTALL_RDF_FILE} … …  95 95 DEPENDS ${PACKAGE_STAGE_DIR}  96 96 DEPENDS ${INSTALL_RDF_FILE}  97  97 98 COMMAND ${CMAKE_COMMAND} -E copy COPYING ${PACKAGE_STAGE_DIR} 98 99 COMMAND ${CMAKE_COMMAND} -E copy COPYRIGHT ${PACKAGE_STAGE_DIR} 99 100 COMMAND ${CMAKE_COMMAND} -E copy xul/chrome.manifest ${PACKAGE_STAGE_DIR}  101  100 102 COMMAND mkdir -p ${PACKAGE_STAGE_DIR}/chrome/content 101  COMMAND ${CMAKE_COMMAND} -E copy xul/chrome/content/cbisicon.png ${PACKAGE_STAGE_DIR}/chrome/content  103   104 COMMAND ${CMAKE_COMMAND} -E copy xul/chrome/content/IdentitySelector.xul ${PACKAGE_STAGE_DIR}/chrome/content 102 105 COMMAND ${CMAKE_COMMAND} -E copy xul/chrome/content/IdentitySelector.js ${PACKAGE_STAGE_DIR}/chrome/content 103  COMMAND ${CMAKE_COMMAND} -E copy xul/chrome/content/IdentitySelector .xul${PACKAGE_STAGE_DIR}/chrome/contentÂ104  COMMAND ${CMAKE_COMMAND} -E copy xul/chrome/content/ cbis.js ${PACKAGE_STAGE_DIR}/chrome/contentÂ105  COMMAND ${CMAKE_COMMAND} -E copy xul/chrome/content/ cbisPrefs.xul${PACKAGE_STAGE_DIR}/chrome/contentÂ106  COMMAND ${CMAKE_COMMAND} -E copy xul/chrome/content/ cbisPrefs.js ${PACKAGE_STAGE_DIR}/chrome/content 106 COMMAND ${CMAKE_COMMAND} -E copy xul/chrome/content/IdentitySelectorDiag.js ${PACKAGE_STAGE_DIR}/chrome/content  107 COMMAND ${CMAKE_COMMAND} -E copy xul/chrome/content/IdentitySelectorPrefs.js ${PACKAGE_STAGE_DIR}/chrome/content  108 COMMAND ${CMAKE_COMMAND} -E copy xul/chrome/content/IdentitySelectorUtil.js ${PACKAGE_STAGE_DIR}/chrome/content  109 COMMAND ${CMAKE_COMMAND} -E copy xul/chrome/content/NoIdentitySelector.js ${PACKAGE_STAGE_DIR}/chrome/content 107 110 COMMAND ${CMAKE_COMMAND} -E copy xul/chrome/content/Intercept.js ${PACKAGE_STAGE_DIR}/chrome/content  111   112 COMMAND ${CMAKE_COMMAND} -E copy xul/chrome/content/DigitalMe.xul ${PACKAGE_STAGE_DIR}/chrome/content  113 COMMAND ${CMAKE_COMMAND} -E copy xul/chrome/content/DigitalMe.js ${PACKAGE_STAGE_DIR}/chrome/content  114   115 COMMAND ${CMAKE_COMMAND} -E copy xul/chrome/content/DigitalMePrefs.xul ${PACKAGE_STAGE_DIR}/chrome/content  116 COMMAND ${CMAKE_COMMAND} -E copy xul/chrome/content/DigitalMePrefs.js ${PACKAGE_STAGE_DIR}/chrome/content  117   118 COMMAND ${CMAKE_COMMAND} -E copy xul/chrome/content/DigitalMeIcon.png ${PACKAGE_STAGE_DIR}/chrome/content  119  108 120 COMMAND mkdir -p ${PACKAGE_STAGE_DIR}/defaults/preferences 109 121 COMMAND mkdir -p ${PACKAGE_STAGE_DIR}/components -
trunk/digitalme/launchers/firefox-addon/xul/chrome/content/IdentitySelector.js
r2525 r2526  22 22 // ************************************************************************** 23 23  24  constnsIX509Cert = Components.interfaces.nsIX509Cert;Â25   26  constnsIX509CertDB = Components.interfaces.nsIX509CertDB;Â27  constnsX509CertDB = "@mozilla.org/security/x509certdb;1";Â28   29  constnsINSSCertCache = Components.interfaces.nsINSSCertCache;Â30  constnsNSSCertCache = "@mozilla.org/security/nsscertcache;1";Â31   32  constnsICertTree = Components.interfaces.nsICertTree;Â33  constnsCertTree = "@mozilla.org/security/nsCertTree;1";Â34   35  constnsILocalFile = Components.interfaces.nsILocalFile;Â36  constnsLocalFile = "@mozilla.org/file/local;1";Â37   38  constnsIFileOutputStream = Components.interfaces.nsIFileOutputStream;Â39  constnsFileOutputStream = "@mozilla.org/network/file-output-stream;1";Â40   41  constnsICardObjTypeStr = "application/x-informationcard"; 24 var nsIX509Cert = Components.interfaces.nsIX509Cert;  25   26 var nsIX509CertDB = Components.interfaces.nsIX509CertDB;  27 var nsX509CertDB = "@mozilla.org/security/x509certdb;1";  28   29 var nsINSSCertCache = Components.interfaces.nsINSSCertCache;  30 var nsNSSCertCache = "@mozilla.org/security/nsscertcache;1";  31   32 var nsICertTree = Components.interfaces.nsICertTree;  33 var nsCertTree = "@mozilla.org/security/nsCertTree;1";  34   35 var nsILocalFile = Components.interfaces.nsILocalFile;  36 var nsLocalFile = "@mozilla.org/file/local;1";  37   38 var nsIFileOutputStream = Components.interfaces.nsIFileOutputStream;  39 var nsFileOutputStream = "@mozilla.org/network/file-output-stream;1";  40   41 var nsICardObjTypeStr = "application/x-informationcard"; 42 42  43 43 // ************************************************************************** … …  45 45 // ************************************************************************** 46 46  47  var gPrefService = Components.classes[Â48  "@mozilla.org/preferences-service;1"].Â49  getService( Components.interfaces.nsIPrefBranch);Â50  var gConsoleService = Components.classes[ "@mozilla.org/consoleservice;1"].Â51  getService( Components.interfaces.nsIConsoleService);Â52  var gbLoggingEnabled = false;Â53 47 var gLastFailedGetTokenDate = null; 54 48 var gDisableStartTime = null; … …  56 50  57 51 // ************************************************************************** 58  // Desc: Other global variablesÂ59  // **************************************************************************Â60  Â61  var gNavPlat = navigator.platform;Â62  var gbIsWin = ((gNavPlat.indexOf( "Win") > -1) ? true : false);Â63  var gbIsMac = ((gNavPlat.indexOf( "Mac") > -1) ? true : false);Â64  var gbIsLinux = ((gNavPlat.indexOf( "Linux") > -1) ? true : false);Â65  Â66  // **************************************************************************Â67 52 // Desc: 68 53 // ************************************************************************** 69 54  70  var ICProgressListener =Â71  {Â72  QueryInterface : function( aIID)Â73  {Â74  if( aIID.equals( Components.interfaces.nsIWebProgressListener) ||Â75  aIID.equals( Components.interfaces.nsISupportsWeakReference) ||Â76  aIID.equals( Components.interfaces.nsISupports))Â77  {Â78  return( this);Â79  }Â80  Â81  throw Components.results.NS_NOINTERFACE;Â82  },Â83  Â84  onStateChange : function( aProgress, aRequest, aFlag, aStatus)Â85  {Â86  var progListIFace = Components.interfaces.nsIWebProgressListener;Â87  Â88  // Log the flagsÂ89  Â90  IdentitySelector.logMessage( "onStateChange", "flags = " + aFlag);Â91  Â92  if( aFlag & progListIFace.STATE_IS_DOCUMENT)Â93  {Â94  IdentitySelector.logMessage( "onStateChange", "flag & document");Â95  }Â96  Â97  if( aFlag & progListIFace.STATE_IS_WINDOW)Â98  {Â99  IdentitySelector.logMessage( "onStateChange", "flag & window");Â100  }Â101  Â102  if( aFlag & progListIFace.STATE_START)Â103  {Â104  IdentitySelector.logMessage( "onStateChange", "flag & start");Â105  }Â106  Â107  if( aFlag & progListIFace.STATE_STOP)Â108  {Â109  IdentitySelector.logMessage( "onStateChange", "flag & stop");Â110  }Â111  Â112  // Process the document. The 'STOP' state isn't reached until afterÂ113  // the page is fully loaded and all onload events have completed.Â114  // We need to re-process the page in case an onload event addedÂ115  // information card elements or objects to the page. An example ofÂ116  // a page that does this is login.live.com.Â117  Â118  if( aFlag & progListIFace.STATE_STOP)Â119  {Â120  if( aFlag & progListIFace.STATE_IS_WINDOW)Â121  {Â122  IdentitySelector.logMessage( "onStateChange",Â123  "stop status code = " + aStatus);Â124  Â125  if( aStatus == 0)Â126  {Â127  // Process any information card itemsÂ128  Â129  tryÂ130  {Â131  IdentitySelector.processICardItems(Â132  aProgress.DOMWindow.document, true);Â133  }Â134  catch( e)Â135  {Â136  alert( e);Â137  }Â138  }Â139  }Â140  }Â141  Â142  return( 0);Â143  },Â144  Â145  onLocationChange : function( aProgress, aRequest, aURI)Â146  {Â147  // This fires when a load event has been confirmed or when theÂ148  // user switches tabs. At this point, Firefox has created a skeletalÂ149  // document into which the source document will be loaded. This isÂ150  // where we run our global intercept script.Â151  Â152  tryÂ153  {Â154  IdentitySelector.runInterceptScript( aProgress.DOMWindow.document);Â155  }Â156  catch( e)Â157  {Â158  if( gDebugMode)Â159  {Â160  IdentitySelector.reportError( "onLocationChange", e);Â161  }Â162  }Â163  Â164  return( 0);Â165  },Â166  Â167  onProgressChange : function()Â168  {Â169  return( 0);Â170  },Â171  Â172  onStatusChange : function()Â173  {Â174  return( 0);Â175  },Â176  Â177  onSecurityChange : function()Â178  {Â179  return( 0);Â180  },Â181  Â182  onLinkIconAvailable : function()Â183  {Â184  return( 0);Â185  }Â186  };Â187  Â188  // **************************************************************************Â189  // Desc:Â190  // **************************************************************************Â191  Â192 55 var IdentitySelector =  193 56 { 194 57 // *********************************************************************** 195  // Method: reportErrorÂ196  // ***********************************************************************Â197  Â198  reportError : function( location, description)Â199  {Â200  alert( "IdentitySelector Error:" + location + ": " + description);Â201  IdentitySelector.logMessage( location, "Error:" + description);Â202  },Â203  Â204  // ***********************************************************************Â205  // Method: throwErrorÂ206  // ***********************************************************************Â207  Â208  throwError : function( location, description)Â209  {Â210  IdentitySelector.reportError( location, description);Â211  throw( "IdentitySelector Exception:" + location + ": " + description);Â212  },Â213  Â214  // ***********************************************************************Â215  // Method: logMessageÂ216  // ***********************************************************************Â217  Â218  logMessage : function( location, message)Â219  {Â220  if( gbLoggingEnabled)Â221  {Â222  gConsoleService.logStringMessage( "IdentitySelector:" +Â223  location + ": " + message);Â224  }Â225  },Â226  Â227  // ***********************************************************************Â228  // Method: dumpConsoleToLogFileÂ229  // ***********************************************************************Â230  Â231  dumpConsoleLogToFile : function( filePath)Â232  {Â233  var messageArray = {};Â234  var messageCount = {};Â235  var logBuffer = "";Â236  Â237  tryÂ238  {Â239  gConsoleService.getMessageArray( messageArray, messageCount);Â240  Â241  for( var i = 0; i < messageCount.value; i++)Â242  {Â243  var messageStr = messageArray.value[ i].message;Â244  Â245  if( messageStr.indexOf( "IdentitySelector:") > -1)Â246  {Â247  logBuffer += messageStr + "\n";Â248  }Â249  }Â250  Â251  if( gbIsMac || gbIsLinux)Â252  {Â253  IdentitySelector.writeFile( "/tmp/icardxpi.log", logBuffer);Â254  }Â255  }Â256  catch( e)Â257  {Â258  IdentitySelector.reportError( "dumpConsoleLogToFile", e);Â259  }Â260  },Â261  Â262  // ***********************************************************************Â263  // Method: logPlatformInfoÂ264  // ***********************************************************************Â265  Â266  logPlatformInfo : function()Â267  {Â268  tryÂ269  {Â270  IdentitySelector.logMessage( "logPlatformInfo",Â271  "platform = " + navigator.platform);Â272  Â273  IdentitySelector.logMessage( "logPlatformInfo",Â274  "appName = " + navigator.appName);Â275  Â276  IdentitySelector.logMessage( "logPlatformInfo",Â277  "appVersion = " + navigator.appVersion);Â278  Â279  IdentitySelector.logMessage( "logPlatformInfo",Â280  "product = " + navigator.product);Â281  Â282  IdentitySelector.logMessage( "logPlatformInfo",Â283  "productSub = " + navigator.productSub);Â284  Â285  IdentitySelector.logMessage( "logPlatformInfo",Â286  "userAgent = " + navigator.userAgent);Â287  Â288  IdentitySelector.logMessage( "logPlatformInfo",Â289  "oscpu = " + navigator.oscpu);Â290  }Â291  catch( e)Â292  {Â293  }Â294  },Â295  Â296  // ***********************************************************************Â297 58 // Method: onInstall 298 59 // *********************************************************************** … …  324 85 if( !handlerAlreadyInstalled) 325 86 { 326  var event = document.createEvent( "Event");Â327   328  event.initEvent( "IdentitySelectorAvailable", true, true);Â329  top.dispatchEvent( event);Â330  Â331  if( top.IdentitySelectorAvailable == true) 87 var availEvent = document.createEvent( "Event");  88   89 availEvent.initEvent( "IdentitySelectorAvailable", true, true);  90 top.dispatchEvent( availEvent);  91   92 if( top.IdentitySelectorAvailable === true) 332 93 { 333 94 handlerAlreadyInstalled = true; … …  385 146 else 386 147 { 387  IdentitySelector .logMessage( "onInstall",  148 IdentitySelectorDiag.logMessage( "onInstall",  388 149 "Another identity selector is already installed."); 389 150 } … …  391 152 catch( e) 392 153 { 393  IdentitySelector .throwError( "onInstall", e); 154 IdentitySelectorDiag.throwError( "onInstall", e); 394 155 } 395 156 }, … …  444 205 catch( e) 445 206 { 446  IdentitySelector .throwError( "onUninstall", e); 207 IdentitySelectorDiag.throwError( "onUninstall", e); 447 208 } 448 209 }, … …  459 220 } 460 221  461  if( doc.__identityselector__ == undefined) 222 if( doc.__identityselector__ === undefined) 462 223 { 463 224 // Load and execute the script … …  466 227 "@mozilla.org/moz/jssubscript-loader;1"].getService( 467 228 Components.interfaces.mozIJSSubScriptLoader).loadSubScript( 468  "chrome://identityselector/content/Intercept.js", doc) Â469  Â470  IdentitySelector .logMessage( "runInterceptScript",  229 "chrome://identityselector/content/Intercept.js", doc);  230   231 IdentitySelectorDiag.logMessage( "runInterceptScript",  471 232 "Executed script on " + doc.location); 472 233 } … …  488 249 try 489 250 { 490  if( (doc = target.ownerDocument) == undefined) 251 if( (doc = target.ownerDocument) === undefined) 491 252 { 492 253 return; 493 254 } 494 255  495  var event = doc.createEvent( "Event");Â496  event.initEvent( "ICDOMChanged", true, true);Â497  target.dispatchEvent( event); 256 var changedEvent = doc.createEvent( "Event");  257 changedEvent.initEvent( "ICDOMChanged", true, true);  258 target.dispatchEvent( changedEvent); 498 259 } 499 260 catch( e) … …  501 262 if( gDebugMode) 502 263 { 503  IdentitySelector .reportError( "onDOMChanged", e); 264 IdentitySelectorDiag.reportError( "onDOMChanged", e); 504 265 } 505 266 } … …  529 290 // __identityselector__ should be defined. 530 291  531  if( doc.__identityselector__ == undefined) 292 if( doc.__identityselector__ === undefined) 532 293 { 533 294 // Since there are information card items on the page, warn … …  536 297 // disabled. 537 298  538  var jsEnabled = gPrefService.getBoolPref( "javascript.enabled"); 539   540  // Warn if JavaScript is disabled 541   542  if( !jsEnabled) 543  { 544  IdentitySelector.reportError( "onProcessItems",   299 if( !IdentitySelectorUtil.isJavaScriptEnabled())  300 {  301 IdentitySelectorDiag.reportError( "onProcessItems",  545 302 "This page contains information card objects, but " + 546 303 "JavaScript is disabled. The information card " + … …  550 307 else 551 308 { 552  IdentitySelector .reportError( "onProcessItems",  309 IdentitySelectorDiag.reportError( "onProcessItems",  553 310 "This page contains information card objects, but " + 554 311 "the information card selector was unable to fully " + … …  579 336 if( gDebugMode) 580 337 { 581  IdentitySelector .reportError( "onProcessItems", e); 338 IdentitySelectorDiag.reportError( "onProcessItems", e); 582 339 } 583 340 } … …  592 349 try 593 350 {  351 var iLoop; 594 352 var itemCount = 0; 595 353  … …  599 357 var icardObjectCount = 0; 600 358  601  IdentitySelector .logMessage( "processICardItems", "Found " +  359 IdentitySelectorDiag.logMessage( "processICardItems", "Found " +  602 360 objElems.length + " object(s) on " + doc.location); 603 361  604  for( var i = 0; i < objElems.length; i++) Â605  { Â606  var objElem = objElems[ i ]; 362 for( iLoop = 0; iLoop < objElems.length; iLoop++)   363 {  364 var objElem = objElems[ iLoop]; 607 365 var objTypeStr = objElem.getAttribute( "TYPE"); 608 366  609  if( (objTypeStr != null &&  367 if( (objTypeStr !== null &&  610 368 objTypeStr.toLowerCase() == nsICardObjTypeStr) || 611 369 objElem._type == nsICardObjTypeStr) … …  622 380 } 623 381  624  IdentitySelector .logMessage( "processICardItems", "Found " +  382 IdentitySelectorDiag.logMessage( "processICardItems", "Found " +  625 383 icardObjectCount + " ICard object(s) on " + doc.location); 626 384  … …  632 390 if( dispatchEvents) 633 391 { 634  for( var i = 0; i < icardElems.length; i++) Â635  { Â636  var icardElem = icardElems[ i ];Â637  Â638  var event = doc.createEvent( "Event");Â639  e vent.initEvent( "ICElementLoaded", true, true);Â640  icardElem.dispatchEvent( e vent);Â641  } Â642  } Â643  Â644  IdentitySelector .logMessage( "processICardItems", "Found " +  392 for( iLoop = 0; iLoop < icardElems.length; iLoop++)   393 {  394 var icardElem = icardElems[ iLoop];  395 var elementEvent = doc.createEvent( "Event");  396   397 elementEvent.initEvent( "ICElementLoaded", true, true);  398 icardElem.dispatchEvent( elementEvent);  399 }  400 }  401   402 IdentitySelectorDiag.logMessage( "processICardItems", "Found " +  645 403 icardElementCount + " ICard element(s) on " + doc.location); 646 404  … …  651 409 if( gDebugMode)Â