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

Side by Side Diff: ui/views/widget/widget.cc

Issue 10913237: Allow the Views Delegate to provide the native widget. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 3 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 | Annotate | Revision Log
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 #include "ui/views/widget/widget.h" 5 #include "ui/views/widget/widget.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "ui/base/events/event.h" 10 #include "ui/base/events/event.h"
(...skipping 30 matching lines...) Expand all
41 // views that are direct children of the Widgets layer. 41 // views that are direct children of the Widgets layer.
42 void BuildRootLayers(View* view, std::vector<ui::Layer*>* layers) { 42 void BuildRootLayers(View* view, std::vector<ui::Layer*>* layers) {
43 if (view->layer()) { 43 if (view->layer()) {
44 layers->push_back(view->layer()); 44 layers->push_back(view->layer());
45 } else { 45 } else {
46 for (int i = 0; i < view->child_count(); ++i) 46 for (int i = 0; i < view->child_count(); ++i)
47 BuildRootLayers(view->child_at(i), layers); 47 BuildRootLayers(view->child_at(i), layers);
48 } 48 }
49 } 49 }
50 50
51 // Create a native widget implementation.
52 // First, use the supplied one if non-NULL.
53 // Second, ask the delegate.
54 // Finally, make a default one.
55 NativeWidget* CreateNativeWidget(NativeWidget* native_widget,
56 internal::NativeWidgetDelegate* delegate,
57 gfx::NativeView parent) {
58 if (!native_widget && ViewsDelegate::views_delegate) {
59 native_widget =
60 ViewsDelegate::views_delegate->CreateNativeWidget(delegate, parent);
61 if (!native_widget) {
62 native_widget =
63 internal::NativeWidgetPrivate::CreateNativeWidget(delegate);
64 }
65 }
66 return native_widget;
67 }
68
51 } // namespace 69 } // namespace
52 70
53 // This class is used to keep track of the event a Widget is processing, and 71 // This class is used to keep track of the event a Widget is processing, and
54 // restore any previously active event afterwards. 72 // restore any previously active event afterwards.
55 class ScopedEvent { 73 class ScopedEvent {
56 public: 74 public:
57 ScopedEvent(Widget* widget, const ui::Event& event) 75 ScopedEvent(Widget* widget, const ui::Event& event)
58 : widget_(widget), 76 : widget_(widget),
59 event_(&event) { 77 event_(&event) {
60 widget->event_stack_.push(this); 78 widget->event_stack_.push(this);
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 } 320 }
303 321
304 void Widget::Init(const InitParams& params) { 322 void Widget::Init(const InitParams& params) {
305 is_top_level_ = params.top_level || 323 is_top_level_ = params.top_level ||
306 (!params.child && 324 (!params.child &&
307 params.type != InitParams::TYPE_CONTROL && 325 params.type != InitParams::TYPE_CONTROL &&
308 params.type != InitParams::TYPE_TOOLTIP); 326 params.type != InitParams::TYPE_TOOLTIP);
309 widget_delegate_ = params.delegate ? 327 widget_delegate_ = params.delegate ?
310 params.delegate : new DefaultWidgetDelegate(this, params); 328 params.delegate : new DefaultWidgetDelegate(this, params);
311 ownership_ = params.ownership; 329 ownership_ = params.ownership;
312 native_widget_ = params.native_widget ? 330 native_widget_ =
313 params.native_widget->AsNativeWidgetPrivate() : 331 CreateNativeWidget(params.native_widget, this, params.GetParent())->
314 internal::NativeWidgetPrivate::CreateNativeWidget(this); 332 AsNativeWidgetPrivate();
315 GetRootView(); 333 GetRootView();
316 default_theme_provider_.reset(new DefaultThemeProvider); 334 default_theme_provider_.reset(new DefaultThemeProvider);
317 if (params.type == InitParams::TYPE_MENU) { 335 if (params.type == InitParams::TYPE_MENU) {
318 is_mouse_button_pressed_ = 336 is_mouse_button_pressed_ =
319 internal::NativeWidgetPrivate::IsMouseButtonDown(); 337 internal::NativeWidgetPrivate::IsMouseButtonDown();
320 } 338 }
321 native_widget_->InitNativeWidget(params); 339 native_widget_->InitNativeWidget(params);
322 if (RequiresNonClientView(params.type)) { 340 if (RequiresNonClientView(params.type)) {
323 non_client_view_ = new NonClientView; 341 non_client_view_ = new NonClientView;
324 non_client_view_->SetFrameView(CreateNonClientFrameView()); 342 non_client_view_->SetFrameView(CreateNonClientFrameView());
(...skipping 1002 matching lines...) Expand 10 before | Expand all | Expand 10 after
1327 1345
1328 //////////////////////////////////////////////////////////////////////////////// 1346 ////////////////////////////////////////////////////////////////////////////////
1329 // internal::NativeWidgetPrivate, NativeWidget implementation: 1347 // internal::NativeWidgetPrivate, NativeWidget implementation:
1330 1348
1331 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { 1349 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() {
1332 return this; 1350 return this;
1333 } 1351 }
1334 1352
1335 } // namespace internal 1353 } // namespace internal
1336 } // namespace views 1354 } // namespace views
OLDNEW
« ui/views/views_delegate.h ('K') | « ui/views/widget/desktop_native_widget_aura.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698