Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / ui / views / views_delegate.h
blob39c7f5a54ea7186b1172a2f84bb16a6c72dd5bd3
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/callback.h"
15 #include "base/location.h"
16 #include "base/strings/string16.h"
17 #include "ui/accessibility/ax_enums.h"
18 #include "ui/base/ui_base_types.h"
19 #include "ui/gfx/native_widget_types.h"
20 #include "ui/views/views_export.h"
21 #include "ui/views/widget/widget.h"
23 namespace base {
24 class TaskRunner;
25 class TimeDelta;
28 namespace content {
29 class WebContents;
30 class BrowserContext;
31 class SiteInstance;
34 namespace gfx {
35 class ImageSkia;
36 class Rect;
39 namespace ui {
40 class ContextFactory;
43 namespace views {
45 class NativeWidget;
46 class NonClientFrameView;
47 class ViewsTouchEditingControllerFactory;
48 class View;
49 class Widget;
51 #if defined(USE_AURA)
52 class TouchSelectionMenuRunnerViews;
53 #endif
55 namespace internal {
56 class NativeWidgetDelegate;
59 // ViewsDelegate is an interface implemented by an object using the views
60 // framework. It is used to obtain various high level application utilities
61 // and perform some actions such as window placement saving.
63 // The embedding app must set views_delegate to assign its ViewsDelegate
64 // implementation.
65 class VIEWS_EXPORT ViewsDelegate {
66 public:
67 #if defined(OS_WIN)
68 enum AppbarAutohideEdge {
69 EDGE_TOP = 1 << 0,
70 EDGE_LEFT = 1 << 1,
71 EDGE_BOTTOM = 1 << 2,
72 EDGE_RIGHT = 1 << 3,
74 #endif
76 ViewsDelegate();
77 virtual ~ViewsDelegate();
79 // Saves the position, size and "show" state for the window with the
80 // specified name.
81 virtual void SaveWindowPlacement(const Widget* widget,
82 const std::string& window_name,
83 const gfx::Rect& bounds,
84 ui::WindowShowState show_state);
86 // Retrieves the saved position and size and "show" state for the window with
87 // the specified name.
88 virtual bool GetSavedWindowPlacement(const Widget* widget,
89 const std::string& window_name,
90 gfx::Rect* bounds,
91 ui::WindowShowState* show_state) const;
93 virtual void NotifyAccessibilityEvent(View* view, ui::AXEvent event_type);
95 // For accessibility, notify the delegate that a menu item was focused
96 // so that alternate feedback (speech / magnified text) can be provided.
97 virtual void NotifyMenuItemFocused(const base::string16& menu_name,
98 const base::string16& menu_item_name,
99 int item_index,
100 int item_count,
101 bool has_submenu);
103 #if defined(OS_WIN)
104 // Retrieves the default window icon to use for windows if none is specified.
105 virtual HICON GetDefaultWindowIcon() const;
106 // Retrieves the small window icon to use for windows if none is specified.
107 virtual HICON GetSmallWindowIcon() const = 0;
108 // Returns true if the window passed in is in the Windows 8 metro
109 // environment.
110 virtual bool IsWindowInMetro(gfx::NativeWindow window) const;
111 #elif defined(OS_LINUX) && !defined(OS_CHROMEOS)
112 virtual gfx::ImageSkia* GetDefaultWindowIcon() const;
113 #endif
115 // Creates a default NonClientFrameView to be used for windows that don't
116 // specify their own. If this function returns NULL, the
117 // views::CustomFrameView type will be used.
118 virtual NonClientFrameView* CreateDefaultNonClientFrameView(Widget* widget);
120 // AddRef/ReleaseRef are invoked while a menu is visible. They are used to
121 // ensure we don't attempt to exit while a menu is showing.
122 virtual void AddRef();
123 virtual void ReleaseRef();
125 // Creates a web contents. This will return NULL unless overriden.
126 virtual content::WebContents* CreateWebContents(
127 content::BrowserContext* browser_context,
128 content::SiteInstance* site_instance);
130 // Gives the platform a chance to modify the properties of a Widget.
131 virtual void OnBeforeWidgetInit(Widget::InitParams* params,
132 internal::NativeWidgetDelegate* delegate) = 0;
134 // Returns the default obscured text reveal duration.
135 virtual base::TimeDelta GetDefaultTextfieldObscuredRevealDuration();
137 // Returns true if the operating system's window manager will always provide a
138 // title bar with caption buttons (ignoring the setting to
139 // |remove_standard_frame| in InitParams). If |maximized|, this applies to
140 // maximized windows; otherwise to restored windows.
141 virtual bool WindowManagerProvidesTitleBar(bool maximized);
143 // Returns the context factory for new windows.
144 virtual ui::ContextFactory* GetContextFactory();
146 // Returns the user-visible name of the application.
147 virtual std::string GetApplicationName();
149 #if defined(OS_WIN)
150 // Starts a query for the appbar autohide edges of the specified monitor and
151 // returns the current value. If the query finds the edges have changed from
152 // the current value, |callback| is subsequently invoked. If the edges have
153 // not changed, |callback| is never run.
155 // The return value is a bitmask of AppbarAutohideEdge.
156 virtual int GetAppbarAutohideEdges(HMONITOR monitor,
157 const base::Closure& callback);
158 #endif
160 // Returns a blocking pool task runner given a TaskRunnerType.
161 virtual scoped_refptr<base::TaskRunner> GetBlockingPoolTaskRunner();
163 // The active ViewsDelegate used by the views system.
164 static ViewsDelegate* views_delegate;
166 private:
167 scoped_ptr<ViewsTouchEditingControllerFactory> views_tsc_factory_;
169 #if defined(USE_AURA)
170 scoped_ptr<TouchSelectionMenuRunnerViews> touch_selection_menu_runner_;
171 #endif
173 DISALLOW_COPY_AND_ASSIGN(ViewsDelegate);
176 } // namespace views
178 #endif // UI_VIEWS_VIEWS_DELEGATE_H_