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); |
| 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 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
744 // Poll for the sign in state every hour. | 750 // Poll for the sign in state every hour. |
745 // One hour is just an arbitrary amount of time chosen. | 751 // One hour is just an arbitrary amount of time chosen. |
746 chrome.alarms.create(alarmName, {periodInMinutes: 60}); | 752 chrome.alarms.create(alarmName, {periodInMinutes: 60}); |
747 | 753 |
748 return { | 754 return { |
749 addListener: addListener, | 755 addListener: addListener, |
750 isSignedIn: isSignedIn, | 756 isSignedIn: isSignedIn, |
751 removeToken: removeToken | 757 removeToken: removeToken |
752 }; | 758 }; |
753 } | 759 } |
OLD | NEW |