Skip to content
Browse files

Update samples to use 'bounds' parameter to window.create.

Older parameters of left, top, widgth, height have been deprecated.
This clean up is part of http://crbug.com/181651, fixing documentation
to use app.window.create({ bounds: {left, top, width, height}}).
  • Loading branch information...
1 parent f81ab26 commit 0d905010bb14a90962c23e3e3b5fbce20685e9e9 @scheib scheib committed Mar 14, 2013
Showing with 184 additions and 109 deletions.
  1. +1 −1 analytics/launch.js
  2. +4 −2 appsquare/background.js
  3. +4 −2 browser/main.js
  4. +4 −2 calculator/main.js
  5. +4 −2 camera-capture/background.js
  6. +5 −3 clock/main.js
  7. +2 −2 context-menu/main.js
  8. +1 −1 dart/js/main.js
  9. +4 −2 diff/js/background.js
  10. +5 −3 dojo/build.sh
  11. BIN dojo/dojo.crx
  12. +1 −1 filesystem-access/background.js
  13. +7 −4 frameless-window/background.js
  14. +1 −1 fullscreen/background.js
  15. +4 −2 gdocs/js/background.js
  16. +4 −2 hello-world-sync/main.js
  17. +14 −3 hello-world/README.md
  18. +9 −4 hello-world/main.js
  19. +1 −1 identity/main.js
  20. +4 −2 instagram-auth/main.js
  21. +4 −2 ioio/background.js
  22. +2 −2 media-gallery/runtime.js
  23. +2 −2 messaging/app1/main.js
  24. +2 −2 messaging/app2/main.js
  25. +2 −2 mini-code-edit/background.js
  26. +1 −1 mini-code-edit/editor.js
  27. +4 −2 optional-permissions/main.js
  28. +4 −2 parrot-ar-drone/main.js
  29. +4 −2 restarted-demo/background.js
  30. +2 −2 rich-notifications/app.js
  31. +1 −1 sandbox/main.js
  32. +1 −1 sandboxed-content/main.js
  33. +6 −4 serial-control-signals/background.js
  34. +1 −1 serial/adkjs/app/js/background.js
  35. +4 −2 serial/ledtoggle/launch.js
  36. +6 −4 servo/background.js
  37. +4 −2 singleton/main.js
  38. +4 −2 storage/background.js
  39. +1 −1 syncfs-editor/js/background.js
  40. +4 −2 systemInfo/main.js
  41. +1 −1 tcpserver/commands/BrowserCommands.js
  42. +1 −1 tcpserver/main.js
  43. +4 −2 telnet/launch.js
  44. +4 −2 udp/main.js
  45. +4 −2 usb/knob/background.js
  46. +4 −2 weather/main.js
  47. +1 −1 webgl-pointer-lock/README.md
  48. +1 −1 webgl-pointer-lock/main.js
  49. +6 −4 webserver/main.js
  50. +4 −4 webview/main.js
  51. +12 −8 windows/main.js
  52. +4 −2 zephyr_hxm/background.js
View
2 analytics/launch.js
@@ -6,5 +6,5 @@
*/
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create('main.html',
- {width: 480, height: 225});
+ {bounds: {width: 480, height: 225}});
});
View
6 appsquare/background.js
@@ -1,6 +1,8 @@
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create('main.html', {
- width: 300,
- height: 600
+ bounds: {
+ width: 300,
+ height: 600
+ }
});
});
View
6 browser/main.js
@@ -24,7 +24,9 @@ chrome.app.runtime.onRestarted.addListener(function() {
*/
function runApp() {
chrome.app.window.create('browser.html', {
- 'width': 1024,
- 'height': 768
+ bounds: {
+ 'width': 1024,
+ 'height': 768
+ }
});
}
View
6 calculator/main.js
@@ -12,8 +12,10 @@
*/
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create('calculator.html', {
- width: 244,
- height: 380,
+ bounds: {
+ width: 244,
+ height: 380
+ },
maxWidth: 244,
minWidth: 244,
minHeight: 380,
View
6 camera-capture/background.js
@@ -6,7 +6,9 @@
*/
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create('index.html', {
- width: 700,
- height: 600
+ bounds: {
+ width: 700,
+ height: 600
+ }
});
});
View
8 clock/main.js
@@ -12,9 +12,11 @@
*/
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create('index.html', {
- height: 550,
- width: 800,
- top: 100,
+ bounds: {
+ height: 550,
+ width: 800,
+ top: 100
+ },
frame: 'none'
});
});
View
4 context-menu/main.js
@@ -1,4 +1,4 @@
chrome.app.runtime.onLaunched.addListener(function() {
- chrome.app.window.create('a.html', {top: 0, left: 0, width: 300, height: 300});
- chrome.app.window.create('b.html', {top: 0, left: 310, width: 300, height: 300});
+ chrome.app.window.create('a.html', {bounds:{top: 0, left: 0, width: 300, height: 300}});
+ chrome.app.window.create('b.html', {bounds:{top: 0, left: 310, width: 300, height: 300}});
});
View
2 dart/js/main.js
@@ -6,5 +6,5 @@
*/
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create('clock.html',
- {id: 'clock', width: 800, height: 550});
+ {id: 'clock', bounds: {width: 800, height: 550}});
});
View
6 diff/js/background.js
@@ -6,8 +6,10 @@
function onLaunched(launchData) {
chrome.app.window.create('main.html', {
- width: 1270,
- height: 800
+ bounds: {
+ width: 1270,
+ height: 800
+ }
});
}
View
8 dojo/build.sh
@@ -19,7 +19,7 @@ function _dojo_launch(app) {
function _dojo_readme(file) {
chrome.app.window.create(file,
- {width: 500, height: 700, left: 602});
+ {bounds: {width: 500, height: 700, left: 602}});
}
function _dojo_source(app) {
window.open("https://github.com/GoogleChrome/chrome-app-samples/tree/master/"+app);
@@ -53,8 +53,10 @@ function writeJS_launch() {
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create('index.html', {
- width: 600,
- height: 800
+ bounds: {
+ width: 600,
+ height: 800
+ }
});
});
EOF
View
BIN dojo/dojo.crx
Binary file not shown.
View
2 filesystem-access/background.js
@@ -1,5 +1,5 @@
chrome.app.runtime.onLaunched.addListener(function(launchData) {
- chrome.app.window.create('index.html', {width: 800, height: 500}, function(win) {
+ chrome.app.window.create('index.html', {bounds: {width: 800, height: 500}}, function(win) {
win.contentWindow.launchData = launchData;
});
});
View
11 frameless-window/background.js
@@ -1,10 +1,13 @@
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create("frameless_window.html",
- { frame: "none", width: 360,
- height: 300,
+ { frame: "none",
+ bounds: {
+ width: 360,
+ height: 300,
+ left: 600
+ },
minWidth: 220,
- minHeight: 220,
- left: 600
+ minHeight: 220
}
);
});
View
2 fullscreen/background.js
@@ -1,3 +1,3 @@
chrome.app.runtime.onLaunched.addListener(function() {
- chrome.app.window.create('window.html', {width: 500, height: 309});
+ chrome.app.window.create('window.html', {bounds: {width: 500, height: 309}});
});
View
6 gdocs/js/background.js
@@ -1,7 +1,9 @@
chrome.app.runtime.onLaunched.addListener(function(launchData) {
chrome.app.window.create('../main.html', {
- width: 500,
- height: 600,
+ bounds: {
+ width: 500,
+ height: 600
+ },
minWidth: 500,
minHeight: 600,
frame: 'none'
View
6 hello-world-sync/main.js
@@ -1,6 +1,8 @@
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create('index.html', {
- width: 500,
- height: 415
+ bounds: {
+ width: 500,
+ height: 415
+ }
});
});
View
17 hello-world/README.md
@@ -5,10 +5,21 @@ additional permissions. The manifest denotes a background script, main.js,
detailed below:
```javascript
-// Main.js
chrome.app.runtime.onLaunched.addListener(function() {
- chrome.app.window.create('index.html',
- {width: 500, height: 309});
+ // Center window on screen.
+ var screenWidth = screen.availWidth;
+ var screenHeight = screen.availHeight;
+ var width = 500;
+ var height = 300;
+
+ chrome.app.window.create('index.html', {
+ bounds: {
+ width: width,
+ height: height,
+ left: Math.round((screenWidth-width)/2),
+ top: Math.round((screenHeight-height)/2)
+ }
+ });
});
```
View
13 hello-world/main.js
@@ -5,13 +5,18 @@
* @see http://developer.chrome.com/trunk/apps/app.window.html
*/
chrome.app.runtime.onLaunched.addListener(function() {
+ // Center window on screen.
var screenWidth = screen.availWidth;
var screenHeight = screen.availHeight;
var width = 500;
var height = 300;
- chrome.app.window.create('index.html',
- {width: width, height: height,
- left: (screenWidth-width)/2,
- top: (screenHeight-height)/2});
+ chrome.app.window.create('index.html', {
+ bounds: {
+ width: width,
+ height: height,
+ left: Math.round((screenWidth-width)/2),
+ top: Math.round((screenHeight-height)/2)
+ }
+ });
});
View
2 identity/main.js
@@ -1,3 +1,3 @@
chrome.app.runtime.onLaunched.addListener(function() {
- chrome.app.window.create('index.html', { "width": 1024, "height": 768 });
+ chrome.app.window.create('index.html', { "bounds": { "width": 1024, "height": 768 } });
});
View
6 instagram-auth/main.js
@@ -6,7 +6,9 @@
*/
chrome.app.runtime.onLaunched.addListener(function(intentData) {
chrome.app.window.create('index.html', {
- width: 500,
- height: 309
+ bounds: {
+ width: 500,
+ height: 309
+ }
});
});
View
6 ioio/background.js
@@ -1,6 +1,8 @@
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create('index.html', {
- width: 640,
- height: 480
+ bounds: {
+ width: 640,
+ height: 480
+ }
});
});
View
4 media-gallery/runtime.js
@@ -3,7 +3,7 @@
chrome.app.runtime.onLaunched.addListener(function(data) {
chrome.app.window.create('page.html',
- {width:900, height:600, minWidth:900, maxWidth: 900, minHeight:600, maxHeight: 600, id:"MGExp"},
+ {bounds: {width:900, height:600}, minWidth:900, maxWidth: 900, minHeight:600, maxHeight: 600, id:"MGExp"},
function(app_win) {
app_win.contentWindow.__MGA__bRestart = false;
}
@@ -13,7 +13,7 @@ chrome.app.runtime.onLaunched.addListener(function(data) {
chrome.app.runtime.onRestarted.addListener(function() {
chrome.app.window.create('page.html',
- {width:900, height:600, minWidth:900, maxWidth: 900, minHeight:600, maxHeight: 600, id:"MGExp"},
+ {bounds: {width:900, height:600}, minWidth:900, maxWidth: 900, minHeight:600, maxHeight: 600, id:"MGExp"},
function(app_win) {
app_win.contentWindow.__MGA__bRestart = true;
}
View
4 messaging/app1/main.js
@@ -6,6 +6,6 @@
*/
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create('index.html',
- {width: 800, height: 500});
+ {bounds: {width: 800, height: 500}});
});
-//function addExternalMessageListener
+//function addExternalMessageListener
View
4 messaging/app2/main.js
@@ -6,6 +6,6 @@
*/
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create('index.html',
- {width: 800, height: 500});
+ {bounds: {width: 800, height: 500}});
});
-//function addExternalMessageListener
+//function addExternalMessageListener
View
4 mini-code-edit/background.js
@@ -2,7 +2,7 @@ chrome.app.runtime.onLaunched.addListener(function() {
// width 640 for font size 12
// 720 for font size 14
chrome.app.window.create('main.html', {
- frame: 'chrome', width: 720, height: 400, minWidth:720, minHeight: 400
+ frame: 'chrome', bounds: { width: 720, height: 400}, minWidth:720, minHeight: 400
});
});
@@ -15,7 +15,7 @@ chrome.commands.onCommand.addListener(function(command) {
if (command == "cmdNew") {
chrome.app.window.create('main.html', {
- frame: 'chrome', width: 720, height: 400, minWidth:720, minHeight: 400
+ frame: 'chrome', bounds: { width: 720, height: 400}, minWidth:720, minHeight: 400
});
}
});
View
2 mini-code-edit/editor.js
@@ -124,7 +124,7 @@ function handleNewButton() {
editor.setValue("");
} else {
chrome.app.window.create('main.html', {
- frame: 'chrome', width: 720, height: 400
+ frame: 'chrome', bounds: { width: 720, height: 400}
});
}
}
View
6 optional-permissions/main.js
@@ -1,7 +1,9 @@
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create('permissions.html', {
id: 'permissions',
- width: 640,
- height: 480
+ bounds: {
+ width: 640,
+ height: 480
+ }
});
})
View
6 parrot-ar-drone/main.js
@@ -12,8 +12,10 @@ chrome.app.runtime.onLaunched.addListener(function() {
}, 1000);
chrome.app.window.create('index.html', {
- width: 565,
- height: 400
+ bounds: {
+ width: 565,
+ height: 400
+ }
}, function(createdWindow) {
appWindow = createdWindow.dom;
});
View
6 restarted-demo/background.js
@@ -94,8 +94,10 @@ Counter.prototype.close = function() {
function runApp(counter) {
chrome.app.window.create('main.html', {
id: counter.id + '',
- width: 800,
- height: 600
+ bounds: {
+ width: 800,
+ height: 600
+ }
}, function(win) {
win.contentWindow.onload = function() {
counter.attachToWindow(win, win.contentWindow.document);
View
4 rich-notifications/app.js
@@ -1,3 +1,3 @@
chrome.app.runtime.onLaunched.addListener(function () {
- chrome.app.window.create("window.html", {width:600, height:400});
-});
+ chrome.app.window.create("window.html", {bounds: {width:600, height:400}});
+});
View
2 sandbox/main.js
@@ -6,5 +6,5 @@
*/
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create('mainpage.html',
- {width: 500, height: 309});
+ {bounds: {width: 500, height: 309}});
});
View
2 sandboxed-content/main.js
@@ -6,5 +6,5 @@
*/
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create('main.html',
- {width: 400, height: 350});
+ {bounds: {width: 400, height: 350}});
});
View
10 serial-control-signals/background.js
@@ -1,8 +1,10 @@
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create('main.html', {
- top: 0,
- left: 0,
- width: 640,
- height: 720
+ bounds: {
+ top: 0,
+ left: 0,
+ width: 640,
+ height: 720
+ }
});
})
View
2 serial/adkjs/app/js/background.js
@@ -1,4 +1,4 @@
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create('comm.html#inlink',
- {frame: 'custom', width: 343, height: 600});
+ {frame: 'custom', bounds: {width: 343, height: 600}});
});
View
6 serial/ledtoggle/launch.js
@@ -1,6 +1,8 @@
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create('index.html', {
- width: 320,
- height: 240
+ bounds: {
+ width: 320,
+ height: 240
+ }
});
});
View
10 servo/background.js
@@ -1,8 +1,10 @@
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create('main.html', {
- top: 0,
- left: 0,
- width: 640,
- height: 720
+ bounds: {
+ top: 0,
+ left: 0,
+ width: 640,
+ height: 720
+ }
});
})
View
6 singleton/main.js
@@ -16,8 +16,10 @@ chrome.app.runtime.onLaunched.addListener(function() {
} else {
console.log('Creating singleton window');
chrome.app.window.create('singleton.html', {
- width: 500,
- height: 309,
+ bounds: {
+ width: 500,
+ height: 309
+ },
maxWidth: 500,
maxHeight: 309,
View
6 storage/background.js
@@ -1,6 +1,8 @@
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create('main.html', {
- 'width': 400,
- 'height': 500
+ bounds: {
+ 'width': 400,
+ 'height': 500
+ }
});
});
View
2 syncfs-editor/js/background.js
@@ -1,5 +1,5 @@
chrome.app.runtime.onLaunched.addListener(function (arg) {
chrome.app.window.create(
'main.html',
- { width:780, height:490, type:"shell" });
+ { bounds: { width:780, height:490}, type:"shell" });
});
View
6 systemInfo/main.js
@@ -12,7 +12,9 @@
*/
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create('index.html', {
- height: 550,
- width: 800
+ bounds: {
+ height: 550,
+ width: 800
+ }
});
});
View
2 tcpserver/commands/BrowserCommands.js
@@ -68,7 +68,7 @@ Commands.addCommand("echo",
Commands.addCommand("open",
"Open the given URL",
function(args) {
- chrome.app.window.create('commands/webview.html', {width: 600, height: 400},
+ chrome.app.window.create('commands/webview.html', {bounds: {width: 600, height: 400}},
function(w) {
w.contentWindow.addEventListener("DOMContentLoaded", function() {
var doc=w.contentWindow.document;
View
2 tcpserver/main.js
@@ -13,7 +13,7 @@ chrome.app.runtime.onLaunched.addListener(function() {
commandWindow.focus();
} else {
chrome.app.window.create('index.html',
- {width: 500, height: 309, left: 0},
+ {bounds: {width: 500, height: 309, left: 0}},
function(w) {
commandWindow = w;
});
View
6 telnet/launch.js
@@ -6,7 +6,9 @@
*/
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create('terminal.html', {
- width: 880,
- height: 480
+ bounds: {
+ width: 880,
+ height: 480
+ }
});
});
View
6 udp/main.js
@@ -1,6 +1,8 @@
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create('echo_mco.html', {
- width: 680,
- height: 480
+ bounds: {
+ width: 680,
+ height: 480
+ }
});
});
View
6 usb/knob/background.js
@@ -1,6 +1,8 @@
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create('knob.html', {
- width: 400,
- height: 400
+ bounds: {
+ width: 400,
+ height: 400
+ }
});
});
View
6 weather/main.js
@@ -1,8 +1,10 @@
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create('weather.html', {
id: 'weather',
- height: 450,
- width: 300,
+ bounds: {
+ height: 450,
+ width: 300
+ },
minHeight: 450,
minWidth: 300,
maxHeight: 450,
View
2 webgl-pointer-lock/README.md
@@ -6,7 +6,7 @@ This sample uses the frameless window:
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create('index.html',
- {frame: 'none', width: 500, height: 400});
+ {frame: 'none', bounds: {width: 500, height: 400}});
});
## APIs
View
2 webgl-pointer-lock/main.js
@@ -6,5 +6,5 @@
*/
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create('index.html',
- {frame:"none", width: 500, height: 400});
+ {frame:"none", bounds: {width: 500, height: 400}});
});
View
10 webserver/main.js
@@ -5,8 +5,10 @@
* @see http://developer.chrome.com/trunk/apps/app.window.html
*/
chrome.app.runtime.onLaunched.addListener(function(intentData) {
- chrome.app.window.create('index.html', {
- width: 500,
- height: 640
- });
+ chrome.app.window.create('index.html', {
+ bounds: {
+ width: 500,
+ height: 640
+ }
+ });
});
View
8 webview/main.js
@@ -6,9 +6,9 @@
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create('index.html', {
id: 'embedder',
- width: 1430,
- height: 870
+ bounds: {
+ width: 1430,
+ height: 870
+ }
});
});
-
-
View
20 windows/main.js
@@ -29,10 +29,12 @@ function launch() {
// create the original window
chrome.app.window.create('original.html', {
- top: 128,
- left: 128,
- width: 300,
- height: 300,
+ bounds: {
+ top: 128,
+ left: 128,
+ width: 300,
+ height: 300
+ },
minHeight: 300,
maxWidth: 500,
minWidth: 300,
@@ -46,10 +48,12 @@ function launch() {
windows.push(originalWindow);
chrome.app.window.create('copycat.html', {
- top: 128,
- left: 428 + 5,
- width: 300,
- height: 300,
+ bounds: {
+ top: 128,
+ left: 428 + 5,
+ width: 300,
+ height: 300
+ },
minHeight: 300,
maxWidth: 500,
minWidth: 300,
View
6 zephyr_hxm/background.js
@@ -1,6 +1,8 @@
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create('index.html', {
- width: 640,
- height: 480
+ bounds: {
+ width: 640,
+ height: 480
+ }
});
});

0 comments on commit 0d90501

Please sign in to comment.
Something went wrong with that request. Please try again.