@@ -76,7 +76,7 @@ class MainFrame(wx.Frame):
7676
7777 def __init__ (self ):
7878 wx .Frame .__init__ (self , parent = None , id = wx .ID_ANY ,
79- title = 'wxPython example' , size = (600 , 400 ))
79+ title = 'wxPython example' , size = (800 , 600 ))
8080 self .CreateMenu ()
8181
8282 windowInfo = cefpython .WindowInfo ()
@@ -88,7 +88,9 @@ def __init__(self):
8888 # Flash will crash app in CEF 1 on Linux, setting
8989 # plugins_disabled to True.
9090 browserSettings = {"plugins_disabled" : True },
91- navigateUrl = "file://" + GetApplicationPath ("cefsimple.html" ))
91+ navigateUrl = "file://" + GetApplicationPath ("wxpython.html" ))
92+
93+ self .browser .SetClientHandler (ClientHandler ())
9294
9395 self .Bind (wx .EVT_CLOSE , self .OnClose )
9496 if USE_EVT_IDLE :
@@ -115,6 +117,29 @@ def OnIdle(self, event):
115117 print ("wxpython.py: OnIdle() %d" % self .idleCount )
116118 cefpython .MessageLoopWork ()
117119
120+ class ClientHandler :
121+
122+ # Request handler, see documentation at:
123+ # https://code.google.com/p/cefpython/wiki/RequestHandler
124+
125+ def OnBeforeBrowse (self , browser , frame , request , navType , isRedirect ):
126+ # frame.GetUrl() returns current url
127+ # request.GetUrl() returns new url
128+ # Return true to cancel the navigation or false to allow
129+ # the navigation to proceed.
130+ print ("wxpython.py: OnBeforeBrowse()" )
131+
132+ def OnBeforeResourceLoad (self , browser , request , redirectUrl ,
133+ resourceStream , response , loadFlags ):
134+ print ("wxpython.py: OnBeforeResourceLoad()" )
135+
136+ def OnResourceRedirect (self , browser , oldUrl , newUrl ):
137+ print ("wxpython.py: OnResourceRedirect(): oldUrl: %s, newUrl: %s" % (
138+ oldUrl , newUrl [0 ]))
139+
140+ def OnResourceResponse (self , browser , url , response , contentFilter ):
141+ print ("wxpython.py: OnResourceResponse()" )
142+
118143class MyApp (wx .App ):
119144 timer = None
120145 timerID = 1
0 commit comments