Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/globalhistory.py
diff options
context:
space:
mode:
authorManuel QuiƱones <manuq@laptop.org>2012-01-06 14:22:48 (GMT)
committer Simon Schampijer <simon@schampijer.de>2012-01-06 19:25:24 (GMT)
commitd50001dc6f26b31e39689a20a6540ad4f2e525ba (patch)
treec418ab0448f2eb471c216695766f089b3c399ca5 /globalhistory.py
parent766ae15770617580c0cba22a7118d13dc175d3cc (diff)
Global history for URL autocompletion in URL entry
The sqlite backend to store the global history is maintained. There are two fields in the database that are left unused: bookmark and gecko_flags. Signed-off-by: Manuel QuiƱones <manuq@laptop.org> Acked-by: Simon Schampijer <simon@laptop.org>
Diffstat (limited to 'globalhistory.py')
-rw-r--r--globalhistory.py55
1 files changed, 12 insertions, 43 deletions
diff --git a/globalhistory.py b/globalhistory.py
index 1ec0a72..e93cdab 100644
--- a/globalhistory.py
+++ b/globalhistory.py
@@ -16,65 +16,34 @@
from datetime import datetime
-from xpcom import components
-from xpcom.components import interfaces
-from xpcom.server.factory import Factory
-
import places
+_global_history = None
-class GlobalHistory:
- _com_interfaces_ = interfaces.nsIGlobalHistory, \
- interfaces.nsIGlobalHistory2, \
- interfaces.nsIGlobalHistory3
-
- cid = '{2a53cf28-c48e-4a01-ba18-3d3fef3e2985}'
- description = 'Sugar Global History'
+class GlobalHistory(object):
def __init__(self):
self._store = places.get_store()
- def addPage(self, url):
- self.addURI(url, False, True, None)
-
- def isVisited(self, uri):
- place = self._store.lookup_place(uri.spec)
- return place != None
-
- def addURI(self, uri, redirect, toplevel, referrer):
- place = self._store.lookup_place(uri.spec)
+ def add_page(self, uri):
+ place = self._store.lookup_place(uri)
if place:
place.visits += 1
place.last_visit = datetime.now()
self._store.update_place(place)
else:
- place = places.Place(uri.spec)
+ place = places.Place(uri)
self._store.add_place(place)
- def setPageTitle(self, uri, title):
- place = self._store.lookup_place(uri.spec)
+ def set_page_title(self, uri, title):
+ place = self._store.lookup_place(uri)
if place:
place.title = title
self._store.update_place(place)
- def addDocumentRedirect(self, old_channel, new_channel, flags, toplevel):
- pass
-
- def getURIGeckoFlags(self, uri):
- place = self._store.lookup_place(uri.spec)
- if place:
- return place.gecko_flags
- else:
- return 0
-
- def setURIGeckoFlags(self, uri, flags):
- place = self._store.lookup_place(uri.spec)
- if place:
- place.gecko_flags = flags
- self._store.update_place(place)
-
-components.registrar.registerFactory(GlobalHistory.cid,
- GlobalHistory.description,
- '@mozilla.org/browser/global-history;2',
- Factory(GlobalHistory))
+def get_global_history():
+ global _global_history
+ if _global_history == None:
+ _global_history = GlobalHistory()
+ return _global_history