| OLD | NEW |
| 1 // Copyright (c) 2009 The chrome Authors. All rights reserved. | 1 // Copyright (c) 2009 The chrome 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 // ----------------------------------------------------------------------------- | 5 // ----------------------------------------------------------------------------- |
| 6 // NOTE: If you change this file you need to touch renderer_resources.grd to | 6 // NOTE: If you change this file you need to touch renderer_resources.grd to |
| 7 // have your change take effect. | 7 // have your change take effect. |
| 8 // ----------------------------------------------------------------------------- | 8 // ----------------------------------------------------------------------------- |
| 9 | 9 |
| 10 // This script contains privileged chrome extension related javascript APIs. | 10 // This script contains privileged chrome extension related javascript APIs. |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 function setupPageActionEvents(extensionId) { | 164 function setupPageActionEvents(extensionId) { |
| 165 var pageActions = GetCurrentPageActions(); | 165 var pageActions = GetCurrentPageActions(); |
| 166 var eventName = ""; | 166 var eventName = ""; |
| 167 for (var i = 0; i < pageActions.length; ++i) { | 167 for (var i = 0; i < pageActions.length; ++i) { |
| 168 eventName = extensionId + "/" + pageActions[i]; | 168 eventName = extensionId + "/" + pageActions[i]; |
| 169 // Setup events for each extension_id/page_action_id string we find. | 169 // Setup events for each extension_id/page_action_id string we find. |
| 170 chrome.pageActions[pageActions[i]] = new chrome.Event(eventName); | 170 chrome.pageActions[pageActions[i]] = new chrome.Event(eventName); |
| 171 } | 171 } |
| 172 } | 172 } |
| 173 | 173 |
| 174 // Bookmarks custom parameter handling. | |
| 175 chrome.bookmarks.remove = function(id, callback) { | |
| 176 validate(arguments, arguments.callee.params); | |
| 177 sendRequest("bookmarks.remove", [id, false], callback); | |
| 178 }; | |
| 179 | |
| 180 chrome.bookmarks.remove.params = [ | |
| 181 { | |
| 182 choice : [ | |
| 183 {type: "integer", minimum: 0}, | |
| 184 {type: "array", item: {type: "integer", minimum: 0}, minItems: 1} | |
| 185 ] | |
| 186 }, | |
| 187 {type: "function", optional: true} | |
| 188 ]; | |
| 189 | |
| 190 chrome.bookmarks.removeTree = function(id, callback) { | |
| 191 validate(arguments, arguments.callee.params); | |
| 192 sendRequest("bookmarks.removeTree", [id, true], callback); | |
| 193 }; | |
| 194 | |
| 195 chrome.bookmarks.removeTree.params = [ | |
| 196 {type: "integer", minimum: 0}, | |
| 197 {type: "function", optional: true} | |
| 198 ]; | |
| 199 | |
| 200 // Tabs connect() | 174 // Tabs connect() |
| 201 chrome.tabs.connect = function(tabId, opt_name) { | 175 chrome.tabs.connect = function(tabId, opt_name) { |
| 202 validate(arguments, arguments.callee.params); | 176 validate(arguments, arguments.callee.params); |
| 203 var portId = OpenChannelToTab(tabId, chrome.extension.id_, opt_name || ""); | 177 var portId = OpenChannelToTab(tabId, chrome.extension.id_, opt_name || ""); |
| 204 return chromeHidden.Port.createPort(portId, opt_name); | 178 return chromeHidden.Port.createPort(portId, opt_name); |
| 205 }; | 179 }; |
| 206 | 180 |
| 207 chrome.tabs.connect.params = [ | 181 chrome.tabs.connect.params = [ |
| 208 {type: "integer", optional: true, minimum: 0}, | 182 {type: "integer", optional: true, minimum: 0}, |
| 209 {type: "string", optional: true} | 183 {type: "string", optional: true} |
| 210 ]; | 184 ]; |
| 211 | 185 |
| 212 // chrome.self / chrome.extension. | 186 // chrome.self / chrome.extension. |
| 213 chrome.self = chrome.self || {}; | 187 chrome.self = chrome.self || {}; |
| 214 | 188 |
| 215 chromeHidden.onLoad.addListener(function (extensionId) { | 189 chromeHidden.onLoad.addListener(function (extensionId) { |
| 216 chrome.extension = new chrome.Extension(extensionId); | 190 chrome.extension = new chrome.Extension(extensionId); |
| 217 // TODO(mpcomplete): self.onConnect is deprecated. Remove it at 1.0. | 191 // TODO(mpcomplete): self.onConnect is deprecated. Remove it at 1.0. |
| 218 // http://code.google.com/p/chromium/issues/detail?id=16356 | 192 // http://code.google.com/p/chromium/issues/detail?id=16356 |
| 219 chrome.self.onConnect = chrome.extension.onConnect; | 193 chrome.self.onConnect = chrome.extension.onConnect; |
| 220 | 194 |
| 221 setupPageActionEvents(extensionId); | 195 setupPageActionEvents(extensionId); |
| 222 }); | 196 }); |
| 223 | 197 |
| 224 chrome.self.getViews = function() { | 198 chrome.self.getViews = function() { |
| 225 return GetViews(); | 199 return GetViews(); |
| 226 } | 200 } |
| 227 })(); | 201 })(); |
| OLD | NEW |