| 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 // Don't remove 'error.stack.replace' below! | 82 // Don't remove 'error.stack.replace' below! |
| 83 var filteredStack = error.canSendMessageToServer ? | 83 var filteredStack = error.canSendMessageToServer ? |
| 84 error.stack : error.stack.replace(/.*\n/, '(message removed)\n'); | 84 error.stack : error.stack.replace(/.*\n/, '(message removed)\n'); |
| 85 var file; | 85 var file; |
| 86 var line; | 86 var line; |
| 87 var topFrameLineMatch = filteredStack.match(/\n at .*\n/); | 87 var topFrameLineMatch = filteredStack.match(/\n at .*\n/); |
| 88 var topFrame = topFrameLineMatch && topFrameLineMatch[0]; | 88 var topFrame = topFrameLineMatch && topFrameLineMatch[0]; |
| 89 if (topFrame) { | 89 if (topFrame) { |
| 90 // Examples of a frame: | 90 // Examples of a frame: |
| 91 // 1. '\n at someFunction (chrome-extension:// | 91 // 1. '\n at someFunction (chrome-extension:// |
| 92 // pmofbkohncoogjjhahejjfbppikbjigm/background.js:915:15)\n' | 92 // pafkbggdmjlpgkdkcbjmhmfcdpncadgh/background.js:915:15)\n' |
| 93 // 2. '\n at chrome-extension://pmofbkohncoogjjhahejjfbppikbjigm/ | 93 // 2. '\n at chrome-extension://pafkbggdmjlpgkdkcbjmhmfcdpncadgh/ |
| 94 // utility.js:269:18\n' | 94 // utility.js:269:18\n' |
| 95 // 3. '\n at Function.target.(anonymous function) (extensions:: | 95 // 3. '\n at Function.target.(anonymous function) (extensions:: |
| 96 // SafeBuiltins:19:14)\n' | 96 // SafeBuiltins:19:14)\n' |
| 97 // 4. '\n at Event.dispatchToListener (event_bindings:382:22)\n' | 97 // 4. '\n at Event.dispatchToListener (event_bindings:382:22)\n' |
| 98 var errorLocation; | 98 var errorLocation; |
| 99 // Find the the parentheses at the end of the line, if any. | 99 // Find the the parentheses at the end of the line, if any. |
| 100 var parenthesesMatch = topFrame.match(/\(.*\)\n/); | 100 var parenthesesMatch = topFrame.match(/\(.*\)\n/); |
| 101 if (parenthesesMatch && parenthesesMatch[0]) { | 101 if (parenthesesMatch && parenthesesMatch[0]) { |
| 102 errorLocation = | 102 errorLocation = |
| 103 parenthesesMatch[0].substring(1, parenthesesMatch[0].length - 2); | 103 parenthesesMatch[0].substring(1, parenthesesMatch[0].length - 2); |
| 104 } else { | 104 } else { |
| 105 errorLocation = topFrame; | 105 errorLocation = topFrame; |
| 106 } | 106 } |
| 107 | 107 |
| 108 var topFrameElements = errorLocation.split(':'); | 108 var topFrameElements = errorLocation.split(':'); |
| 109 // topFrameElements is an array that ends like: | 109 // topFrameElements is an array that ends like: |
| 110 // [N-3] //pmofbkohncoogjjhahejjfbppikbjigm/utility.js | 110 // [N-3] //pafkbggdmjlpgkdkcbjmhmfcdpncadgh/utility.js |
| 111 // [N-2] 308 | 111 // [N-2] 308 |
| 112 // [N-1] 19 | 112 // [N-1] 19 |
| 113 if (topFrameElements.length >= 3) { | 113 if (topFrameElements.length >= 3) { |
| 114 file = topFrameElements[topFrameElements.length - 3]; | 114 file = topFrameElements[topFrameElements.length - 3]; |
| 115 line = topFrameElements[topFrameElements.length - 2]; | 115 line = topFrameElements[topFrameElements.length - 2]; |
| 116 } | 116 } |
| 117 } | 117 } |
| 118 | 118 |
| 119 var errorText = error.name; | 119 var errorText = error.name; |
| 120 if (error.canSendMessageToServer) | 120 if (error.canSendMessageToServer) |
| (...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 732 // Poll for the sign in state every hour. | 732 // Poll for the sign in state every hour. |
| 733 // One hour is just an arbitrary amount of time chosen. | 733 // One hour is just an arbitrary amount of time chosen. |
| 734 chrome.alarms.create(alarmName, {periodInMinutes: 60}); | 734 chrome.alarms.create(alarmName, {periodInMinutes: 60}); |
| 735 | 735 |
| 736 return { | 736 return { |
| 737 addListener: addListener, | 737 addListener: addListener, |
| 738 isSignedIn: isSignedIn, | 738 isSignedIn: isSignedIn, |
| 739 removeToken: removeToken | 739 removeToken: removeToken |
| 740 }; | 740 }; |
| 741 } | 741 } |
| OLD | NEW |