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

Side by Side Diff: chrome/common/extensions/docs/examples/api/tabs/inspector/tabs_api.js

Issue 9289057: Changing manifest to v2 extension samples (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Cleaning up warnings Created 8 years, 11 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
OLDNEW
1 <html>
2 <head>
3 <script src="jstemplate_compiled.js" type="text/javascript"></script>
4 <script>
5
6 tabs = {}; 1 tabs = {};
Mike West 2012/01/27 16:06:32 Copyright.
7 tabIds = []; 2 tabIds = [];
8 3
9 focusedWindowId = undefined; 4 focusedWindowId = undefined;
10 currentWindowId = undefined; 5 currentWindowId = undefined;
11 6
12 function bootStrap() { 7 function bootStrap() {
13 chrome.windows.getCurrent(function(currentWindow) { 8 chrome.windows.getCurrent(function(currentWindow) {
14 currentWindowId = currentWindow.id; 9 currentWindowId = currentWindow.id;
15 chrome.windows.getLastFocused(function(focusedWindow) { 10 chrome.windows.getLastFocused(function(focusedWindow) {
16 focusedWindowId = focusedWindow.id; 11 focusedWindowId = focusedWindow.id;
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 appendToLog('windows.onFocusChanged -- window: ' + windowId); 145 appendToLog('windows.onFocusChanged -- window: ' + windowId);
151 loadWindowList(); 146 loadWindowList();
152 }); 147 });
153 148
154 chrome.windows.onRemoved.addListener(function(windowId) { 149 chrome.windows.onRemoved.addListener(function(windowId) {
155 appendToLog('windows.onRemoved -- window: ' + windowId); 150 appendToLog('windows.onRemoved -- window: ' + windowId);
156 loadWindowList(); 151 loadWindowList();
157 }); 152 });
158 153
159 chrome.tabs.onCreated.addListener(function(tab) { 154 chrome.tabs.onCreated.addListener(function(tab) {
160 appendToLog('tabs.onCreated -- window: ' + tab.windowId + ' tab: ' + tab.id + ' title: ' + tab.title + ' index ' + tab.index + ' url ' + tab.url); 155 appendToLog(
156 'tabs.onCreated -- window: ' + tab.windowId + ' tab: ' + tab.id +
157 ' title: ' + tab.title + ' index ' + tab.index + ' url ' + tab.url);
161 loadWindowList(); 158 loadWindowList();
162 }); 159 });
163 160
164 chrome.tabs.onAttached.addListener(function(tabId, props) { 161 chrome.tabs.onAttached.addListener(function(tabId, props) {
165 appendToLog('tabs.onAttached -- window: ' + props.newWindowId + ' tab: ' + tab Id + ' index ' + props.newPosition); 162 appendToLog(
163 'tabs.onAttached -- window: ' + props.newWindowId + ' tab: ' + tabId +
164 ' index ' + props.newPosition);
166 loadWindowList(); 165 loadWindowList();
167 }); 166 });
168 167
169 chrome.tabs.onMoved.addListener(function(tabId, props) { 168 chrome.tabs.onMoved.addListener(function(tabId, props) {
170 appendToLog('tabs.onMoved -- window: ' + props.windowId + ' tab: ' + tabId + ' from ' + props.fromIndex + ' to ' + props.toIndex); 169 appendToLog(
170 'tabs.onMoved -- window: ' + props.windowId + ' tab: ' + tabId +
171 ' from ' + props.fromIndex + ' to ' + props.toIndex);
171 loadWindowList(); 172 loadWindowList();
172 }); 173 });
173 174
174 function refreshTab(tabId) { 175 function refreshTab(tabId) {
175 chrome.tabs.get(tabId, function(tab) { 176 chrome.tabs.get(tabId, function(tab) {
176 var input = new JsExprContext(tab); 177 var input = new JsExprContext(tab);
177 var output = document.getElementById('tab_' + tab.id); 178 var output = document.getElementById('tab_' + tab.id);
178 jstProcess(input, output); 179 jstProcess(input, output);
179 appendToLog('tab refreshed -- tabId: ' + tab.id + ' url: ' + tab.url); 180 appendToLog('tab refreshed -- tabId: ' + tab.id + ' url: ' + tab.url);
180 }); 181 });
181 } 182 }
182 183
183 chrome.tabs.onUpdated.addListener(function(tabId, props) { 184 chrome.tabs.onUpdated.addListener(function(tabId, props) {
184 appendToLog('tabs.onUpdated -- tab: ' + tabId + ' status ' + props.status + ' url ' + props.url); 185 appendToLog(
186 'tabs.onUpdated -- tab: ' + tabId + ' status ' + props.status +
187 ' url ' + props.url);
185 refreshTab(tabId); 188 refreshTab(tabId);
186 }); 189 });
187 190
188 chrome.tabs.onDetached.addListener(function(tabId, props) { 191 chrome.tabs.onDetached.addListener(function(tabId, props) {
189 appendToLog('tabs.onDetached -- window: ' + props.oldWindowId + ' tab: ' + tab Id + ' index ' + props.oldPosition); 192 appendToLog(
193 'tabs.onDetached -- window: ' + props.oldWindowId + ' tab: ' + tabId +
194 ' index ' + props.oldPosition);
190 loadWindowList(); 195 loadWindowList();
191 }); 196 });
192 197
193 chrome.tabs.onSelectionChanged.addListener(function(tabId, props) { 198 chrome.tabs.onSelectionChanged.addListener(function(tabId, props) {
194 appendToLog('tabs.onSelectionChanged -- window: ' + props.windowId + ' tab: ' + tabId); 199 appendToLog(
200 'tabs.onSelectionChanged -- window: ' + props.windowId + ' tab: ' +
201 tabId);
195 loadWindowList(); 202 loadWindowList();
196 }); 203 });
197 204
198 chrome.tabs.onRemoved.addListener(function(tabId) { 205 chrome.tabs.onRemoved.addListener(function(tabId) {
199 appendToLog('tabs.onRemoved -- tab: ' + tabId); 206 appendToLog('tabs.onRemoved -- tab: ' + tabId);
200 loadWindowList(); 207 loadWindowList();
201 }); 208 });
202 209
203 function createWindow() { 210 function createWindow() {
204 var args = { 211 var args = {
(...skipping 22 matching lines...) Expand all
227 } 234 }
228 } 235 }
229 236
230 function refreshWindow(windowId) { 237 function refreshWindow(windowId) {
231 chrome.windows.get(windowId, function(window) { 238 chrome.windows.get(windowId, function(window) {
232 chrome.tabs.getAllInWindow(window.id, function(tabList) { 239 chrome.tabs.getAllInWindow(window.id, function(tabList) {
233 window.tabs = tabList; 240 window.tabs = tabList;
234 var input = new JsExprContext(window); 241 var input = new JsExprContext(window);
235 var output = document.getElementById('window_' + window.id); 242 var output = document.getElementById('window_' + window.id);
236 jstProcess(input, output); 243 jstProcess(input, output);
237 appendToLog('window refreshed -- windowId: ' + window.id + ' tab count:' + window.tabs.length); 244 appendToLog(
245 'window refreshed -- windowId: ' + window.id + ' tab count:' +
246 window.tabs.length);
238 }); 247 });
239 }); 248 });
240 } 249 }
241 250
242 function updateWindowData(id) { 251 function updateWindowData(id) {
243 var retval = { 252 var retval = {
244 left: parseInt(document.getElementById('left_' + id).value), 253 left: parseInt(document.getElementById('left_' + id).value),
245 top: parseInt(document.getElementById('top_' + id).value), 254 top: parseInt(document.getElementById('top_' + id).value),
246 width: parseInt(document.getElementById('width_' + id).value), 255 width: parseInt(document.getElementById('width_' + id).value),
247 height: parseInt(document.getElementById('height_' + id).value) 256 height: parseInt(document.getElementById('height_' + id).value)
(...skipping 26 matching lines...) Expand all
274 } catch (e) { 283 } catch (e) {
275 alert(e); 284 alert(e);
276 } 285 }
277 } 286 }
278 287
279 function refreshSelectedTab(windowId) { 288 function refreshSelectedTab(windowId) {
280 chrome.tabs.getSelected(windowId, function(tab) { 289 chrome.tabs.getSelected(windowId, function(tab) {
281 var input = new JsExprContext(tab); 290 var input = new JsExprContext(tab);
282 var output = document.getElementById('tab_' + tab.id); 291 var output = document.getElementById('tab_' + tab.id);
283 jstProcess(input, output); 292 jstProcess(input, output);
284 appendToLog('selected tab refreshed -- tabId: ' + tab.id + ' url:' + tab.url ); 293 appendToLog(
294 'selected tab refreshed -- tabId: ' + tab.id + ' url:' + tab.url);
285 }); 295 });
286 } 296 }
287 297
288 </script> 298 document.addEventListener('DOMContentLoaded', function() {
289 </head> 299 bootStrap();
290 <body onload="bootStrap();"> 300 });
291 <div id="windowList">
292 <div style="background-color: #AAEEEE; margin: 4px; padding: 8px; margin: 20px" jsselect="$this"
293 jsvalues="id:'window_' + id">
294 <div style="font-style: italic; width: 80px; display: inline-block">
295 Window: <span jscontent="id"></span>
296 </div>
297 <div style="display: inline-block">
298 left: <input style="width: 60px" type="text" jsvalues="value:$this.lef t;id:'left_' + id" />
299 top: <input style="width: 60px" type="text" jsvalues="value:$this.top; id:'top_' + id" />
300 width: <input style="width: 60px" type="text" jsvalues="value:$this.wi dth;id:'width_' + id" />
301 height: <input style="width: 60px" type="text" jsvalues="value:$this.h eight;id:'height_' + id" />
302 <input type="checkbox" jsvalues="checked:focused; id:'focused_' + id" /> Focused
303 <input type="checkbox" jsvalues="checked:current; id:'current_' + id" /> Current
304 <button onclick="refreshWindow(this.jstdata);" jsvalues=".jstdata:id"> Refresh</button>
305 </div>
306 <div id="tabList">
307 <div jsselect="tabs">
308 <div style="background-color: #EEEEEE; margin: 8px; padding: 4px" j svalues="id:'tab_' + id">
309 <div style="margin: 8px">
310 <div style="font-style: italic; width: 80px; display: inline-blo ck" jscontent="'TabId: ' + id"></div>
311 <div style="width: 300px; display: inline-block">
312 index: <input style="width: 20px" type="text" jsvalues="value: $this.index;id:'index_' + id" />
313 windowId: <input style="width: 20px" type="text" jsvalues="val ue:windowId;id:'windowId_' + id" />
314 <button onclick="moveTab(this.jstdata);" jsvalues=".jstdata:id ">Move</button>
315 <button onclick="refreshTab(this.jstdata);" jsvalues=".jstdata :id">Refresh</button>
316 </div>
317 </div>
318 <div style="margin: 8px">
319 <div>
320 <div style="width: 40px; display:inline-block">title:</div>
321 <input style="width: 90%" type="text" jsvalues="value:title;id :'title_' + id" />
322 </div>
323 <div>
324 <div style="width: 40px; display:inline-block">url:</div>
325 <input style="width: 90%" type="text" jsvalues="value:url;id:' url_' + id" />
326 </div>
327 <div><input type="checkbox" jsvalues="checked:selected; id:'sele cted_' + id" /> Selected</div>
328 </div>
329 <button onclick="updateTab(this.jstdata)" jsvalues=".jstdata:id">U pdate Tab</button>
330 <button onclick="removeTab(this.jstdata);" jsvalues=".jstdata:id"> Close Tab</button>
331 </div>
332 </div>
333 </div>
334 <button onclick="updateWindow(this.jstdata);" jsvalues=".jstdata:id">Upd ate Window</button>
335 <button onclick="removeWindow(this.jstdata);" jsvalues=".jstdata:id">Clo se Window</button>
336 <button onclick="refreshSelectedTab(this.jstdata);" jsvalues=".jstdata:i d">Refresh Selected Tab</button>
337 </div>
338 </div>
339 <div style="background-color: #EEEEBB; margin: 20px; padding: 8px">
340 <h3 style="text-align: center; margin: 8px"> Create Window</h3>
341 <div style="margin: 8px">
342 <div style="width: 300px; display: inline-block">
343 left: <input style="width: 20px" type="text" id="new_window_left" />
344 top: <input style="width: 20px" type="text" id="new_window_top" />
345 width: <input style="width: 20px" type="text" id="new_window_width" />
346 height: <input style="width: 20px" type="text" id="new_window_height" />
347 </div>
348 </div>
349 <div style="margin: 8px">
350 <div>
351 <div style="width: 40px; display:inline-block">url:</div>
352 <input style="width: 90%" type="text" id="new_window_url" />
353 </div>
354 </div>
355 <button onclick="createWindow();">Create</button>
356 </div>
357 <div style="background-color: #EEEEAA; margin: 20px; padding: 8px">
358 <h3 style="text-align: center; margin: 8px"> Create Tab</h3>
359 <div style="margin: 8px">
360 <div style="width: 300px; display: inline-block">
361 index: <input style="width: 20px" type="text" id="index_new" />
362 windowId: <input style="width: 20px" type="text" id="windowId_new" />
363 <button onclick="moveTab(this.jstdata);" jsvalues=".jstdata:id">Move</ button>
364 </div>
365 </div>
366 <div style="margin: 8px">
367 <div>
368 <div style="width: 40px; display:inline-block">title:</div>
369 <input style="width: 90%" type="text" id="title_new" />
370 </div>
371 <div>
372 <div style="width: 40px; display:inline-block">url:</div>
373 <input style="width: 90%" type="text" id="url_new" />
374 </div>
375 <div><input type="checkbox" id="selected_new" /> Selected</div>
376 </div>
377 <button onclick="createTab();">Create</button>
378 </div>
379 <div style="margin: 20px;">
380 <button onclick="loadWindowList();">Refresh</button>
381 <button onclick="updateAll();">Update All</button>
382 <button onclick="moveAll();">Move All</button>
383 <button onclick="clearLog();">-->Clear Log</button>
384 <button onclick="chrome.windows.create();">New Window</button>
385 </div>
386 <div id="log" style="background-color: #EEAAEE; margin: 20px; padding: 8px">
387 </div>
388 </body>
389 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698