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

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

Issue 100164: extensions api: windows.removeWindow(), events: onWindowCreated, onWindowRemoved (Closed)
Patch Set: touch grd to avoid clobber build Created 11 years, 7 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
« no previous file with comments | « chrome/renderer/resources/extension_process_bindings.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 function loadWindowList() { 9 function loadWindowList() {
10 chromium.tabs.getWindows(undefined, function(windowList) { 10 chromium.windows.getWindows(undefined, function(windowList) {
11 tabs = {}; 11 tabs = {};
12 tabIds = []; 12 tabIds = [];
13 for (var i = 0; i < windowList.length; i++) { 13 for (var i = 0; i < windowList.length; i++) {
14 for (var j = 0; j < windowList[i].tabs.length; j++) { 14 for (var j = 0; j < windowList[i].tabs.length; j++) {
15 tabIds[tabIds.length] = windowList[i].tabs[j].id; 15 tabIds[tabIds.length] = windowList[i].tabs[j].id;
16 tabs[windowList[i].tabs[j].id] = windowList[i].tabs[j]; 16 tabs[windowList[i].tabs[j].id] = windowList[i].tabs[j];
17 } 17 }
18 } 18 }
19 19
20 var input = new JsExprContext(windowList); 20 var input = new JsExprContext(windowList);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 77
78 function appendToLog(logLine) { 78 function appendToLog(logLine) {
79 var log = document.getElementById('log'); 79 var log = document.getElementById('log');
80 log.innerHTML = '<div> &gt;&nbsp;' + logLine + '</div>' + log.innerHTML; 80 log.innerHTML = '<div> &gt;&nbsp;' + logLine + '</div>' + log.innerHTML;
81 } 81 }
82 82
83 function clearLog() { 83 function clearLog() {
84 document.getElementById('log').innerHTML = ''; 84 document.getElementById('log').innerHTML = '';
85 } 85 }
86 86
87 chromium.windows.onWindowCreated.addListener(function(windowId) {
88 appendToLog('onWindowCreated -- window: ' + windowId);
89 loadWindowList();
90 });
91
92 chromium.windows.onWindowRemoved.addListener(function(windowId) {
93 appendToLog('onWindowRemoved -- window: ' + windowId);
94 loadWindowList();
95 });
96
87 chromium.tabs.onTabCreated.addListener(function(data) { 97 chromium.tabs.onTabCreated.addListener(function(data) {
88 appendToLog('onTabCreated -- window: ' + data.windowId + ' tab: ' + data.tabId + ' index ' + data.index); 98 appendToLog('onTabCreated -- window: ' + data.windowId + ' tab: ' + data.tabId + ' index ' + data.index);
89 loadWindowList(); 99 loadWindowList();
90 }); 100 });
91 101
92 chromium.tabs.onTabAttached.addListener(function(data) { 102 chromium.tabs.onTabAttached.addListener(function(data) {
93 appendToLog('onTabAttached -- window: ' + data.windowId + ' tab: ' + data.tabI d + ' index ' + data.index); 103 appendToLog('onTabAttached -- window: ' + data.windowId + ' tab: ' + data.tabI d + ' index ' + data.index);
94 loadWindowList(); 104 loadWindowList();
95 }); 105 });
96 106
97 chromium.tabs.onTabMoved.addListener(function(data) { 107 chromium.tabs.onTabMoved.addListener(function(data) {
98 appendToLog('onTabMoved -- window: ' + data.windowId + ' tab: ' + data.tabId + ' from ' + data.fromIndex + ' to ' + data.toIndex); 108 appendToLog('onTabMoved -- window: ' + data.windowId + ' tab: ' + data.tabId + ' from ' + data.fromIndex + ' to ' + data.toIndex);
99 loadWindowList(); 109 loadWindowList();
100 }); 110 });
101 111
102 chromium.tabs.onTabDetached.addListener(function(data) { 112 chromium.tabs.onTabDetached.addListener(function(data) {
103 appendToLog('onTabDetached -- window: ' + data.windowId + ' tab: ' + data.tabI d + ' index ' + data.index); 113 appendToLog('onTabDetached -- window: ' + data.windowId + ' tab: ' + data.tabI d + ' index ' + data.index);
104 loadWindowList(); 114 loadWindowList();
105 }); 115 });
106 116
107 chromium.tabs.onTabSelectionChanged.addListener(function(data) { 117 chromium.tabs.onTabSelectionChanged.addListener(function(data) {
108 appendToLog('onTabSelectionChanged -- window: ' + data.windowId + ' tab: ' + d ata.tabId + ' index ' + data.index); 118 appendToLog('onTabSelectionChanged -- window: ' + data.windowId + ' tab: ' + d ata.tabId + ' index ' + data.index);
109 loadWindowList(); 119 loadWindowList();
110 }); 120 });
111 121
112 chromium.tabs.onTabRemoved.addListener(function(data) { 122 chromium.tabs.onTabRemoved.addListener(function(tabId) {
113 appendToLog('onTabRemoved -- window: ' + data.windowId + ' tab: ' + data.tabId + ' index ' + data.index); 123 appendToLog('onTabRemoved -- tab: ' + tabId);
114 loadWindowList(); 124 loadWindowList();
115 }); 125 });
116 126
117 function isInt(i) { 127 function isInt(i) {
118 return (typeof i == "number") && !(i % 1) && !isNaN(i); 128 return (typeof i == "number") && !(i % 1) && !isNaN(i);
119 } 129 }
120 130
121 function createWindow() { 131 function createWindow() {
122 var args = { 132 var args = {
123 'left': parseInt(document.getElementById('new_window_left').value), 133 'left': parseInt(document.getElementById('new_window_left').value),
124 'top': parseInt(document.getElementById('new_window_top').value), 134 'top': parseInt(document.getElementById('new_window_top').value),
125 'width': parseInt(document.getElementById('new_window_width').value), 135 'width': parseInt(document.getElementById('new_window_width').value),
126 'height': parseInt(document.getElementById('new_window_height').value), 136 'height': parseInt(document.getElementById('new_window_height').value),
127 'url': document.getElementById('new_window_url').value 137 'url': document.getElementById('new_window_url').value
128 } 138 }
129 139
130 if (!isInt(args.left)) 140 if (!isInt(args.left))
131 delete args.left; 141 delete args.left;
132 if (!isInt(args.top)) 142 if (!isInt(args.top))
133 delete args.top; 143 delete args.top;
134 if (!isInt(args.width)) 144 if (!isInt(args.width))
135 delete args.width; 145 delete args.width;
136 if (!isInt(args.height)) 146 if (!isInt(args.height))
137 delete args.height; 147 delete args.height;
138 if (!args.url) 148 if (!args.url)
139 delete args.url; 149 delete args.url;
140 150
141 chromium.tabs.createWindow(args); 151 chromium.windows.createWindow(args);
142 } 152 }
143 153
144 </script> 154 </script>
145 </head> 155 </head>
146 <body onload="loadWindowList();"> 156 <body onload="loadWindowList();">
147 <div id="windowList"> 157 <div id="windowList">
148 <div style="background-color: #AAEEEE; margin: 4px; padding: 8px; margin: 20px" jsselect="$this"> 158 <div style="background-color: #AAEEEE; margin: 4px; padding: 8px; margin: 20px" jsselect="$this">
149 <div style="font-style: italic; width: 80px; display: inline-block"> 159 <div style="font-style: italic; width: 80px; display: inline-block">
150 Window: <span jscontent="id"></span> 160 Window: <span jscontent="id"></span>
151 </div> 161 </div>
(...skipping 22 matching lines...) Expand all
174 <div> 184 <div>
175 <div style="width: 40px; display:inline-block">url:</div> 185 <div style="width: 40px; display:inline-block">url:</div>
176 <input style="width: 90%" type="text" jsvalues="value:url;id:'ur l_' + id" /> 186 <input style="width: 90%" type="text" jsvalues="value:url;id:'ur l_' + id" />
177 </div> 187 </div>
178 <div><input type="checkbox" jsvalues="checked:selected; id:'select ed_' + id" /> Selected</div> 188 <div><input type="checkbox" jsvalues="checked:selected; id:'select ed_' + id" /> Selected</div>
179 </div> 189 </div>
180 <button onclick="updateTab(this.jstdata)" jsvalues=".jstdata:id">Upd ate Tab</button> 190 <button onclick="updateTab(this.jstdata)" jsvalues=".jstdata:id">Upd ate Tab</button>
181 <button onclick="chromium.tabs.removeTab(this.jstdata);" jsvalues=". jstdata:id">Close Tab</button> 191 <button onclick="chromium.tabs.removeTab(this.jstdata);" jsvalues=". jstdata:id">Close Tab</button>
182 </div> 192 </div>
183 </div> 193 </div>
194 <button onclick="chromium.windows.removeWindow(this.jstdata);" jsvalues= ".jstdata:id">Close Window</button>
184 </div> 195 </div>
185 </div> 196 </div>
186 <div style="background-color: #EEEEBB; margin: 20px; padding: 8px"> 197 <div style="background-color: #EEEEBB; margin: 20px; padding: 8px">
187 <h3 style="text-align: center; margin: 8px"> Create Window</h3> 198 <h3 style="text-align: center; margin: 8px"> Create Window</h3>
188 <div style="margin: 8px"> 199 <div style="margin: 8px">
189 <div style="width: 300px; display: inline-block"> 200 <div style="width: 300px; display: inline-block">
190 left: <input style="width: 20px" type="text" id="new_window_left" /> 201 left: <input style="width: 20px" type="text" id="new_window_left" />
191 top: <input style="width: 20px" type="text" id="new_window_top" /> 202 top: <input style="width: 20px" type="text" id="new_window_top" />
192 width: <input style="width: 20px" type="text" id="new_window_width" /> 203 width: <input style="width: 20px" type="text" id="new_window_width" />
193 height: <input style="width: 20px" type="text" id="new_window_height" /> 204 height: <input style="width: 20px" type="text" id="new_window_height" />
(...skipping 27 matching lines...) Expand all
221 </div> 232 </div>
222 <div><input type="checkbox" id="selected_new" /> Selected</div> 233 <div><input type="checkbox" id="selected_new" /> Selected</div>
223 </div> 234 </div>
224 <button onclick="createTab();">Create</button> 235 <button onclick="createTab();">Create</button>
225 </div> 236 </div>
226 <div style="margin: 20px;"> 237 <div style="margin: 20px;">
227 <button onclick="loadWindowList();">Refresh</button> 238 <button onclick="loadWindowList();">Refresh</button>
228 <button onclick="updateAll();">Update All</button> 239 <button onclick="updateAll();">Update All</button>
229 <button onclick="moveAll();">Move All</button> 240 <button onclick="moveAll();">Move All</button>
230 <button onclick="clearLog();">-->Clear Log</button> 241 <button onclick="clearLog();">-->Clear Log</button>
231 <button onclick="chromium.tabs.createWindow();">New Window</button> 242 <button onclick="chromium.windows.createWindow();">New Window</button>
232 </div> 243 </div>
233 <div id="log" style="background-color: #EEAAEE; margin: 20px; padding: 8px"> 244 <div id="log" style="background-color: #EEAAEE; margin: 20px; padding: 8px">
234 </div> 245 </div>
235 </body> 246 </body>
236 </html> 247 </html>
237 248
OLDNEW
« no previous file with comments | « chrome/renderer/resources/extension_process_bindings.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698