- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / common / extensions / api / app_window.idl
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Use the <code>chrome.app.window</code> API to create windows. Windows
6 // have an optional frame with title bar and size controls. They are not
7 // associated with any Chrome browser windows.
8 namespace app.window {
9   dictionary Bounds {
10     long? left;
11     long? top;
12     long? width;
13     long? height;
14   };
15
16   // State of a window: normal, fullscreen, maximized, minimized.
17   enum State { normal, fullscreen, maximized, minimized };
18
19   // 'shell' is the default window type. 'panel' is managed by the OS
20   // (Currently experimental, Ash only).
21   [nodoc] enum WindowType { shell, panel };
22
23   dictionary CreateWindowOptions {
24     // Id to identify the window. This will be used to remember the size
25     // and position of the window and restore that geometry when a window
26     // with the same id is later opened.
27     DOMString? id;
28
29     // Default width of the window. (Deprecated; regular bounds act like this
30     // now.)
31     [nodoc] long? defaultWidth;
32
33     // Default height of the window. (Deprecated; regular bounds act like this
34     // now.)
35     [nodoc] long? defaultHeight;
36
37     // Default X coordinate of the window. (Deprecated; regular bounds act like
38     // this now.)
39     [nodoc] long? defaultLeft;
40
41     // Default Y coordinate of the window. (Deprecated; regular bounds act like
42     // this now.)
43     [nodoc] long? defaultTop;
44
45     // Width of the window. (Deprecated; use 'bounds'.)
46     [nodoc] long? width;
47
48     // Height of the window. (Deprecated; use 'bounds'.)
49     [nodoc] long? height;
50
51     // X coordinate of the window. (Deprecated; use 'bounds'.)
52     [nodoc] long? left;
53
54     // Y coordinate of the window. (Deprecated; use 'bounds'.)
55     [nodoc] long? top;
56
57     // Minimum width of the window.
58     long? minWidth;
59
60     // Minimum height of the window.
61     long? minHeight;
62
63     // Maximum width of the window.
64     long? maxWidth;
65
66     // Maximum height of the window.
67     long? maxHeight;
68
69     // Type of window to create.
70     [nodoc] WindowType? type;
71
72     // Frame type: <code>none</code> or <code>chrome</code> (defaults to
73     // <code>chrome</code>). For <code>none</code>, the
74     // <code>-webkit-app-region</code> CSS property can be used to apply
75     // draggability to the app's window. <code>-webkit-app-region: drag</code>
76     // can be used to mark regions draggable. <code>no-drag</code> can be used
77     // to disable this style on nested elements.
78     DOMString? frame;
79
80     // Size and position of the content in the window (excluding the titlebar).
81     // If an id is also specified and a window with a matching id has been shown
82     // before, the remembered bounds of the window will be used instead.
83     Bounds? bounds;
84
85     // Enable window background transparency.
86     // Only supported in ash. Requires experimental API permission.
87     boolean? transparentBackground;
88
89     // The initial state of the window, allowing it to be created already
90     // fullscreen, maximized, or minimized. Defaults to 'normal'.
91     State? state;
92
93     // If true, the window will be created in a hidden state. Call show() on
94     // the window to show it once it has been created. Defaults to false.
95     boolean? hidden;
96
97     // If true, the window will be resizable by the user. Defaults to true.
98     boolean? resizable;
99
100     // By default if you specify an id for the window, the window will only be
101     // created if another window with the same id doesn't already exist. If a
102     // window with the same id already exists that window is activated instead.
103     // If you do want to create multiple windows with the same id, you can
104     // set this property to false.
105     boolean? singleton;
106
107     // If true, the window will stay above most other windows. If there are
108     // multiple windows of this kind, the currently focused window will be in
109     // the foreground. Defaults to false. Call <code>setAlwaysOnTop()</code> on
110     // the window to change this property after creation.
111     boolean? alwaysOnTop;
112   };
113
114   // Called in the creating window (parent) before the load event is called in
115   // the created window (child). The parent can set fields or functions on the
116   // child usable from onload. E.g. background.js:<br>
117   // <code>function(createdWindow) { createdWindow.contentWindow.foo =
118   // function () { }; };</code>
119   // <br>window.js:<br>
120   // <code>window.onload = function () { foo(); }</code>
121   callback CreateWindowCallback =
122       void ([instanceOf=AppWindow] object createdWindow);
123
124   [noinline_doc] dictionary AppWindow {
125     // Focus the window.
126     static void focus();
127
128     // Fullscreens the window.
129     static void fullscreen();
130
131     // Is the window fullscreen?
132     static boolean isFullscreen();
133
134     // Minimize the window.
135     static void minimize();
136
137     // Is the window minimized?
138     static boolean isMinimized();
139
140     // Maximize the window.
141     static void maximize();
142
143     // Is the window maximized?
144     static boolean isMaximized();
145
146     // Restore the window, exiting a maximized, minimized, or fullscreen state.
147     static void restore();
148
149     // Move the window to the position (|left|, |top|).
150     static void moveTo(long left, long top);
151
152     // Resize the window to |width|x|height| pixels in size.
153     static void resizeTo(long width, long height);
154
155     // Draw attention to the window.
156     static void drawAttention();
157
158     // Clear attention to the window.
159     static void clearAttention();
160
161     // Close the window.
162     static void close();
163
164     // Show the window. Does nothing if the window is already visible.
165     static void show();
166
167     // Hide the window. Does nothing if the window is already hidden.
168     static void hide();
169
170     // Get the window's bounds as a $ref:Bounds object.
171     [nocompile] static Bounds getBounds();
172
173     // Set the window's bounds.
174     static void setBounds(Bounds bounds);
175
176     // Get the current minimum width of the window. Returns |undefined| if there
177     // is no minimum.
178     [nocompile] static long getMinWidth();
179
180     // Get the current minimum height of the window. Returns |undefined| if
181     // there is no minimum.
182     [nocompile] static long getMinHeight();
183
184     // Get the current maximum width of the window. Returns |undefined| if there
185     // is no maximum.
186     [nocompile] static long getMaxWidth();
187
188     // Get the current maximum height of the window. Returns |undefined| if
189     // there is no maximum.
190     [nocompile] static long getMaxHeight();
191
192     // Set the current minimum width of the window. Set to |null| to remove the
193     // constraint.
194     static void setMinWidth(optional long minWidth);
195
196     // Set the current minimum height of the window. Set to |null| to remove the
197     // constraint.
198     static void setMinHeight(optional long minHeight);
199
200     // Set the current maximum width of the window. Set to |null| to remove the
201     // constraint.
202     static void setMaxWidth(optional long maxWidth);
203
204     // Set the current maximum height of the window. Set to |null| to remove the
205     // constraint.
206     static void setMaxHeight(optional long maxHeight);
207
208     // Set the app icon for the window (experimental).
209     // Currently this is only being implemented on Ash.
210     // TODO(stevenjb): Investigate implementing this on Windows and OSX.
211     [nodoc] static void setIcon(DOMString iconUrl);
212
213     // Is the window always on top?
214     static boolean isAlwaysOnTop();
215
216     // Set whether the window should stay above most other windows.
217     static void setAlwaysOnTop(boolean alwaysOnTop);
218
219     // The JavaScript 'window' object for the created child.
220     [instanceOf=Window] object contentWindow;
221   };
222
223   interface Functions {
224     // The size and position of a window can be specified in a number of
225     // different ways. The most simple option is not specifying anything at
226     // all, in which case a default size and platform dependent position will
227     // be used.
228     //
229     // Another option is to use the bounds property, which will put the window
230     // at the specified coordinates with the specified size. If the window has
231     // a frame, it's total size will be the size given plus the size of the
232     // frame; that is, the size in bounds is the content size, not the window
233     // size.
234     //
235     // To automatically remember the positions of windows you can give them ids.
236     // If a window has an id, This id is used to remember the size and position
237     // of the window whenever it is moved or resized. This size and position is
238     // then used instead of the specified bounds on subsequent opening of a
239     // window with the same id. If you need to open a window with an id at a
240     // location other than the remembered default, you can create it hidden,
241     // move it to the desired location, then show it.
242     static void create(DOMString url,
243                        optional CreateWindowOptions options,
244                        optional CreateWindowCallback callback);
245
246     // Returns an $ref:AppWindow object for the
247     // current script context (ie JavaScript 'window' object). This can also be
248     // called on a handle to a script context for another page, for example:
249     // otherWindow.chrome.app.window.current().
250     [nocompile] static AppWindow current();
251     [nocompile, nodoc] static void initializeAppWindow(object state);
252   };
253
254   interface Events {
255     // Fired when the window is resized.
256     [nocompile] static void onBoundsChanged();
257
258     // Fired when the window is closed.
259     [nocompile] static void onClosed();
260
261     // Fired when the window is fullscreened.
262     [nocompile] static void onFullscreened();
263
264     // Fired when the window is maximized.
265     [nocompile] static void onMaximized();
266
267     // Fired when the window is minimized.
268     [nocompile] static void onMinimized();
269
270     // Fired when the window is restored from being minimized or maximized.
271     [nocompile] static void onRestored();
272   };
273 };