-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbrowser.py
37 lines (28 loc) · 1.18 KB
/
browser.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import urlparse
import fetchers.urllib2Wrapper as urllib2Wrapper
# This file will contain all the parts needed for getting documents and interfacing with the filesystem and Internet
class Browser (object):
"""
The Browser class holds all the data and handles all the
functionality related to a single browser instance
This includes (but probably isn't limited to):
- Fetching resources from URIs
- Getting/Setting/handling cookies
- Managing History (allowing forward/back functionality)
- Managing multiple "contexts", each which has its own histories, but
shares things like cookies. Think tabs or windows within the same
browser instance
"""
def __init__(self, dom, renderer, ui, layout):
self.dom = dom
self.renderer = renderer
self.ui = ui
self.layout = layout
self.fetchers = {'http': urllib2Wrapper.open,
'file': urllib2Wrapper.open}
def open(self, uri):
""" Gets the resource at the specified URI """
# Where are we looking?
url_parts = urlparse.urlparse(uri, 'http')
f = self.fetchers[url_parts.scheme](uri)
return f