1 / 45

Chapter 2 The Mechanism behind Extensions

Chapter 2 The Mechanism behind Extensions. How “Extensions” are implemented. How is it different from plugins. Plugin is a small application that interacts with the main application to provide a certain function. Firefox Extension is like dynamically applied software patch. Patch?.

Download Presentation

Chapter 2 The Mechanism behind Extensions

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 2 The Mechanism behind Extensions

  2. How “Extensions” are implemented

  3. How is it different from plugins

  4. Plugin is a small application that interacts with the main application to provide a certain function.

  5. Firefox Extension is like dynamically applied software patch

  6. Patch?

  7. Index: layout/xul/base/src/nsNativeScrollbarFrame.cpp =================================================================== RCS file: /cvsroot/mozilla/layout/xul/base/src/nsNativeScrollbarFrame.cpp,v retrieving revision 1.22 diff -u -6 -p -r1.22 nsNativeScrollbarFrame.cpp --- layout/xul/base/src/nsNativeScrollbarFrame.cpp 31 Dec 2004 01:13:26 -0000 1.22 +++ layout/xul/base/src/nsNativeScrollbarFrame.cpp 28 Jul 2005 22:06:05 -0000 @@ -342,6 +342,68 @@ nsNativeScrollbarFrame::Hookup()‏ if (!curpos || error)‏ return; scrollbar->SetPosition(curpos); } +NS_IMETHODIMP +nsNativeScrollbarFrame::Paint(nsPresContext* aPresContext, + nsIRenderingContext& aRenderingContext, + const nsRect& aDirtyRect, + nsFramePaintLayer aWhichLayer, + PRUint32 aFlags)‏ +{ + if (NS_FRAME_IS_UNFLOWABLE & mState) { + return NS_OK; + } + + if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) { + PaintSelf(aPresContext, aRenderingContext, aDirtyRect); + } + + return nsBoxFrame::Paint(aPresContext, aRenderingContext, aDirtyRect, + aWhichLayer); +}

  8. Applied dynamically?

  9. Actually,

  10. Key technologies used in Firefox

  11. XUL CSS JavaScript XPCOM

  12. Can all be overwritten and appended after they're built and installed

  13. CSS

  14. XUL

  15. Comparing Overlay and JavaScript+DOM

  16. JavaScript

  17. Example var obj = new Object(); obj.objectProperty = new Object(); obj.objectProperty.newProperty = 'string' obj.objectProperty.parent = obj; obj.myself = obj;

  18. Example var obj = new Object(); obj.name = 'Firefox'; function sayName() { alert(this.name); } obj.sayMyName = sayName; obj.sayMyName(); // says "Firefox"

  19. Sample

  20. window.__original__open = window.open; window.open = function(aURI, aName, aFlag) { if (aURI.indexOf('.google.') > -1)‏ return null; return this.__original__open(aURI, aName, aFlag); }; window.open('http://www.google.co.jp/'); // will be blocked

  21. XPCOM

  22. Keywords for XPCOM

  23. ・Component ・Interface ・Contract ID

  24. Component ↓ Small parts of applications (Libraries)‏

  25. Interface ↓ Input/Output standard for components

  26. Contract ID ↓ Name to identify components

  27. Create a component with Same Interface Same Name as an existing component

  28. Then

  29. You can replace the existing XPCOM component with the user created one

  30. Summary

  31. Different concept from plugins

  32. But it is no ordinary software patch

  33. Because the patch application is dynamic

  34. XUL CSS JavaScript Are all interpretive, so they don't require compilers

  35. Firefox can be configured and modified in every way after it is built and installed

  36. Extension traits

  37. Conclusion

  38. Extensions are very powerful customization tools when compared to plugins and conventional patches

More Related