Drive: Add BatchableRequest subclass.
[chromium-blink-merge.git] / ui / views / views_delegate.h
blobea14e7887047e936145986e3fe52f8994c32e53a
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 ui {
37 class ContextFactory;
40 namespace views {
42 class NativeWidget;
43 class NonClientFrameView;
44 class ViewsTouchEditingControllerFactory;
45 class View;
46 class Widget;
47 namespace internal {
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
56 // implementation.
57 class VIEWS_EXPORT ViewsDelegate {
58 public:
59 #if defined(OS_WIN)
60 enum AppbarAutohideEdge {
61 EDGE_TOP = 1 << 0,
62 EDGE_LEFT = 1 << 1,
63 EDGE_BOTTOM = 1 << 2,
64 EDGE_RIGHT = 1 << 3,
66 #endif
68 ViewsDelegate();
69 virtual ~ViewsDelegate();
71 // Saves the position, size and "show" state for the window with the
72 // specified name.
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,
82 gfx::Rect* bounds,
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,
91 int item_index,
92 int item_count,
93 bool has_submenu);
95 #if defined(OS_WIN)
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
101 // environment.
102 virtual bool IsWindowInMetro(gfx::NativeWindow window) const;
103 #elif defined(OS_LINUX) && !defined(OS_CHROMEOS)
104 virtual gfx::ImageSkia* GetDefaultWindowIcon() const;
105 #endif
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();
138 // Returns the user-visible name of the application.
139 virtual std::string GetApplicationName();
141 #if defined(OS_WIN)
142 // Starts a query for the appbar autohide edges of the specified monitor and
143 // returns the current value. If the query finds the edges have changed from
144 // the current value, |callback| is subsequently invoked. If the edges have
145 // not changed, |callback| is never run.
147 // The return value is a bitmask of AppbarAutohideEdge.
148 virtual int GetAppbarAutohideEdges(HMONITOR monitor,
149 const base::Closure& callback);
150 #endif
152 // The active ViewsDelegate used by the views system.
153 static ViewsDelegate* views_delegate;
155 private:
156 scoped_ptr<ViewsTouchEditingControllerFactory> views_tsc_factory_;
158 DISALLOW_COPY_AND_ASSIGN(ViewsDelegate);
161 } // namespace views
163 #endif // UI_VIEWS_VIEWS_DELEGATE_H_