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

Side by Side Diff: chrome/test/data/extensions/samples/tabs/tabs_api.html

Issue 180016: Extension API Renaming/Consistency changes (Closed)
Patch Set: render docs Created 11 years, 3 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> 1 <html>
2 <head> 2 <head>
3 <script src="jstemplate_compiled.js" type="text/javascript"></script> 3 <script src="jstemplate_compiled.js" type="text/javascript"></script>
4 <script> 4 <script>
5 5
6 tabs = {}; 6 tabs = {};
7 tabIds = []; 7 tabIds = [];
8 8
9 focusedWindowId = undefined; 9 focusedWindowId = undefined;
10 currentWindowId = undefined; 10 currentWindowId = undefined;
11 11
12 function bootStrap() { 12 function bootStrap() {
13 chrome.windows.getCurrent(function(currentWindow) { 13 chrome.windows.getCurrent(function(currentWindow) {
14 currentWindowId = currentWindow.id; 14 currentWindowId = currentWindow.id;
15 chrome.windows.getLastFocused(function(focusedWindow) { 15 chrome.windows.getLastFocused(function(focusedWindow) {
16 focusedWindowId = focusedWindow.id; 16 focusedWindowId = focusedWindow.id;
17 loadWindowList(); 17 loadWindowList();
18 }); 18 });
19 }); 19 });
20 } 20 }
21 21
22 function isInt(i) { 22 function isInt(i) {
23 return (typeof i == "number") && !(i % 1) && !isNaN(i); 23 return (typeof i == "number") && !(i % 1) && !isNaN(i);
24 } 24 }
25 25
26 function loadWindowList() { 26 function loadWindowList() {
27 chrome.windows.getAll(true, function(windowList) { 27 chrome.windows.getAll({ populate: true }, function(windowList) {
28 tabs = {}; 28 tabs = {};
29 tabIds = []; 29 tabIds = [];
30 for (var i = 0; i < windowList.length; i++) { 30 for (var i = 0; i < windowList.length; i++) {
31 windowList[i].current = (windowList[i].id == currentWindowId); 31 windowList[i].current = (windowList[i].id == currentWindowId);
32 windowList[i].focused = (windowList[i].id == focusedWindowId); 32 windowList[i].focused = (windowList[i].id == focusedWindowId);
33 33
34 for (var j = 0; j < windowList[i].tabs.length; j++) { 34 for (var j = 0; j < windowList[i].tabs.length; j++) {
35 tabIds[tabIds.length] = windowList[i].tabs[j].id; 35 tabIds[tabIds.length] = windowList[i].tabs[j].id;
36 tabs[windowList[i].tabs[j].id] = windowList[i].tabs[j]; 36 tabs[windowList[i].tabs[j].id] = windowList[i].tabs[j];
37 } 37 }
38 } 38 }
39 39
40 var input = new JsExprContext(windowList); 40 var input = new JsExprContext(windowList);
41 var output = document.getElementById('windowList'); 41 var output = document.getElementById('windowList');
42 jstProcess(input, output); 42 jstProcess(input, output);
43 }); 43 });
44 } 44 }
45 45
46 function updateTabData(id) { 46 function updateTabData(id) {
47 var retval = { 47 var retval = {
48 url: document.getElementById('url_' + id).value, 48 url: document.getElementById('url_' + id).value,
49 selected: document.getElementById('selected_' + id).value ? true : false 49 selected: document.getElementById('selected_' + id).value ? true : false
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 132
133 function appendToLog(logLine) { 133 function appendToLog(logLine) {
134 var log = document.getElementById('log'); 134 var log = document.getElementById('log');
135 log.innerHTML = '<div> &gt;&nbsp;' + logLine + '</div>' + log.innerHTML; 135 log.innerHTML = '<div> &gt;&nbsp;' + logLine + '</div>' + log.innerHTML;
136 } 136 }
137 137
138 function clearLog() { 138 function clearLog() {
139 document.getElementById('log').innerHTML = ''; 139 document.getElementById('log').innerHTML = '';
140 } 140 }
141 141
142 chrome.windows.onCreated.addListener(function(windowId) { 142 chrome.windows.onCreated.addListener(function(createInfo) {
143 appendToLog('windows.onCreated -- window: ' + windowId); 143 appendToLog('windows.onCreated -- window: ' + createInfo.id);
144 loadWindowList(); 144 loadWindowList();
145 }); 145 });
146 146
147 chrome.windows.onFocusChanged.addListener(function(windowId) { 147 chrome.windows.onFocusChanged.addListener(function(windowId) {
148 focusedWindowId = windowId; 148 focusedWindowId = windowId;
149 appendToLog('windows.onFocusChanged -- window: ' + windowId); 149 appendToLog('windows.onFocusChanged -- window: ' + windowId);
150 loadWindowList(); 150 loadWindowList();
151 }); 151 });
152 152
153 chrome.windows.onRemoved.addListener(function(windowId) { 153 chrome.windows.onRemoved.addListener(function(windowId) {
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 <button onclick="loadWindowList();">Refresh</button> 381 <button onclick="loadWindowList();">Refresh</button>
382 <button onclick="updateAll();">Update All</button> 382 <button onclick="updateAll();">Update All</button>
383 <button onclick="moveAll();">Move All</button> 383 <button onclick="moveAll();">Move All</button>
384 <button onclick="clearLog();">-->Clear Log</button> 384 <button onclick="clearLog();">-->Clear Log</button>
385 <button onclick="chrome.windows.create();">New Window</button> 385 <button onclick="chrome.windows.create();">New Window</button>
386 </div> 386 </div>
387 <div id="log" style="background-color: #EEAAEE; margin: 20px; padding: 8px"> 387 <div id="log" style="background-color: #EEAAEE; margin: 20px; padding: 8px">
388 </div> 388 </div>
389 </body> 389 </body>
390 </html> 390 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698