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_
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"
43 class NonClientFrameView
;
44 class ViewsTouchEditingControllerFactory
;
48 class NativeWidgetDelegate
;
51 // ViewsDelegate is an interface implemented by an object using the views
52 // framework. It is used to obtain various high level application utilities
53 // and perform some actions such as window placement saving.
55 // The embedding app must set views_delegate to assign its ViewsDelegate
57 class VIEWS_EXPORT ViewsDelegate
{
60 enum AppbarAutohideEdge
{
69 virtual ~ViewsDelegate();
71 // Saves the position, size and "show" state for the window with the
73 virtual void SaveWindowPlacement(const Widget
* widget
,
74 const std::string
& window_name
,
75 const gfx::Rect
& bounds
,
76 ui::WindowShowState show_state
);
78 // Retrieves the saved position and size and "show" state for the window with
79 // the specified name.
80 virtual bool GetSavedWindowPlacement(const Widget
* widget
,
81 const std::string
& window_name
,
83 ui::WindowShowState
* show_state
) const;
85 virtual void NotifyAccessibilityEvent(View
* view
, ui::AXEvent event_type
);
87 // For accessibility, notify the delegate that a menu item was focused
88 // so that alternate feedback (speech / magnified text) can be provided.
89 virtual void NotifyMenuItemFocused(const base::string16
& menu_name
,
90 const base::string16
& menu_item_name
,
96 // Retrieves the default window icon to use for windows if none is specified.
97 virtual HICON
GetDefaultWindowIcon() const;
98 // Retrieves the small window icon to use for windows if none is specified.
99 virtual HICON
GetSmallWindowIcon() const = 0;
100 // Returns true if the window passed in is in the Windows 8 metro
102 virtual bool IsWindowInMetro(gfx::NativeWindow window
) const;
103 #elif defined(OS_LINUX) && !defined(OS_CHROMEOS)
104 virtual gfx::ImageSkia
* GetDefaultWindowIcon() const;
107 // Creates a default NonClientFrameView to be used for windows that don't
108 // specify their own. If this function returns NULL, the
109 // views::CustomFrameView type will be used.
110 virtual NonClientFrameView
* CreateDefaultNonClientFrameView(Widget
* widget
);
112 // AddRef/ReleaseRef are invoked while a menu is visible. They are used to
113 // ensure we don't attempt to exit while a menu is showing.
114 virtual void AddRef();
115 virtual void ReleaseRef();
117 // Creates a web contents. This will return NULL unless overriden.
118 virtual content::WebContents
* CreateWebContents(
119 content::BrowserContext
* browser_context
,
120 content::SiteInstance
* site_instance
);
122 // Gives the platform a chance to modify the properties of a Widget.
123 virtual void OnBeforeWidgetInit(Widget::InitParams
* params
,
124 internal::NativeWidgetDelegate
* delegate
) = 0;
126 // Returns the default obscured text reveal duration.
127 virtual base::TimeDelta
GetDefaultTextfieldObscuredRevealDuration();
129 // Returns true if the operating system's window manager will always provide a
130 // title bar with caption buttons (ignoring the setting to
131 // |remove_standard_frame| in InitParams). If |maximized|, this applies to
132 // maximized windows; otherwise to restored windows.
133 virtual bool WindowManagerProvidesTitleBar(bool maximized
);
135 // Returns the context factory for new windows.
136 virtual ui::ContextFactory
* GetContextFactory();
139 // Starts a query for the appbar autohide edges of the specified monitor and
140 // returns the current value. If the query finds the edges have changed from
141 // the current value, |callback| is subsequently invoked. If the edges have
142 // not changed, |callback| is never run.
144 // The return value is a bitmask of AppbarAutohideEdge.
145 virtual int GetAppbarAutohideEdges(HMONITOR monitor
,
146 const base::Closure
& callback
);
149 // The active ViewsDelegate used by the views system.
150 static ViewsDelegate
* views_delegate
;
153 scoped_ptr
<ViewsTouchEditingControllerFactory
> views_tsc_factory_
;
155 DISALLOW_COPY_AND_ASSIGN(ViewsDelegate
);
160 #endif // UI_VIEWS_VIEWS_DELEGATE_H_