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/string16.h"
15 #include "ui/base/accessibility/accessibility_types.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"
34 class NonClientFrameView
;
35 class ViewsTouchSelectionControllerFactory
;
39 class NativeWidgetDelegate
;
42 // ViewsDelegate is an interface implemented by an object using the views
43 // framework. It is used to obtain various high level application utilities
44 // and perform some actions such as window placement saving.
46 // The embedding app must set views_delegate to assign its ViewsDelegate
48 class VIEWS_EXPORT ViewsDelegate
{
50 // The active ViewsDelegate used by the views system.
51 static ViewsDelegate
* views_delegate
;
55 virtual ~ViewsDelegate();
57 // Saves the position, size and "show" state for the window with the
59 virtual void SaveWindowPlacement(const Widget
* widget
,
60 const std::string
& window_name
,
61 const gfx::Rect
& bounds
,
62 ui::WindowShowState show_state
) = 0;
64 // Retrieves the saved position and size and "show" state for the window with
65 // the specified name.
66 virtual bool GetSavedWindowPlacement(
67 const std::string
& window_name
,
69 ui::WindowShowState
* show_state
) const = 0;
71 virtual void NotifyAccessibilityEvent(
73 ui::AccessibilityTypes::Event event_type
) = 0;
75 // For accessibility, notify the delegate that a menu item was focused
76 // so that alternate feedback (speech / magnified text) can be provided.
77 virtual void NotifyMenuItemFocused(const string16
& menu_name
,
78 const string16
& menu_item_name
,
81 bool has_submenu
) = 0;
84 // Retrieves the default window icon to use for windows if none is specified.
85 virtual HICON
GetDefaultWindowIcon() const = 0;
88 // Creates a default NonClientFrameView to be used for windows that don't
89 // specify their own. If this function returns NULL, the
90 // views::CustomFrameView type will be used.
91 virtual NonClientFrameView
* CreateDefaultNonClientFrameView(
94 // Returns whether the embedding app wants windows to be created with the
95 // views::Widget marked as transparent. For example, an app may wish to
96 // apply transparent window frames in the NonClientFrameView.
97 virtual bool UseTransparentWindows() const = 0;
99 // AddRef/ReleaseRef are invoked while a menu is visible. They are used to
100 // ensure we don't attempt to exit while a menu is showing.
101 virtual void AddRef() = 0;
102 virtual void ReleaseRef() = 0;
104 // Creates a web contents. This will return NULL unless overriden.
105 virtual content::WebContents
* CreateWebContents(
106 content::BrowserContext
* browser_context
,
107 content::SiteInstance
* site_instance
) = 0;
109 // Gives the platform a chance to modify the properties of a Widget.
110 virtual void OnBeforeWidgetInit(Widget::InitParams
* params
,
111 internal::NativeWidgetDelegate
* delegate
) = 0;
114 scoped_ptr
<ViewsTouchSelectionControllerFactory
> views_tsc_factory_
;
119 #endif // UI_VIEWS_VIEWS_DELEGATE_H_