// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. namespace app.window { dictionary Bounds { long? left; long? top; long? width; long? height; }; dictionary CreateWindowOptions { // Id to identify the window. This will be used to remember the size // and position of the window and restore that geometry when a window // with the same id (and no explicit size or position) is later opened. DOMString? id; // Default width of the window. (Deprecated; regular bounds act like this // now.) [nodoc] long? defaultWidth; // Default height of the window. (Deprecated; regular bounds act like this // now.) [nodoc] long? defaultHeight; // Default X coordinate of the window. (Deprecated; regular bounds act like // this now.) [nodoc] long? defaultLeft; // Default Y coordinate of the window. (Deprecated; regular bounds act like // this now.) [nodoc] long? defaultTop; // Width of the window. (Deprecated; use 'bounds'.) [nodoc] long? width; // Height of the window. (Deprecated; use 'bounds'.) [nodoc] long? height; // X coordinate of the window. (Deprecated; use 'bounds'.) [nodoc] long? left; // Y coordinate of the window. (Deprecated; use 'bounds'.) [nodoc] long? top; // Minimum width of the window. long? minWidth; // Minimum height of the window. long? minHeight; // Maximum width of the window. long? maxWidth; // Maximum height of the window. long? maxHeight; // Window type: // 'shell' - the default window type // 'panel' - a panel, managed by the OS (Currently experimental, Ash only) [nodoc] DOMString? type; // Frame type: 'none' or 'chrome' (defaults to 'chrome'). DOMString? frame; // Size of the content in the window (excluding the titlebar). If specified // in addition to any of the left/top/width/height parameters, this field // takes precedence. If a frameBounds is specified, the frameBounds take // precedence. Bounds? bounds; // Enable window background transparency. // Only supported in ash. Requires experimental API permission. boolean? transparentBackground; // If true, the window will be created in a hidden state. Call show() on // the window to show it once it has been created. Defaults to false. boolean? hidden; // By default if you specify an id for the window, the window will only be // created if another window with the same id doesn't already exist. If a // window with the same id already exists that window is activated instead. // If you do want to create multiple windows with the same id, you can // set this property to false. boolean? singleton; }; callback CreateWindowCallback = void ([instanceOf=AppWindow] object created_window); dictionary AppWindow { // Focus the window. static void focus(); // Minimize the window. static void minimize(); // Is the window minimized? static boolean isMinimized(); // Maximize the window. static void maximize(); // Is the window maximized? static bool isMaximized(); // Restore the window. static void restore(); // Move the window to the position (|left|, |top|). static void moveTo(long left, long top); // Resize the window to |width|x|height| pixels in size. static void resizeTo(long width, long height); // Draw attention to the window. static void drawAttention(); // Clear attention to the window. static void clearAttention(); // Close the window. static void close(); // Show the window. Does nothing if the window is already visible. static void show(); // Hide the window. Does nothing if the window is already hidden. static void hide(); // Get the window's bounds as a $ref:Bounds object. [nocompile] static Bounds getBounds(); // Set the window's bounds. static void setBounds(Bounds bounds); // Set the app icon for the window (experimental). // Currently this is only being implemented on Ash. // TODO(stevenjb): Investigate implementing this on Windows and OSX. [nodoc] static void setIcon(DOMString icon_url); // The JavaScript 'window' object for the created child. [instanceOf=global] object contentWindow; }; interface Functions { // The size and position of a window can be specified in a number of // different ways. The most simple option is not specifying anything at // all, in which case a default size and platform dependent position will // be used. // // Another option is to use the top/left and width/height properties, // which will always put the window at the specified coordinates with the // specified size. // // Yet another option is to give the window a (unique) id. This id is then // used to remember the size and position of the window whenever it is // moved or resized. This size and position is then used instead of the // specified bounds on subsequent opening of a window with the same id. If // you need to open a window with an id at a location other than the // remembered default, you can create it hidden, move it to the desired // location, then show it. // // You can also combine these various options, explicitly specifying for // example the size while having the position be remembered or other // combinations like that. Size and position are dealt with seperately, // but individual coordinates are not. So if you specify a top (or left) // coordinate, you should also specify a left (or top) coordinate, and // similar for size. // // If you specify both a regular and a default value for the same option // the regular value is the only one that takes effect. static void create(DOMString url, optional CreateWindowOptions options, optional CreateWindowCallback callback); // Returns an $ref:AppWindow object for the // current script context (ie JavaScript 'window' object). This can also be // called on a handle to a script context for another page, for example: // otherWindow.chrome.app.window.current(). [nocompile] static AppWindow current(); [nocompile, nodoc] static void initializeAppWindow(object state); }; interface Events { // Fired when the window is resized. [nocompile] static void onBoundsChanged(); // Fired when the window is closed. [nocompile] static void onClosed(); // Fired when the window is maximized. [nocompile] static void onMaximized(); // Fired when the window is minimized. [nocompile] static void onMinimized(); // Fired when the window is restored from being minimized or maximized. [nocompile] static void onRestored(); }; };