Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(276)

Side by Side Diff: chrome/renderer/resources/extension_process_bindings.js

Issue 79026: added windows.getWindows() and tabs.moveTab() (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 var chromium; 1 var chromium;
2 (function() { 2 (function() {
3 native function GetNextCallbackId(); 3 native function GetNextCallbackId();
4 native function GetWindows();
4 native function GetTabsForWindow(); 5 native function GetTabsForWindow();
5 native function GetTab(); 6 native function GetTab();
6 native function CreateTab(); 7 native function CreateTab();
7 native function UpdateTab(); 8 native function UpdateTab();
9 native function MoveTab();
8 native function RemoveTab(); 10 native function RemoveTab();
9 11
10 if (!chromium) 12 if (!chromium)
11 chromium = {}; 13 chromium = {};
12 14
13 // Validate arguments. 15 // Validate arguments.
14 function validate(inst, schemas) { 16 function validate(inst, schemas) {
15 if (inst.length > schemas.length) 17 if (inst.length > schemas.length)
16 throw new Error("Too many arguments."); 18 throw new Error("Too many arguments.");
17 19
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 callbackId = GetNextCallbackId(); 65 callbackId = GetNextCallbackId();
64 callbacks[callbackId] = callback; 66 callbacks[callbackId] = callback;
65 } 67 }
66 request(sargs, callbackId); 68 request(sargs, callbackId);
67 } 69 }
68 70
69 //---------------------------------------------------------------------------- 71 //----------------------------------------------------------------------------
70 72
71 // Tabs 73 // Tabs
72 chromium.tabs = {}; 74 chromium.tabs = {};
75
76 chromium.tabs.getWindows = function(windowQuery, callback) {
77 validate(arguments, arguments.callee.params);
78 sendRequest(GetWindows, windowQuery, callback);
79 };
80 chromium.tabs.getWindows.params = [
81 {
82 type: "object",
83 properties: {
84 ids: {
85 type: "array",
86 items: chromium.types.pInt,
87 minItems: 1
88 }
89 },
90 optional: true,
91 additionalProperties: false
92 },
93 chromium.types.optFun
94 ];
95
73 // TODO(aa): This should eventually take an optional windowId param. 96 // TODO(aa): This should eventually take an optional windowId param.
74 chromium.tabs.getTabsForWindow = function(callback) { 97 chromium.tabs.getTabsForWindow = function(callback) {
75 validate(arguments, arguments.callee.params); 98 validate(arguments, arguments.callee.params);
76 sendRequest(GetTabsForWindow, null, callback); 99 sendRequest(GetTabsForWindow, null, callback);
77 }; 100 };
78 chromium.tabs.getTabsForWindow.params = [ 101 chromium.tabs.getTabsForWindow.params = [
79 chromium.types.optFun 102 chromium.types.optFun
80 ]; 103 ];
81 104
82 chromium.tabs.getTab = function(tabId, callback) { 105 chromium.tabs.getTab = function(tabId, callback) {
83 validate(arguments, arguments.callee.params); 106 validate(arguments, arguments.callee.params);
84 sendRequest(GetTab, tabId, callback); 107 sendRequest(GetTab, tabId, callback);
85 }; 108 };
86 chromium.tabs.getTab.params = [ 109 chromium.tabs.getTab.params = [
87 chromium.types.pInt, 110 chromium.types.pInt,
88 chromium.types.optFun 111 chromium.types.optFun
89 ]; 112 ];
90 113
91 chromium.tabs.createTab = function(tab, callback) { 114 chromium.tabs.createTab = function(tab, callback) {
92 validate(arguments, arguments.callee.params); 115 validate(arguments, arguments.callee.params);
93 sendRequest(CreateTab, tab, callback); 116 sendRequest(CreateTab, tab, callback);
94 }; 117 };
95 chromium.tabs.createTab.params = [ 118 chromium.tabs.createTab.params = [
96 { 119 {
97 type: "object", 120 type: "object",
98 properties: { 121 properties: {
99 windowId: chromium.types.optPInt, 122 windowId: chromium.types.optPInt,
100 url: chromium.types.optStr, 123 url: chromium.types.optStr,
101 selected: chromium.types.optBool 124 selected: chromium.types.optBool
(...skipping 13 matching lines...) Expand all
115 properties: { 138 properties: {
116 id: chromium.types.pInt, 139 id: chromium.types.pInt,
117 windowId: chromium.types.optPInt, 140 windowId: chromium.types.optPInt,
118 url: chromium.types.optStr, 141 url: chromium.types.optStr,
119 selected: chromium.types.optBool 142 selected: chromium.types.optBool
120 }, 143 },
121 additionalProperties: false 144 additionalProperties: false
122 } 145 }
123 ]; 146 ];
124 147
148 chromium.tabs.moveTab = function(tab) {
149 validate(arguments, arguments.callee.params);
150 sendRequest(MoveTab, tab);
151 };
152 chromium.tabs.moveTab.params = [
153 {
154 type: "object",
155 properties: {
156 id: chromium.types.pInt,
157 windowId: chromium.types.optPInt,
158 index: chromium.types.pInt
159 },
160 additionalProperties: false
161 }
162 ];
163
125 chromium.tabs.removeTab = function(tabId) { 164 chromium.tabs.removeTab = function(tabId) {
126 validate(arguments, arguments.callee.params); 165 validate(arguments, arguments.callee.params);
127 sendRequest(RemoveTab, tabId); 166 sendRequest(RemoveTab, tabId);
128 }; 167 };
129 chromium.tabs.removeTab.params = [ 168 chromium.tabs.removeTab.params = [
130 chromium.types.pInt 169 chromium.types.pInt
131 ]; 170 ];
132 171
133 // onTabMoved sends ({tabId, windowId, fromIndex, toIndex}) as named 172 // onTabMoved sends ({tabId, windowId, fromIndex, toIndex}) as named
134 // arguments. 173 // arguments.
135 chromium.tabs.onTabMoved = new chromium.Event("tab-moved"); 174 chromium.tabs.onTabMoved = new chromium.Event("tab-moved");
136 175
137 //---------------------------------------------------------------------------- 176 //----------------------------------------------------------------------------
138 177
139 // Self 178 // Self
140 chromium.self = {}; 179 chromium.self = {};
141 chromium.self.onConnect = new chromium.Event("channel-connect"); 180 chromium.self.onConnect = new chromium.Event("channel-connect");
142 })(); 181 })();
143 182
OLDNEW
« no previous file with comments | « chrome/renderer/renderer_resources.grd ('k') | chrome/test/data/extensions/test/TabsAPI/1/tabs_api.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698