Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Side by Side Diff: remoting/client/appengine/main.py

Issue 7033042: Update the appengine code to use OAuth2 and break the gdata dependency. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove the hardcoded localhost Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 2
3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. 3 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 import logging 7 import logging
8 import os 8 import os
9 9
10 from django.utils import simplejson as json 10 from django.utils import simplejson as json
11 11
12 import gdata.gauth
13 import gdata.client
14
15 from google.appengine.api import users 12 from google.appengine.api import users
16 from google.appengine.ext import webapp 13 from google.appengine.ext import webapp
17 from google.appengine.ext.webapp import template 14 from google.appengine.ext.webapp import template
18 from google.appengine.ext.webapp import util 15 from google.appengine.ext.webapp import util
19 from google.appengine.ext.webapp.util import login_required 16 from google.appengine.ext.webapp.util import login_required
20 17
21 import auth 18 import auth
22 19
23 class HostListHandler(webapp.RequestHandler): 20 class HostListHandler(webapp.RequestHandler):
24 """Renders the main hostlist page.""" 21 """Renders the main hostlist page."""
25 @login_required 22 @login_required
26 def get(self): 23 def get(self):
27 template_params = { 24 template_params = {
28 'chromoting_token': auth.GetChromotingToken(throws=False), 25 'has_oauth2_tokens': auth.HasOAuth2Tokens(),
29 'xmpp_token': auth.GetXmppToken(throws=False) 26 'xmpp_token': auth.GetXmppToken(throws=False)
30 } 27 }
31 path = os.path.join(os.path.dirname(__file__), 'hostlist.html') 28 path = os.path.join(os.path.dirname(__file__), 'hostlist.html')
32 self.response.out.write(template.render(path, template_params)) 29 self.response.out.write(template.render(path, template_params))
33 30
34 31
35 class ChromotingSessionHandler(webapp.RequestHandler): 32 class ChromotingSessionHandler(webapp.RequestHandler):
36 """Renders one Chromoting session.""" 33 """Renders one Chromoting session."""
37 @login_required 34 @login_required
38 def get(self): 35 def get(self):
39 template_params = { 36 template_params = {
40 'hostname': self.request.get('hostname'), 37 'hostname': self.request.get('hostname'),
41 'username': users.get_current_user().email(), 38 'username': users.get_current_user().email(),
42 'hostjid': self.request.get('hostjid'), 39 'hostjid': self.request.get('hostjid'),
43 'connect_method': self.request.get('connect_method'), 40 'connect_method': self.request.get('connect_method'),
44 'insecure': self.request.get('insecure'), 41 'insecure': self.request.get('insecure'),
45 'xmpp_token': auth.GetXmppToken(), 42 'xmpp_token': auth.GetXmppToken(),
46 'http_xmpp_proxy': auth.GetHttpXmppProxy(), 43 'http_xmpp_proxy': self.request.get('http_xmpp_proxy')
47 } 44 }
48 path = os.path.join(os.path.dirname(__file__), 'chromoting_session.html') 45 path = os.path.join(os.path.dirname(__file__), 'chromoting_session.html')
49 self.response.out.write(template.render(path, template_params)) 46 self.response.out.write(template.render(path, template_params))
50 47
51 48
52 def main(): 49 def main():
53 application = webapp.WSGIApplication( 50 application = webapp.WSGIApplication(
54 [ 51 [
55 ('/', HostListHandler), 52 ('/', HostListHandler),
56 ('/session', ChromotingSessionHandler), 53 ('/session', ChromotingSessionHandler),
57 ], 54 ],
58 debug=True) 55 debug=True)
59 util.run_wsgi_app(application) 56 util.run_wsgi_app(application)
60 57
61 58
62 if __name__ == '__main__': 59 if __name__ == '__main__':
63 main() 60 main()
OLDNEW
« no previous file with comments | « remoting/client/appengine/hostlist.html ('k') | remoting/client/appengine/static_files/client.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698