| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // This script contains privileged chrome extension related javascript APIs. | 5 // This script contains privileged chrome extension related javascript APIs. |
| 6 // It is loaded by pages whose URL has the chrome-extension protocol. | 6 // It is loaded by pages whose URL has the chrome-extension protocol. |
| 7 | 7 |
| 8 var chrome = chrome || {}; | 8 var chrome = chrome || {}; |
| 9 (function() { | 9 (function() { |
| 10 native function GetChromeHidden(); | 10 native function GetChromeHidden(); |
| (...skipping 1087 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1098 }); | 1098 }); |
| 1099 | 1099 |
| 1100 apiFunctions.setCustomCallback("contextMenus.removeAll", | 1100 apiFunctions.setCustomCallback("contextMenus.removeAll", |
| 1101 function(name, request, response) { | 1101 function(name, request, response) { |
| 1102 if (chrome.extension.lastError) { | 1102 if (chrome.extension.lastError) { |
| 1103 return; | 1103 return; |
| 1104 } | 1104 } |
| 1105 chromeHidden.contextMenus.handlers = {}; | 1105 chromeHidden.contextMenus.handlers = {}; |
| 1106 }); | 1106 }); |
| 1107 | 1107 |
| 1108 // TODO(skerner,mtytel): The next step to omitting optional arguments is the |
| 1109 // replacement of this code with code that matches arguments by type. |
| 1110 // Once this is working for captureVisibleTab() it can be enabled for |
| 1111 // the rest of the API. See crbug/29215 . |
| 1108 apiFunctions.setUpdateArgumentsPreValidate("tabs.captureVisibleTab", | 1112 apiFunctions.setUpdateArgumentsPreValidate("tabs.captureVisibleTab", |
| 1109 function() { | 1113 function() { |
| 1110 // Old signature: | 1114 // Old signature: |
| 1111 // captureVisibleTab(int windowId, function callback); | 1115 // captureVisibleTab(int windowId, function callback); |
| 1112 // New signature: | 1116 // New signature: |
| 1113 // captureVisibleTab(int windowId, object details, function callback); | 1117 // captureVisibleTab(int windowId, object details, function callback); |
| 1114 // | |
| 1115 // TODO(skerner): The next step to omitting optional arguments is the | |
| 1116 // replacement of this code with code that matches arguments by type. | |
| 1117 // Once this is working for captureVisibleTab() it can be enabled for | |
| 1118 // the rest of the API. See crbug/29215 . | |
| 1119 if (arguments.length == 2 && typeof(arguments[1]) == "function") { | 1118 if (arguments.length == 2 && typeof(arguments[1]) == "function") { |
| 1120 // If the old signature is used, add a null details object. | 1119 // If the old signature is used, add a null details object. |
| 1121 newArgs = [arguments[0], null, arguments[1]]; | 1120 newArgs = [arguments[0], null, arguments[1]]; |
| 1122 } else { | 1121 } else { |
| 1123 newArgs = arguments; | 1122 newArgs = arguments; |
| 1124 } | 1123 } |
| 1125 return newArgs; | 1124 return newArgs; |
| 1126 }); | 1125 }); |
| 1127 | 1126 |
| 1127 apiFunctions.setUpdateArgumentsPreValidate("windows.get", |
| 1128 function() { |
| 1129 // Old signature: |
| 1130 // get(int windowId, function callback); |
| 1131 // New signature: |
| 1132 // get(int windowId, object populate, function callback); |
| 1133 if (arguments.length == 2 && typeof(arguments[1]) == "function") { |
| 1134 // If the old signature is used, add a null populate object. |
| 1135 newArgs = [arguments[0], null, arguments[1]]; |
| 1136 } else { |
| 1137 newArgs = arguments; |
| 1138 } |
| 1139 return newArgs; |
| 1140 }); |
| 1141 |
| 1142 apiFunctions.setUpdateArgumentsPreValidate("windows.getCurrent", |
| 1143 function() { |
| 1144 // Old signature: |
| 1145 // getCurrent(function callback); |
| 1146 // New signature: |
| 1147 // getCurrent(object populate, function callback); |
| 1148 if (arguments.length == 1 && typeof(arguments[0]) == "function") { |
| 1149 // If the old signature is used, add a null populate object. |
| 1150 newArgs = [null, arguments[0]]; |
| 1151 } else { |
| 1152 newArgs = arguments; |
| 1153 } |
| 1154 return newArgs; |
| 1155 }); |
| 1156 |
| 1157 apiFunctions.setUpdateArgumentsPreValidate("windows.getLastFocused", |
| 1158 function() { |
| 1159 // Old signature: |
| 1160 // getLastFocused(function callback); |
| 1161 // New signature: |
| 1162 // getLastFocused(object populate, function callback); |
| 1163 if (arguments.length == 1 && typeof(arguments[0]) == "function") { |
| 1164 // If the old signature is used, add a null populate object. |
| 1165 newArgs = [null, arguments[0]]; |
| 1166 } else { |
| 1167 newArgs = arguments; |
| 1168 } |
| 1169 return newArgs; |
| 1170 }); |
| 1171 |
| 1172 apiFunctions.setUpdateArgumentsPreValidate("windows.getAll", |
| 1173 function() { |
| 1174 // Old signature: |
| 1175 // getAll(function callback); |
| 1176 // New signature: |
| 1177 // getAll(object populate, function callback); |
| 1178 if (arguments.length == 1 && typeof(arguments[0]) == "function") { |
| 1179 // If the old signature is used, add a null populate object. |
| 1180 newArgs = [null, arguments[0]]; |
| 1181 } else { |
| 1182 newArgs = arguments; |
| 1183 } |
| 1184 return newArgs; |
| 1185 }); |
| 1186 |
| 1128 apiFunctions.setUpdateArgumentsPostValidate("omnibox.sendSuggestions", | 1187 apiFunctions.setUpdateArgumentsPostValidate("omnibox.sendSuggestions", |
| 1129 function(requestId, userSuggestions) { | 1188 function(requestId, userSuggestions) { |
| 1130 var suggestions = []; | 1189 var suggestions = []; |
| 1131 for (var i = 0; i < userSuggestions.length; i++) { | 1190 for (var i = 0; i < userSuggestions.length; i++) { |
| 1132 var parseResult = parseOmniboxDescription( | 1191 var parseResult = parseOmniboxDescription( |
| 1133 userSuggestions[i].description); | 1192 userSuggestions[i].description); |
| 1134 parseResult.content = userSuggestions[i].content; | 1193 parseResult.content = userSuggestions[i].content; |
| 1135 suggestions.push(parseResult); | 1194 suggestions.push(parseResult); |
| 1136 } | 1195 } |
| 1137 return [requestId, suggestions]; | 1196 return [requestId, suggestions]; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1188 | 1247 |
| 1189 if (!chrome.tts) | 1248 if (!chrome.tts) |
| 1190 chrome.tts = {}; | 1249 chrome.tts = {}; |
| 1191 | 1250 |
| 1192 if (!chrome.ttsEngine) | 1251 if (!chrome.ttsEngine) |
| 1193 chrome.ttsEngine = {}; | 1252 chrome.ttsEngine = {}; |
| 1194 | 1253 |
| 1195 if (!chrome.experimental.downloads) | 1254 if (!chrome.experimental.downloads) |
| 1196 chrome.experimental.downloads = {}; | 1255 chrome.experimental.downloads = {}; |
| 1197 })(); | 1256 })(); |
| OLD | NEW |