OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 'use strict'; | 5 'use strict'; |
6 | 6 |
7 /** | 7 /** |
8 * @fileoverview Utility objects and functions for Google Now extension. | 8 * @fileoverview Utility objects and functions for Google Now extension. |
9 * Most important entities here: | 9 * Most important entities here: |
10 * (1) 'wrapper' is a module used to add error handling and other services to | 10 * (1) 'wrapper' is a module used to add error handling and other services to |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
134 message: errorText, | 134 message: errorText, |
135 file: file, | 135 file: file, |
136 line: line, | 136 line: line, |
137 trace: filteredStack | 137 trace: filteredStack |
138 }; | 138 }; |
139 | 139 |
140 var request = buildServerRequest('POST', 'jserrors', 'application/json'); | 140 var request = buildServerRequest('POST', 'jserrors', 'application/json'); |
141 request.onloadend = function(event) { | 141 request.onloadend = function(event) { |
142 console.log('sendErrorReport status: ' + request.status); | 142 console.log('sendErrorReport status: ' + request.status); |
143 }; | 143 }; |
144 request.send(JSON.stringify(errorObject)); | 144 |
145 chrome.identity.getAuthToken({interactive: false}, function(token) { | |
146 if (token) { | |
147 request.setRequestHeader('Authorization', 'Bearer ' + token); | |
robliao
2013/10/23 22:24:15
setAuthorization reusuable here?
vadimt
2013/10/23 22:32:23
Nope, since it does stuff that we don't need here
| |
148 request.send(JSON.stringify(errorObject)); | |
149 } | |
150 }); | |
145 } | 151 } |
146 | 152 |
147 // Limiting 1 error report per background page load. | 153 // Limiting 1 error report per background page load. |
148 var errorReported = false; | 154 var errorReported = false; |
149 | 155 |
150 /** | 156 /** |
151 * Reports an error to the server and the user, as appropriate. | 157 * Reports an error to the server and the user, as appropriate. |
152 * @param {Error} error Error to report. | 158 * @param {Error} error Error to report. |
153 */ | 159 */ |
154 function reportError(error) { | 160 function reportError(error) { |
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
742 // Poll for the sign in state every hour. | 748 // Poll for the sign in state every hour. |
743 // One hour is just an arbitrary amount of time chosen. | 749 // One hour is just an arbitrary amount of time chosen. |
744 chrome.alarms.create(alarmName, {periodInMinutes: 60}); | 750 chrome.alarms.create(alarmName, {periodInMinutes: 60}); |
745 | 751 |
746 return { | 752 return { |
747 addListener: addListener, | 753 addListener: addListener, |
748 isSignedIn: isSignedIn, | 754 isSignedIn: isSignedIn, |
749 removeToken: removeToken | 755 removeToken: removeToken |
750 }; | 756 }; |
751 } | 757 } |
OLD | NEW |