Upstream version 9.37.193.0
[platform/framework/web/crosswalk.git] / src / xwalk / runtime / browser / ui / native_app_window.h
1 // Copyright (c) 2013 Intel Corporation. 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 #ifndef XWALK_RUNTIME_BROWSER_UI_NATIVE_APP_WINDOW_H_
6 #define XWALK_RUNTIME_BROWSER_UI_NATIVE_APP_WINDOW_H_
7
8 #include "base/compiler_specific.h"
9 #include "base/files/file_path.h"
10 #include "base/strings/string16.h"
11 #include "ui/base/ui_base_types.h"
12 #include "ui/gfx/image/image.h"
13 #include "ui/gfx/native_widget_types.h"
14 #include "ui/gfx/rect.h"
15 #include "ui/gfx/size.h"
16
17 namespace content {
18 class WebContents;
19 }
20
21 namespace xwalk {
22
23 class NativeAppWindowDelegate {
24  public:
25   // Called when native app window is being destroyed.
26   virtual void OnWindowDestroyed() {}
27
28  protected:
29   virtual ~NativeAppWindowDelegate() {}
30 };
31
32 // Base window class for native application.
33 class NativeAppWindow {
34  public:
35   struct CreateParams {
36     CreateParams();
37     ~CreateParams();
38     // Delegate for this window.
39     NativeAppWindowDelegate* delegate;
40     // WebContents which the content will be displayed in this window.
41     content::WebContents* web_contents;
42     // The initial window bounds, empty means default bound will be used.
43     gfx::Rect bounds;
44     // The minimum window size. The window can only be resized to smaller if
45     // its width or height is greater than the value in |minimum_size|.
46     gfx::Size minimum_size;
47     // The maximum window size. The window can only be resized to bigger if
48     // its width or height is lower than the value in |maximum_size|.
49     gfx::Size maximum_size;
50     // The window state, e.g. fullscreen, maximized and minimized.
51     ui::WindowShowState state;
52     // True if the window can be resized.
53     bool resizable;
54     // Used only by X11. Specifies the PID set in _NET_WM_PID window property.
55     int32 net_wm_pid;
56     // The parent view which this window belongs to. NULL if it is root window.
57     gfx::NativeView parent;
58     // The absolute path of splash screen.
59     // Empty if splash screen is not to be shown.
60     base::FilePath splash_screen_path;
61   };
62
63   // Do one time initialization at application startup.
64   static void Initialize();
65
66   // Initialize the platform-specific native app window.
67   static NativeAppWindow* Create(const CreateParams& params);
68
69   // Return a platform dependent identifier for this window.
70   virtual gfx::NativeWindow GetNativeWindow() const = 0;
71   // Returns true if the window has no frame.
72   // Called when the icon of the window changes.
73   virtual void UpdateIcon(const gfx::Image& icon) = 0;
74   // Called when the title of the window changes.
75   virtual void UpdateTitle(const base::string16& title) = 0;
76   // Returns the nonmaximized bounds of the window (even if the window is
77   // currently maximized or minimized) in terms of the screen coordinates.
78   virtual gfx::Rect GetRestoredBounds() const = 0;
79   // Retrieves the window's current bounds, including its window.
80   virtual gfx::Rect GetBounds() const = 0;
81   // Sets the window's size and position to the specified values.
82   virtual void SetBounds(const gfx::Rect& bounds) = 0;
83
84   // Focus the native app window.
85   virtual void Focus() = 0;
86   // Shows the window, or activates it if it's already visible.
87   virtual void Show() = 0;
88   // Hides the window.
89   virtual void Hide() = 0;
90   // Maximizes the window.
91   virtual void Maximize() = 0;
92   // Minimized the window.
93   virtual void Minimize() = 0;
94   // Toggle the window fullscreen status.
95   virtual void SetFullscreen(bool fullscreen) = 0;
96   // Restore the window.
97   virtual void Restore() = 0;
98   // Flash the taskbar item associated with this window.
99   // Set |flash| to true to initiate flashing, false to stop flashing.
100   virtual void FlashFrame(bool flash) = 0;
101   // Close the window as soon as possible. The close action may be delayed
102   // if an operation is in progress (e.g. a drag operation).
103   virtual void Close() = 0;
104
105   // Returns true if the window is currently the active/focused window.
106   virtual bool IsActive() const = 0;
107   virtual bool IsMaximized() const = 0;
108   virtual bool IsMinimized() const = 0;
109   virtual bool IsFullscreen() const = 0;
110
111  protected:
112   virtual ~NativeAppWindow() {}
113 };
114
115 }  // namespace xwalk
116 #endif  // XWALK_RUNTIME_BROWSER_UI_NATIVE_APP_WINDOW_H_