Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: ui/views/views_delegate.h

Issue 2746763007: Adds a factory function to ViewsDelegate for DesktopWindowTreeHost (Closed)
Patch Set: cleanup Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/views/mus/mus_client.cc ('k') | ui/views/widget/desktop_aura/desktop_native_widget_aura.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef UI_VIEWS_VIEWS_DELEGATE_H_ 5 #ifndef UI_VIEWS_VIEWS_DELEGATE_H_
6 #define UI_VIEWS_VIEWS_DELEGATE_H_ 6 #define UI_VIEWS_VIEWS_DELEGATE_H_
7 7
8 #include <memory>
8 #include <string> 9 #include <string>
9 10
10 #if defined(OS_WIN) 11 #if defined(OS_WIN)
11 #include <windows.h> 12 #include <windows.h>
12 #endif 13 #endif
13 14
14 #include "base/callback.h" 15 #include "base/callback.h"
15 #include "base/location.h" 16 #include "base/location.h"
16 #include "base/macros.h" 17 #include "base/macros.h"
17 #include "base/strings/string16.h" 18 #include "base/strings/string16.h"
(...skipping 26 matching lines...) Expand all
44 45
45 namespace views { 46 namespace views {
46 47
47 class NativeWidget; 48 class NativeWidget;
48 class NonClientFrameView; 49 class NonClientFrameView;
49 class ViewsTouchEditingControllerFactory; 50 class ViewsTouchEditingControllerFactory;
50 class View; 51 class View;
51 class Widget; 52 class Widget;
52 53
53 #if defined(USE_AURA) 54 #if defined(USE_AURA)
55 class DesktopNativeWidgetAura;
56 class DesktopWindowTreeHost;
54 class TouchSelectionMenuRunnerViews; 57 class TouchSelectionMenuRunnerViews;
55 #endif 58 #endif
56 59
57 namespace internal { 60 namespace internal {
58 class NativeWidgetDelegate; 61 class NativeWidgetDelegate;
59 } 62 }
60 63
61 enum class InsetsMetric { 64 enum class InsetsMetric {
62 // The margins that should be applied around a bubble dialog. 65 // The margins that should be applied around a bubble dialog.
63 BUBBLE_DIALOG, 66 BUBBLE_DIALOG,
(...skipping 27 matching lines...) Expand all
91 // framework. It is used to obtain various high level application utilities 94 // framework. It is used to obtain various high level application utilities
92 // and perform some actions such as window placement saving. 95 // and perform some actions such as window placement saving.
93 // 96 //
94 // The embedding app must set the ViewsDelegate instance by instantiating an 97 // The embedding app must set the ViewsDelegate instance by instantiating an
95 // implementation of ViewsDelegate (the constructor will set the instance). 98 // implementation of ViewsDelegate (the constructor will set the instance).
96 class VIEWS_EXPORT ViewsDelegate { 99 class VIEWS_EXPORT ViewsDelegate {
97 public: 100 public:
98 using NativeWidgetFactory = 101 using NativeWidgetFactory =
99 base::Callback<NativeWidget*(const Widget::InitParams&, 102 base::Callback<NativeWidget*(const Widget::InitParams&,
100 internal::NativeWidgetDelegate*)>; 103 internal::NativeWidgetDelegate*)>;
104 #if defined(USE_AURA)
105 using DesktopWindowTreeHostFactory =
106 base::Callback<std::unique_ptr<DesktopWindowTreeHost>(
107 const Widget::InitParams&,
108 internal::NativeWidgetDelegate*,
109 DesktopNativeWidgetAura*)>;
110 #endif
111
101 #if defined(OS_WIN) 112 #if defined(OS_WIN)
102 enum AppbarAutohideEdge { 113 enum AppbarAutohideEdge {
103 EDGE_TOP = 1 << 0, 114 EDGE_TOP = 1 << 0,
104 EDGE_LEFT = 1 << 1, 115 EDGE_LEFT = 1 << 1,
105 EDGE_BOTTOM = 1 << 2, 116 EDGE_BOTTOM = 1 << 2,
106 EDGE_RIGHT = 1 << 3, 117 EDGE_RIGHT = 1 << 3,
107 }; 118 };
108 #endif 119 #endif
109 120
110 enum class ProcessMenuAcceleratorResult { 121 enum class ProcessMenuAcceleratorResult {
111 // The accelerator was handled while the menu was showing. No further action 122 // The accelerator was handled while the menu was showing. No further action
112 // is needed and the menu should be kept open. 123 // is needed and the menu should be kept open.
113 LEAVE_MENU_OPEN, 124 LEAVE_MENU_OPEN,
114 125
115 // The accelerator was not handled. Menu should be closed and the 126 // The accelerator was not handled. Menu should be closed and the
116 // accelerator will be reposted to be handled after the menu closes. 127 // accelerator will be reposted to be handled after the menu closes.
117 CLOSE_MENU 128 CLOSE_MENU
118 }; 129 };
119 130
120 virtual ~ViewsDelegate(); 131 virtual ~ViewsDelegate();
121 132
122 // Returns the ViewsDelegate instance if there is one, or nullptr otherwise. 133 // Returns the ViewsDelegate instance if there is one, or nullptr otherwise.
123 static ViewsDelegate* GetInstance(); 134 static ViewsDelegate* GetInstance();
124 135
125 // Call this method to set a factory callback that will be used to construct 136 // Call this method to set a factory callback that will be used to construct
126 // NativeWidget implementations overriding the platform defaults. 137 // NativeWidget implementations overriding the platform defaults.
127 void set_native_widget_factory(NativeWidgetFactory factory) { 138 void set_native_widget_factory(const NativeWidgetFactory& factory) {
128 native_widget_factory_ = factory; 139 native_widget_factory_ = factory;
129 } 140 }
130 const NativeWidgetFactory& native_widget_factory() { 141 const NativeWidgetFactory& native_widget_factory() const {
131 return native_widget_factory_; 142 return native_widget_factory_;
132 } 143 }
133 144
145 #if defined(USE_AURA)
146 void set_desktop_window_tree_host_factory(
147 const DesktopWindowTreeHostFactory& factory) {
148 desktop_window_tree_host_factory_ = factory;
149 }
150 const DesktopWindowTreeHostFactory& desktop_window_tree_host_factory() const {
151 return desktop_window_tree_host_factory_;
152 }
153 #endif
134 // Saves the position, size and "show" state for the window with the 154 // Saves the position, size and "show" state for the window with the
135 // specified name. 155 // specified name.
136 virtual void SaveWindowPlacement(const Widget* widget, 156 virtual void SaveWindowPlacement(const Widget* widget,
137 const std::string& window_name, 157 const std::string& window_name,
138 const gfx::Rect& bounds, 158 const gfx::Rect& bounds,
139 ui::WindowShowState show_state); 159 ui::WindowShowState show_state);
140 160
141 // Retrieves the saved position and size and "show" state for the window with 161 // Retrieves the saved position and size and "show" state for the window with
142 // the specified name. 162 // the specified name.
143 virtual bool GetSavedWindowPlacement(const Widget* widget, 163 virtual bool GetSavedWindowPlacement(const Widget* widget,
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 virtual int GetDistanceMetric(DistanceMetric metric) const; 253 virtual int GetDistanceMetric(DistanceMetric metric) const;
234 254
235 protected: 255 protected:
236 ViewsDelegate(); 256 ViewsDelegate();
237 257
238 private: 258 private:
239 std::unique_ptr<ViewsTouchEditingControllerFactory> views_tsc_factory_; 259 std::unique_ptr<ViewsTouchEditingControllerFactory> views_tsc_factory_;
240 260
241 #if defined(USE_AURA) 261 #if defined(USE_AURA)
242 std::unique_ptr<TouchSelectionMenuRunnerViews> touch_selection_menu_runner_; 262 std::unique_ptr<TouchSelectionMenuRunnerViews> touch_selection_menu_runner_;
263
264 DesktopWindowTreeHostFactory desktop_window_tree_host_factory_;
243 #endif 265 #endif
244 266
245 NativeWidgetFactory native_widget_factory_; 267 NativeWidgetFactory native_widget_factory_;
246 268
247 DISALLOW_COPY_AND_ASSIGN(ViewsDelegate); 269 DISALLOW_COPY_AND_ASSIGN(ViewsDelegate);
248 }; 270 };
249 271
250 } // namespace views 272 } // namespace views
251 273
252 #endif // UI_VIEWS_VIEWS_DELEGATE_H_ 274 #endif // UI_VIEWS_VIEWS_DELEGATE_H_
OLDNEW
« no previous file with comments | « ui/views/mus/mus_client.cc ('k') | ui/views/widget/desktop_aura/desktop_native_widget_aura.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698