Revert 268405 "Make sure that ScratchBuffer::Allocate() always r..."
[chromium-blink-merge.git] / ui / views / views_delegate.h
blob8be8a0d5844bf2c0b80ad42332953c9968d415ad
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.
5 #ifndef UI_VIEWS_VIEWS_DELEGATE_H_
6 #define UI_VIEWS_VIEWS_DELEGATE_H_
8 #include <string>
10 #if defined(OS_WIN)
11 #include <windows.h>
12 #endif
14 #include "base/strings/string16.h"
15 #include "ui/accessibility/ax_enums.h"
16 #include "ui/base/ui_base_types.h"
17 #include "ui/gfx/native_widget_types.h"
18 #include "ui/views/views_export.h"
19 #include "ui/views/widget/widget.h"
21 namespace base {
22 class TimeDelta;
25 namespace content {
26 class WebContents;
27 class BrowserContext;
28 class SiteInstance;
31 namespace gfx {
32 class ImageSkia;
33 class Rect;
36 namespace views {
38 class NativeWidget;
39 class NonClientFrameView;
40 class ViewsTouchSelectionControllerFactory;
41 class View;
42 class Widget;
43 namespace internal {
44 class NativeWidgetDelegate;
47 // ViewsDelegate is an interface implemented by an object using the views
48 // framework. It is used to obtain various high level application utilities
49 // and perform some actions such as window placement saving.
51 // The embedding app must set views_delegate to assign its ViewsDelegate
52 // implementation.
53 class VIEWS_EXPORT ViewsDelegate {
54 public:
55 #if defined(OS_WIN)
56 enum AppbarAutohideEdge {
57 EDGE_TOP = 1 << 0,
58 EDGE_LEFT = 1 << 1,
59 EDGE_BOTTOM = 1 << 2,
60 EDGE_RIGHT = 1 << 3,
62 #endif
64 ViewsDelegate();
65 virtual ~ViewsDelegate();
67 // Saves the position, size and "show" state for the window with the
68 // specified name.
69 virtual void SaveWindowPlacement(const Widget* widget,
70 const std::string& window_name,
71 const gfx::Rect& bounds,
72 ui::WindowShowState show_state);
74 // Retrieves the saved position and size and "show" state for the window with
75 // the specified name.
76 virtual bool GetSavedWindowPlacement(const Widget* widget,
77 const std::string& window_name,
78 gfx::Rect* bounds,
79 ui::WindowShowState* show_state) const;
81 virtual void NotifyAccessibilityEvent(View* view, ui::AXEvent event_type);
83 // For accessibility, notify the delegate that a menu item was focused
84 // so that alternate feedback (speech / magnified text) can be provided.
85 virtual void NotifyMenuItemFocused(const base::string16& menu_name,
86 const base::string16& menu_item_name,
87 int item_index,
88 int item_count,
89 bool has_submenu);
91 #if defined(OS_WIN)
92 // Retrieves the default window icon to use for windows if none is specified.
93 virtual HICON GetDefaultWindowIcon() const;
94 // Returns true if the window passed in is in the Windows 8 metro
95 // environment.
96 virtual bool IsWindowInMetro(gfx::NativeWindow window) const;
97 #elif defined(OS_LINUX) && !defined(OS_CHROMEOS)
98 virtual gfx::ImageSkia* GetDefaultWindowIcon() const;
99 #endif
101 // Creates a default NonClientFrameView to be used for windows that don't
102 // specify their own. If this function returns NULL, the
103 // views::CustomFrameView type will be used.
104 virtual NonClientFrameView* CreateDefaultNonClientFrameView(Widget* widget);
106 // AddRef/ReleaseRef are invoked while a menu is visible. They are used to
107 // ensure we don't attempt to exit while a menu is showing.
108 virtual void AddRef();
109 virtual void ReleaseRef();
111 // Creates a web contents. This will return NULL unless overriden.
112 virtual content::WebContents* CreateWebContents(
113 content::BrowserContext* browser_context,
114 content::SiteInstance* site_instance);
116 // Gives the platform a chance to modify the properties of a Widget.
117 virtual void OnBeforeWidgetInit(Widget::InitParams* params,
118 internal::NativeWidgetDelegate* delegate) = 0;
120 // Returns the default obscured text reveal duration.
121 virtual base::TimeDelta GetDefaultTextfieldObscuredRevealDuration();
123 // Returns true if the operating system's window manager will always provide a
124 // title bar with caption buttons (ignoring the setting to
125 // |remove_standard_frame| in InitParams). If |maximized|, this applies to
126 // maximized windows; otherwise to restored windows.
127 virtual bool WindowManagerProvidesTitleBar(bool maximized);
129 #if defined(OS_WIN)
130 // Starts a query for the appbar autohide edges of the specified monitor and
131 // returns the current value. If the query finds the edges have changed from
132 // the current value, |callback| is subsequently invoked. If the edges have
133 // not changed, |callback| is never run.
135 // The return value is a bitmask of AppbarAutohideEdge.
136 virtual int GetAppbarAutohideEdges(HMONITOR monitor,
137 const base::Closure& callback);
138 #endif
140 // The active ViewsDelegate used by the views system.
141 static ViewsDelegate* views_delegate;
143 private:
144 scoped_ptr<ViewsTouchSelectionControllerFactory> views_tsc_factory_;
146 DISALLOW_COPY_AND_ASSIGN(ViewsDelegate);
149 } // namespace views
151 #endif // UI_VIEWS_VIEWS_DELEGATE_H_