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

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

Issue 11578014: Desktop aura: Expand what the ViewsDelegate can do to new windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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
« ui/views/widget/widget.h ('K') | « ui/views/widget/widget.h ('k') | no next file » | 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 #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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
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. 51 // Create a native widget implementation.
52 // First, use the supplied one if non-NULL. 52 // First, use the supplied one if non-NULL.
53 // Second, ask the delegate.
54 // Finally, make a default one. 53 // Finally, make a default one.
55 NativeWidget* CreateNativeWidget(NativeWidget* native_widget, 54 NativeWidget* CreateNativeWidget(NativeWidget* native_widget,
56 internal::NativeWidgetDelegate* delegate, 55 internal::NativeWidgetDelegate* delegate) {
57 Widget::InitParams::Type type,
58 gfx::NativeView parent,
59 gfx::NativeView context) {
60 if (!native_widget) { 56 if (!native_widget) {
61 if (ViewsDelegate::views_delegate) { 57 native_widget =
62 native_widget = ViewsDelegate::views_delegate->CreateNativeWidget( 58 internal::NativeWidgetPrivate::CreateNativeWidget(delegate);
63 type, delegate, parent, context);
64 }
65 if (!native_widget) {
66 native_widget =
67 internal::NativeWidgetPrivate::CreateNativeWidget(delegate);
68 }
69 } 59 }
70 return native_widget; 60 return native_widget;
71 } 61 }
72 62
73 } // namespace 63 } // namespace
74 64
75 // This class is used to keep track of the event a Widget is processing, and 65 // This class is used to keep track of the event a Widget is processing, and
76 // restore any previously active event afterwards. 66 // restore any previously active event afterwards.
77 class ScopedEvent { 67 class ScopedEvent {
78 public: 68 public:
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 238
249 // static 239 // static
250 Widget* Widget::CreateWindowWithParentAndBounds(WidgetDelegate* delegate, 240 Widget* Widget::CreateWindowWithParentAndBounds(WidgetDelegate* delegate,
251 gfx::NativeWindow parent, 241 gfx::NativeWindow parent,
252 const gfx::Rect& bounds) { 242 const gfx::Rect& bounds) {
253 Widget* widget = new Widget; 243 Widget* widget = new Widget;
254 Widget::InitParams params; 244 Widget::InitParams params;
255 params.delegate = delegate; 245 params.delegate = delegate;
256 params.parent = parent; 246 params.parent = parent;
257 params.bounds = bounds; 247 params.bounds = bounds;
248 params.top_level = true;
258 widget->Init(params); 249 widget->Init(params);
259 return widget; 250 return widget;
260 } 251 }
261 252
262 // static 253 // static
263 Widget* Widget::CreateWindowWithContext(WidgetDelegate* delegate, 254 Widget* Widget::CreateWindowWithContext(WidgetDelegate* delegate,
264 gfx::NativeView context) { 255 gfx::NativeView context) {
265 return CreateWindowWithContextAndBounds(delegate, context, gfx::Rect()); 256 return CreateWindowWithContextAndBounds(delegate, context, gfx::Rect());
266 } 257 }
267 258
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 GetLocalizedContentsHeight(row_resource_id)); 323 GetLocalizedContentsHeight(row_resource_id));
333 } 324 }
334 325
335 // static 326 // static
336 bool Widget::RequiresNonClientView(InitParams::Type type) { 327 bool Widget::RequiresNonClientView(InitParams::Type type) {
337 return type == InitParams::TYPE_WINDOW || 328 return type == InitParams::TYPE_WINDOW ||
338 type == InitParams::TYPE_PANEL || 329 type == InitParams::TYPE_PANEL ||
339 type == InitParams::TYPE_BUBBLE; 330 type == InitParams::TYPE_BUBBLE;
340 } 331 }
341 332
342 void Widget::Init(const InitParams& params) { 333 void Widget::Init(const InitParams& in_params) {
334 InitParams params = in_params;
335 if (ViewsDelegate::views_delegate)
336 ViewsDelegate::views_delegate->OnWidgetInit(&params, this);
Ben Goodger (Google) 2012/12/13 23:47:41 OnBeforeWidgetInit perhaps. OnInit makes it sound
337
343 is_top_level_ = params.top_level || 338 is_top_level_ = params.top_level ||
344 (!params.child && 339 (!params.child &&
345 params.type != InitParams::TYPE_CONTROL && 340 params.type != InitParams::TYPE_CONTROL &&
346 params.type != InitParams::TYPE_TOOLTIP); 341 params.type != InitParams::TYPE_TOOLTIP);
347 widget_delegate_ = params.delegate ? 342 widget_delegate_ = params.delegate ?
348 params.delegate : new DefaultWidgetDelegate(this, params); 343 params.delegate : new DefaultWidgetDelegate(this, params);
349 ownership_ = params.ownership; 344 ownership_ = params.ownership;
350 native_widget_ = CreateNativeWidget( 345 native_widget_ = CreateNativeWidget(params.native_widget, this)->
351 params.native_widget, this, params.type, params.parent, params.context)-> 346 AsNativeWidgetPrivate();
352 AsNativeWidgetPrivate();
353 GetRootView(); 347 GetRootView();
354 default_theme_provider_.reset(new DefaultThemeProvider); 348 default_theme_provider_.reset(new DefaultThemeProvider);
355 if (params.type == InitParams::TYPE_MENU) { 349 if (params.type == InitParams::TYPE_MENU) {
356 is_mouse_button_pressed_ = 350 is_mouse_button_pressed_ =
357 internal::NativeWidgetPrivate::IsMouseButtonDown(); 351 internal::NativeWidgetPrivate::IsMouseButtonDown();
358 } 352 }
359 native_widget_->InitNativeWidget(params); 353 native_widget_->InitNativeWidget(params);
360 if (RequiresNonClientView(params.type)) { 354 if (RequiresNonClientView(params.type)) {
361 non_client_view_ = new NonClientView; 355 non_client_view_ = new NonClientView;
362 non_client_view_->SetFrameView(CreateNonClientFrameView()); 356 non_client_view_->SetFrameView(CreateNonClientFrameView());
(...skipping 1023 matching lines...) Expand 10 before | Expand all | Expand 10 after
1386 1380
1387 //////////////////////////////////////////////////////////////////////////////// 1381 ////////////////////////////////////////////////////////////////////////////////
1388 // internal::NativeWidgetPrivate, NativeWidget implementation: 1382 // internal::NativeWidgetPrivate, NativeWidget implementation:
1389 1383
1390 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { 1384 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() {
1391 return this; 1385 return this;
1392 } 1386 }
1393 1387
1394 } // namespace internal 1388 } // namespace internal
1395 } // namespace views 1389 } // namespace views
OLDNEW
« ui/views/widget/widget.h ('K') | « ui/views/widget/widget.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698