- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / common / extensions / docs / examples / extensions / gdocs / background.html
1 <!DOCTYPE html>
2 <!--
3  * Copyright (c) 2010 The Chromium Authors. All rights reserved.  Use of this
4  * source code is governed by a BSD-style license that can be found in the
5  * LICENSE file.
6  *
7  * Author: Eric Bidelman <ericbidelman@chromium.org>
8 -->
9 <html>
10   <head>
11     <script type="text/javascript" src="chrome_ex_oauthsimple.js"></script>
12     <script type="text/javascript" src="chrome_ex_oauth.js"></script>
13     <script type="text/javascript">
14       var DOCLIST_SCOPE = 'https://docs.google.com/feeds';
15       var DOCLIST_FEED = DOCLIST_SCOPE + '/default/private/full/';
16       var docs = []; // In memory cache for the user's entire doclist.
17       var refreshRate = localStorage.refreshRate || 300; // 5 min default.
18       var pollIntervalMin = 1000 * refreshRate;
19       var requests = [];
20
21       var oauth = ChromeExOAuth.initBackgroundPage({
22         'request_url': 'https://www.google.com/accounts/OAuthGetRequestToken',
23         'authorize_url': 'https://www.google.com/accounts/OAuthAuthorizeToken',
24         'access_url': 'https://www.google.com/accounts/OAuthGetAccessToken',
25         'consumer_key': 'anonymous',
26         'consumer_secret': 'anonymous',
27         'scope': DOCLIST_SCOPE,
28         'app_name': 'Chrome Extension Sample - Accessing Google Docs with OAuth'
29       });
30
31       function setIcon(opt_badgeObj) {
32         if (opt_badgeObj) {
33           var badgeOpts = {};
34           if (opt_badgeObj && opt_badgeObj.text != undefined) {
35             badgeOpts['text'] = opt_badgeObj.text;
36           }
37           if (opt_badgeObj && opt_badgeObj.tabId) {
38             badgeOpts['tabId'] = opt_badgeObj.tabId;
39           }
40           chrome.browserAction.setBadgeText(badgeOpts);
41         }
42       };
43
44       function clearPendingRequests() {
45         for (var i = 0, req; req = requests[i]; ++i) {
46           window.clearTimeout(req);
47         }
48         requests = [];
49       };
50
51       function logout() {
52         docs = [];
53         setIcon({'text': ''});
54         oauth.clearTokens();
55         clearPendingRequests();
56       };
57     </script>
58   </head>
59   <body>
60   </body>
61 </html>