1 // Copyright 2014 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.
5 #ifndef EXTENSIONS_BROWSER_APP_WINDOW_NATIVE_APP_WINDOW_H_
6 #define EXTENSIONS_BROWSER_APP_WINDOW_NATIVE_APP_WINDOW_H_
10 #include "base/memory/scoped_ptr.h"
11 #include "components/web_modal/web_contents_modal_dialog_host.h"
12 #include "third_party/skia/include/core/SkColor.h"
13 #include "ui/base/base_window.h"
14 #include "ui/gfx/geometry/insets.h"
17 struct NativeWebKeyboardEvent
;
20 namespace extensions
{
22 struct DraggableRegion
;
24 // This is an interface to a native implementation of a app window, used for
25 // new-style packaged apps. App windows contain a web contents, but no tabs
27 class NativeAppWindow
: public ui::BaseWindow
,
28 public web_modal::WebContentsModalDialogHost
{
30 // Sets whether the window is fullscreen and the type of fullscreen.
31 // |fullscreen_types| is a bit field of AppWindow::FullscreenType.
32 virtual void SetFullscreen(int fullscreen_types
) = 0;
34 // Returns whether the window is fullscreen or about to enter fullscreen.
35 virtual bool IsFullscreenOrPending() const = 0;
37 // Called when the icon of the window changes.
38 virtual void UpdateWindowIcon() = 0;
40 // Called when the title of the window changes.
41 virtual void UpdateWindowTitle() = 0;
43 // Called to update the badge icon.
44 virtual void UpdateBadgeIcon() = 0;
46 // Called when the draggable regions are changed.
47 virtual void UpdateDraggableRegions(
48 const std::vector
<DraggableRegion
>& regions
) = 0;
50 // Returns the region used by frameless windows for dragging. May return NULL.
51 virtual SkRegion
* GetDraggableRegion() = 0;
53 // Called when the window shape is changed. If |region| is NULL then the
54 // window is restored to the default shape.
55 virtual void UpdateShape(scoped_ptr
<SkRegion
> region
) = 0;
57 // Set whether the window should receive all keyboard events including task
59 virtual void SetInterceptAllKeys(bool want_all_keys
) = 0;
61 // Allows the window to handle unhandled keyboard messages coming back from
63 virtual void HandleKeyboardEvent(
64 const content::NativeWebKeyboardEvent
& event
) = 0;
66 // Returns true if the window has no frame, as for a window opened by
67 // chrome.app.window.create with the option 'frame' set to 'none'.
68 virtual bool IsFrameless() const = 0;
70 // Returns information about the window's frame.
71 virtual bool HasFrameColor() const = 0;
72 virtual SkColor
ActiveFrameColor() const = 0;
73 virtual SkColor
InactiveFrameColor() const = 0;
75 // Returns the difference between the window bounds (including titlebar and
76 // borders) and the content bounds, if any.
77 virtual gfx::Insets
GetFrameInsets() const = 0;
79 // Hide or show this window as part of hiding or showing the app.
80 // This may have different logic to Hide, Show, and ShowInactive as those are
81 // called via the AppWindow javascript API.
82 virtual void ShowWithApp() = 0;
83 virtual void HideWithApp() = 0;
85 // Updates custom entries for the context menu of the app's taskbar/dock/shelf
87 virtual void UpdateShelfMenu() = 0;
89 // Returns the minimum size constraints of the content.
90 virtual gfx::Size
GetContentMinimumSize() const = 0;
92 // Returns the maximum size constraints of the content.
93 virtual gfx::Size
GetContentMaximumSize() const = 0;
95 // Updates the minimum and maximum size constraints of the content.
96 virtual void SetContentSizeConstraints(const gfx::Size
& min_size
,
97 const gfx::Size
& max_size
) = 0;
99 // Sets whether the window should be visible on all workspaces.
100 virtual void SetVisibleOnAllWorkspaces(bool always_visible
) = 0;
102 // Returns false if the underlying native window ignores alpha transparency
104 virtual bool CanHaveAlphaEnabled() const = 0;
106 ~NativeAppWindow() override
{}
109 } // namespace extensions
111 #endif // EXTENSIONS_BROWSER_APP_WINDOW_NATIVE_APP_WINDOW_H_