Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | |
| 2 // for details. All rights reserved. Use of this source code is governed by a | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 // from app.window.idl | |
| 6 part of chrome; | |
| 7 | |
| 8 /** | |
| 9 * Types | |
| 10 */ | |
| 11 class CreateWindowOptions extends ChromeObject { | |
| 12 /* | |
| 13 * Public constructor | |
| 14 */ | |
| 15 CreateWindowOptions({String id, int defaultWidth, int defaultHeight, | |
| 16 int defaultLeft, int defaultTop, int width, int height, int left, int top, | |
| 17 int minWidth, int minHeight, int maxWidth, int maxHeight, String type, | |
| 18 String frame, Bounds bounds, bool hidden}) { | |
| 19 this.id = id; | |
| 20 this.defaultWidth = defaultWidth; | |
| 21 this.defaultHeight = defaultHeight; | |
| 22 this.defaultLeft = defaultLeft; | |
| 23 this.defaultTop = defaultTop; | |
| 24 this.width = width; | |
| 25 this.height = height; | |
| 26 this.left = left; | |
| 27 this.top = top; | |
| 28 this.minWidth = minWidth; | |
| 29 this.minHeight = minHeight; | |
| 30 this.maxWidth = maxWidth; | |
| 31 this.maxHeight = maxHeight; | |
| 32 this.type = type; | |
| 33 this.frame = frame; | |
| 34 this.bounds = bounds; | |
| 35 this.hidden = hidden; | |
| 36 } | |
| 37 | |
| 38 /* | |
| 39 * Private constructor | |
| 40 */ | |
| 41 CreateWindowOptions._proxy(_jsObject) | |
| 42 : super._proxy(_jsObject); | |
| 43 | |
| 44 /* | |
| 45 * Public accessors | |
| 46 */ | |
| 47 // Id to identify the window. This will be used to remember the size | |
| 48 // and position of the window and restore that geometry when a window | |
| 49 // with the same id (and no explicit size or position) is later opened. | |
| 50 String get id => | |
| 51 getMember('String', 'id'); | |
| 52 | |
| 53 void set id(String id) => | |
| 54 setMember('id', id); | |
| 55 | |
| 56 // Default width of the window. (Deprecated; regular bounds act like this | |
| 57 // now.) | |
| 58 int get defaultWidth => | |
| 59 getMember('int', 'defaultWidth'); | |
| 60 | |
| 61 void set defaultWidth(int defaultWidth) => | |
| 62 setMember('defaultWidth', defaultWidth); | |
| 63 | |
| 64 // Default height of the window. (Deprecated; regular bounds act like this | |
| 65 // now.) | |
| 66 int get defaultHeight => | |
| 67 getMember('int', 'defaultHeight'); | |
| 68 | |
| 69 void set defaultHeight(int defaultHeight) => | |
| 70 setMember('defaultHeight', defaultHeight); | |
| 71 | |
| 72 // Default X coordinate of the window. (Deprecated; regular bounds act like | |
| 73 // this now.) | |
| 74 int get defaultLeft => | |
| 75 getMember('int', 'defaultLeft'); | |
| 76 | |
| 77 void set defaultLeft(int defaultLeft) => | |
| 78 setMember('defaultLeft', defaultLeft); | |
| 79 | |
| 80 // Default Y coordinate of the window. (Deprecated; regular bounds act like | |
| 81 // this now.) | |
| 82 int get defaultTop => | |
| 83 getMember('int', 'defaultTop'); | |
| 84 | |
| 85 void set defaultTop(int defaultTop) => | |
| 86 setMember('defaultTop', defaultTop); | |
| 87 | |
| 88 // Width of the window. (Deprecated; use 'bounds'.) | |
| 89 int get width => | |
| 90 getMember('int', 'width'); | |
| 91 | |
| 92 void set width(int width) => | |
| 93 setMember('width', width); | |
| 94 | |
| 95 // Height of the window. (Deprecated; use 'bounds'.) | |
| 96 int get height => | |
| 97 getMember('int', 'height'); | |
| 98 | |
| 99 void set height(int height) => | |
| 100 setMember('height', height); | |
| 101 | |
| 102 // X coordinate of the window. (Deprecated; use 'bounds'.) | |
| 103 int get left => | |
| 104 getMember('int', 'left'); | |
| 105 | |
| 106 void set left(int left) => | |
| 107 setMember('left', left); | |
| 108 | |
| 109 // Y coordinate of the window. (Deprecated; use 'bounds'.) | |
| 110 int get top => | |
| 111 getMember('int', 'top'); | |
| 112 | |
| 113 void set top(int top) => | |
| 114 setMember('top', top); | |
| 115 | |
| 116 // Minimium width of the window. | |
| 117 int get minWidth => | |
| 118 getMember('int', 'minWidth'); | |
| 119 | |
| 120 void set minWidth(int minWidth) => | |
| 121 setMember('minWidth', minWidth); | |
| 122 | |
| 123 // Minimum height of the window. | |
| 124 int get minHeight => | |
| 125 getMember('int', 'minHeight'); | |
| 126 | |
| 127 void set minHeight(int minHeight) => | |
| 128 setMember('minHeight', minHeight); | |
| 129 | |
| 130 // Maximum width of the window. | |
| 131 int get maxWidth => | |
| 132 getMember('int', 'maxWidth'); | |
| 133 | |
| 134 void set maxWidth(int maxWidth) => | |
| 135 setMember('maxWidth', maxWidth); | |
| 136 | |
| 137 // Maximum height of the window. | |
| 138 int get maxHeight => | |
| 139 getMember('int', 'maxHeight'); | |
| 140 | |
| 141 void set maxHeight(int maxHeight) => | |
| 142 setMember('maxHeight', maxHeight); | |
| 143 | |
| 144 // Window type: 'shell' (the default) is the only currently supported value. | |
| 145 String get type => | |
| 146 getMember('String', 'type'); | |
| 147 | |
| 148 void set type(String type) => | |
| 149 setMember('type', type); | |
| 150 | |
| 151 // Frame type: 'none' or 'chrome' (defaults to 'chrome'). | |
| 152 String get frame => | |
| 153 getMember('String', 'frame'); | |
| 154 | |
| 155 void set frame(String frame) => | |
| 156 setMember('frame', frame); | |
| 157 | |
| 158 // Size of the content in the window (excluding the titlebar). If specified | |
| 159 // in addition to any of the left/top/width/height parameters, this field | |
| 160 // takes precedence. If a frameBounds is specified, the frameBounds take | |
| 161 // precedence. | |
| 162 Bounds get bounds => | |
| 163 new Bounds._proxy(getMember('Bounds', 'bounds')); | |
| 164 | |
| 165 void set bounds(Bounds bounds) => | |
| 166 setMember('bounds', bounds); | |
| 167 | |
| 168 // If true, the window will be created in a hidden state. Call show() on | |
| 169 // the window to show it once it has been created. Defaults to false. | |
| 170 bool get hidden => | |
| 171 getMember('bool', 'hidden'); | |
| 172 | |
| 173 void set hidden(bool hidden) => | |
| 174 setMember('hidden', hidden); | |
| 175 } | |
| 176 | |
| 177 class Bounds extends ChromeObject { | |
| 178 int _left; | |
| 179 int _top; | |
| 180 int _width; | |
| 181 int _height; | |
| 182 | |
| 183 /* | |
| 184 * Public constructor | |
| 185 */ | |
| 186 Bounds({int left, int top, int width, int height}) { | |
| 187 this.left = left; | |
| 188 this.top = top; | |
| 189 this.width = width; | |
| 190 this.height = height; | |
| 191 } | |
| 192 | |
| 193 /* | |
| 194 * Private constructor | |
| 195 */ | |
| 196 Bounds._proxy(_jsObject) | |
| 197 : super._proxy(_jsObject); | |
| 198 | |
| 199 /* | |
| 200 * Public accessors | |
| 201 */ | |
| 202 int get left => | |
| 203 getMember('int', 'left'); | |
| 204 | |
| 205 void set left(int left) => | |
| 206 setMember('left', left); | |
| 207 | |
| 208 int get top => | |
| 209 getMember('int', 'top'); | |
| 210 | |
| 211 void set top(int top) => | |
| 212 setMember('top', top); | |
| 213 | |
| 214 int get width => | |
| 215 getMember('int', 'width'); | |
| 216 | |
| 217 void set width(int width) => | |
| 218 setMember('width', width); | |
| 219 | |
| 220 int get height => | |
| 221 getMember('int', 'height'); | |
| 222 | |
| 223 void set height(int height) => | |
| 224 setMember('height', height); | |
| 225 } | |
| 226 | |
| 227 class AppWindow extends ChromeObject { | |
| 228 /* | |
| 229 * Public constructor | |
| 230 * TODO(sashab): Does it make sense to be able to create a new AppWindow this | |
| 231 * way? | |
| 232 */ | |
| 233 //AppWindow(); | |
| 234 | |
| 235 /* | |
| 236 * Private constructor | |
| 237 */ | |
| 238 AppWindow._proxy(jsObject) | |
| 239 : super._proxy(jsObject); | |
| 240 | |
| 241 /* | |
| 242 * Public accessors | |
| 243 */ | |
| 244 // The JavaScript 'window' object for the created child. | |
| 245 // TODO(sashab, sra): Detect whether this is the current window, or an | |
| 246 // external one, and return an appropriately-typed object | |
| 247 WindowBase get contentWindow { | |
| 248 return JS("Window", "#.contentWindow", this._jsObject); | |
| 249 } | |
| 250 | |
| 251 /* | |
| 252 * Functions | |
| 253 */ | |
| 254 | |
| 255 // Focus the window. | |
| 256 void focus() => | |
| 257 JS("void", "#.focus()", this._jsObject); | |
| 258 | |
| 259 // Minimize the window. | |
| 260 void minimize() => | |
| 261 JS("void", "#.minimize()", this._jsObject); | |
| 262 | |
| 263 // Is the window minimized? | |
| 264 bool isMinimized() => | |
| 265 JS("bool", "#.isMinimized()", this._jsObject); | |
| 266 | |
| 267 // Maximize the window. | |
| 268 void maximize() => | |
| 269 JS("void", "#.maximize()", this._jsObject); | |
| 270 | |
| 271 // Is the window maximized? | |
| 272 bool isMaximized() => | |
| 273 JS("bool", "c#.isMaximized()", this._jsObject); | |
| 274 | |
| 275 // Restore the window. | |
| 276 void restore() => | |
| 277 JS("void", "#.restore()", this._jsObject); | |
| 278 | |
| 279 // Move the window to the position (|left|, |top|). | |
| 280 void moveTo(int left, int top) => | |
| 281 JS("void", "#.moveTo(#, #)", this._jsObject, left, top); | |
| 282 | |
| 283 // Resize the window to |width|x|height| pixels in size. | |
| 284 void resizeTo(int width, int height) => | |
| 285 JS("void", "#.resizeTo(#, #)", this._jsObject, width, height); | |
| 286 | |
| 287 // Draw attention to the window. | |
| 288 void drawAttention() => | |
| 289 JS("void", "#.drawAttention()", this._jsObject); | |
| 290 | |
| 291 // Clear attention to the window. | |
| 292 void clearAttention() => | |
| 293 JS("void", "#.clearAttention()", this._jsObject); | |
| 294 | |
| 295 // Close the window. | |
| 296 void close() => | |
| 297 JS("void", "#.close()", this._jsObject); | |
| 298 | |
| 299 // Show the window. Does nothing if the window is already visible. | |
| 300 void show() => | |
| 301 JS("void", "#.show()", this._jsObject); | |
| 302 | |
| 303 // Hide the window. Does nothing if the window is already hidden. | |
| 304 void hide() => | |
| 305 JS("void", "#.hide()", this._jsObject); | |
| 306 | |
| 307 // Set the window's bounds. | |
| 308 void setBounds(Bounds bounds) => | |
| 309 JS("void", "#.setBounds(#)", this._jsObject, convertArgument(bounds)); | |
| 310 | |
| 311 } | |
| 312 | |
| 313 /** | |
| 314 * Functions | |
| 315 */ | |
| 316 class $API_ChromeAppWindow { | |
| 317 /** | |
| 318 * JS object | |
| 319 */ | |
| 320 Object _jsObject; | |
| 321 | |
| 322 /** | |
| 323 * Constructor | |
| 324 */ | |
| 325 $API_ChromeAppWindow(this._jsObject); | |
| 326 | |
| 327 /** | |
| 328 * Functions | |
| 329 */ | |
| 330 | |
| 331 // Returns an <a href="#type-AppWindow">AppWindow</a> object for the | |
| 332 // current script context (ie JavaScript 'window' object). This can also be | |
| 333 // called on a handle to a script context for another page, for example: | |
|
Emily Fortuna
2013/01/23 19:28:04
if you make this comment triple slash, it will be
sashab
2013/01/23 22:24:53
These comments are generated from the Chrome.* API
| |
| 334 // otherWindow.chrome.app.window.current(). | |
| 335 AppWindow current() => | |
| 336 new AppWindow._proxy(JS("Object", "#.current()", this._jsObject)); | |
| 337 | |
| 338 // The size and position of a window can be specified in a number of | |
| 339 // different ways. The most simple option is not specifying anything at | |
| 340 // all, in which case a default size and platform dependent position will | |
| 341 // be used. | |
| 342 // | |
| 343 // Another option is to use the top/left and width/height properties, | |
| 344 // which will always put the window at the specified coordinates with the | |
| 345 // specified size. | |
| 346 // | |
| 347 // Yet another option is to give the window a (unique) id. This id is then | |
| 348 // used to remember the size and position of the window whenever it is | |
| 349 // moved or resized. This size and position is then used instead of the | |
| 350 // specified bounds on subsequent opening of a window with the same id. If | |
| 351 // you need to open a window with an id at a location other than the | |
| 352 // remembered default, you can create it hidden, move it to the desired | |
| 353 // location, then show it. | |
| 354 // | |
| 355 // You can also combine these various options, explicitly specifying for | |
| 356 // example the size while having the position be remembered or other | |
| 357 // combinations like that. Size and position are dealt with seperately, | |
| 358 // but individual coordinates are not. So if you specify a top (or left) | |
| 359 // coordinate, you should also specify a left (or top) coordinate, and | |
| 360 // similar for size. | |
| 361 // | |
| 362 // If you specify both a regular and a default value for the same option | |
| 363 // the regular value is the only one that takes effect. | |
| 364 void create(String url, [CreateWindowOptions options, | |
| 365 void callback(AppWindow created_window)]) { | |
| 366 void __proxy_callback(Object created_window) { | |
| 367 if (?callback) | |
| 368 callback(new AppWindow._proxy(created_window)); | |
| 369 } | |
| 370 | |
| 371 JS("void", "#.create(#, #, #)", | |
| 372 this._jsObject, | |
| 373 convertArgument(url), | |
| 374 convertArgument(options), | |
| 375 convertDartClosureToJS(__proxy_callback, 1) | |
| 376 ); | |
| 377 } | |
| 378 } | |
| OLD | NEW |