Fix cookie searchbox bug.
[chromium-blink-merge.git] / ui / views / views_delegate.h
blob72aaeeaa8e611402a4c05f99a4a64c268efa3b51
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/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"
21 namespace content {
22 class WebContents;
23 class BrowserContext;
24 class SiteInstance;
27 namespace gfx {
28 class Rect;
31 namespace views {
33 class NativeWidget;
34 class NonClientFrameView;
35 class ViewsTouchSelectionControllerFactory;
36 class View;
37 class Widget;
38 namespace internal {
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
47 // implementation.
48 class VIEWS_EXPORT ViewsDelegate {
49 public:
50 // The active ViewsDelegate used by the views system.
51 static ViewsDelegate* views_delegate;
53 ViewsDelegate();
55 virtual ~ViewsDelegate();
57 // Saves the position, size and "show" state for the window with the
58 // specified name.
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,
68 gfx::Rect* bounds,
69 ui::WindowShowState* show_state) const = 0;
71 virtual void NotifyAccessibilityEvent(
72 View* view,
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,
79 int item_index,
80 int item_count,
81 bool has_submenu) = 0;
83 #if defined(OS_WIN)
84 // Retrieves the default window icon to use for windows if none is specified.
85 virtual HICON GetDefaultWindowIcon() const = 0;
86 #endif
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(
92 Widget* widget) = 0;
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;
113 private:
114 scoped_ptr<ViewsTouchSelectionControllerFactory> views_tsc_factory_;
117 } // namespace views
119 #endif // UI_VIEWS_VIEWS_DELEGATE_H_