Module: Vapir::Firefox::ClearTracksMethods

Included in:
Vapir::Firefox, Vapir::Firefox
Defined in:
lib/vapir-firefox/clear_tracks.rb

Instance Method Summary collapse

Instance Method Details

#clear_all_tracksObject



34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/vapir-firefox/clear_tracks.rb', line 34

def clear_all_tracks
  sanitizer.items.to_hash.inject({}) do |hash, (key, item)|
    # don't try to clear siteSettings; sometimes siteSettings.clear() raises 
    # an error which jssh doesn't handle properly - it somehow bypasses the 
    # try/catch block and shows up on the socket outside of the returned value. 
    # jssh bug? 
    if key!='siteSettings' && hash[key].canClear 
      hash[key]=(item.clear() rescue $!)
    end
    hash
  end
end

#clear_cacheObject Also known as: clear_temporary_files

cookie_manager = firefox_socket.Components.classes.getService(firefox_socket.Components.interfaces.nsICookieManager) cookie_manager.removeAll()



30
31
32
# File 'lib/vapir-firefox/clear_tracks.rb', line 30

def clear_cache
  sanitizer.items.cache.clear
end

#clear_cookiesObject



25
26
27
28
29
# File 'lib/vapir-firefox/clear_tracks.rb', line 25

def clear_cookies
  sanitizer.items.cookies.clear()
  #cookie_manager = firefox_socket.Components.classes["@mozilla.org/cookiemanager;1"].getService(firefox_socket.Components.interfaces.nsICookieManager)
  #cookie_manager.removeAll()
end

#clear_historyObject



22
23
24
# File 'lib/vapir-firefox/clear_tracks.rb', line 22

def clear_history
  sanitizer.items.history.clear()
end

#sanitizerObject

currently defined sanitizer items are:

["cache", "cookies", "offlineApps", "history", "formdata", "downloads", "passwords", "sessions", "siteSettings"]


10
11
12
13
14
15
16
17
18
19
20
# File 'lib/vapir-firefox/clear_tracks.rb', line 10

def sanitizer # :nodoc:
  @@sanitizer ||= begin
    sanitizer_class = firefox_socket.root['Sanitizer']
    unless sanitizer_class
      loader = firefox_socket.Components.classes["@mozilla.org/moz/jssubscript-loader;1"].getService(firefox_socket.Components.interfaces.mozIJSSubScriptLoader)
      loader.loadSubScript("chrome://browser/content/sanitize.js")
      sanitizer_class = firefox_socket.root['Sanitizer']
    end
    sanitizer_class.new
  end
end