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