Correct blacklist entry message
[chromium-blink-merge.git] / ui / views / widget / widget.cc
blobd3af615e107fdafb18ae9b27ac723d52f739e9ce
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 #include "ui/views/widget/widget.h"
7 #include "base/debug/trace_event.h"
8 #include "base/logging.h"
9 #include "base/message_loop/message_loop.h"
10 #include "base/strings/utf_string_conversions.h"
11 #include "ui/base/default_theme_provider.h"
12 #include "ui/base/hit_test.h"
13 #include "ui/base/l10n/l10n_font_util.h"
14 #include "ui/base/resource/resource_bundle.h"
15 #include "ui/compositor/compositor.h"
16 #include "ui/compositor/layer.h"
17 #include "ui/events/event.h"
18 #include "ui/gfx/screen.h"
19 #include "ui/views/controls/menu/menu_controller.h"
20 #include "ui/views/focus/focus_manager.h"
21 #include "ui/views/focus/focus_manager_factory.h"
22 #include "ui/views/focus/view_storage.h"
23 #include "ui/views/focus/widget_focus_manager.h"
24 #include "ui/views/ime/input_method.h"
25 #include "ui/views/views_delegate.h"
26 #include "ui/views/widget/native_widget_private.h"
27 #include "ui/views/widget/root_view.h"
28 #include "ui/views/widget/tooltip_manager.h"
29 #include "ui/views/widget/widget_delegate.h"
30 #include "ui/views/widget/widget_deletion_observer.h"
31 #include "ui/views/widget/widget_observer.h"
32 #include "ui/views/window/custom_frame_view.h"
33 #include "ui/views/window/dialog_delegate.h"
35 #if defined(USE_AURA)
36 #include "ui/base/cursor/cursor.h"
37 #endif
39 namespace views {
41 namespace {
43 // If |view| has a layer the layer is added to |layers|. Else this recurses
44 // through the children. This is used to build a list of the layers created by
45 // views that are direct children of the Widgets layer.
46 void BuildRootLayers(View* view, std::vector<ui::Layer*>* layers) {
47 if (view->layer()) {
48 layers->push_back(view->layer());
49 } else {
50 for (int i = 0; i < view->child_count(); ++i)
51 BuildRootLayers(view->child_at(i), layers);
55 // Create a native widget implementation.
56 // First, use the supplied one if non-NULL.
57 // Finally, make a default one.
58 NativeWidget* CreateNativeWidget(NativeWidget* native_widget,
59 internal::NativeWidgetDelegate* delegate) {
60 if (!native_widget) {
61 native_widget =
62 internal::NativeWidgetPrivate::CreateNativeWidget(delegate);
64 return native_widget;
67 } // namespace
69 // A default implementation of WidgetDelegate, used by Widget when no
70 // WidgetDelegate is supplied.
71 class DefaultWidgetDelegate : public WidgetDelegate {
72 public:
73 DefaultWidgetDelegate(Widget* widget, const Widget::InitParams& params)
74 : widget_(widget),
75 can_activate_(!params.child &&
76 params.type != Widget::InitParams::TYPE_POPUP) {
78 virtual ~DefaultWidgetDelegate() {}
80 // Overridden from WidgetDelegate:
81 virtual void DeleteDelegate() OVERRIDE {
82 delete this;
84 virtual Widget* GetWidget() OVERRIDE {
85 return widget_;
87 virtual const Widget* GetWidget() const OVERRIDE {
88 return widget_;
90 virtual bool CanActivate() const OVERRIDE {
91 return can_activate_;
93 virtual bool ShouldAdvanceFocusToTopLevelWidget() const OVERRIDE {
94 // In most situations where a Widget is used without a delegate the Widget
95 // is used as a container, so that we want focus to advance to the top-level
96 // widget. A good example of this is the find bar.
97 return true;
100 private:
101 Widget* widget_;
102 bool can_activate_;
104 DISALLOW_COPY_AND_ASSIGN(DefaultWidgetDelegate);
107 ////////////////////////////////////////////////////////////////////////////////
108 // Widget, InitParams:
110 Widget::InitParams::InitParams()
111 : type(TYPE_WINDOW),
112 delegate(NULL),
113 child(false),
114 opacity((ViewsDelegate::views_delegate &&
115 ViewsDelegate::views_delegate->UseTransparentWindows()) ?
116 TRANSLUCENT_WINDOW : INFER_OPACITY),
117 accept_events(true),
118 can_activate(true),
119 keep_on_top(false),
120 ownership(NATIVE_WIDGET_OWNS_WIDGET),
121 mirror_origin_in_rtl(false),
122 has_dropshadow(false),
123 remove_standard_frame(false),
124 use_system_default_icon(false),
125 show_state(ui::SHOW_STATE_DEFAULT),
126 double_buffer(false),
127 parent(NULL),
128 native_widget(NULL),
129 desktop_root_window_host(NULL),
130 top_level(false),
131 layer_type(ui::LAYER_TEXTURED),
132 context(NULL) {
135 Widget::InitParams::InitParams(Type type)
136 : type(type),
137 delegate(NULL),
138 child(type == TYPE_CONTROL),
139 opacity(((type == TYPE_WINDOW || type == TYPE_PANEL) &&
140 ViewsDelegate::views_delegate &&
141 ViewsDelegate::views_delegate->UseTransparentWindows()) ?
142 TRANSLUCENT_WINDOW : INFER_OPACITY),
143 accept_events(true),
144 can_activate(type != TYPE_POPUP && type != TYPE_MENU),
145 keep_on_top(type == TYPE_MENU),
146 ownership(NATIVE_WIDGET_OWNS_WIDGET),
147 mirror_origin_in_rtl(false),
148 has_dropshadow(false),
149 remove_standard_frame(false),
150 use_system_default_icon(false),
151 show_state(ui::SHOW_STATE_DEFAULT),
152 double_buffer(false),
153 parent(NULL),
154 native_widget(NULL),
155 desktop_root_window_host(NULL),
156 top_level(false),
157 layer_type(ui::LAYER_TEXTURED),
158 context(NULL) {
161 ////////////////////////////////////////////////////////////////////////////////
162 // Widget, public:
164 Widget::Widget()
165 : native_widget_(NULL),
166 widget_delegate_(NULL),
167 non_client_view_(NULL),
168 dragged_view_(NULL),
169 ownership_(InitParams::NATIVE_WIDGET_OWNS_WIDGET),
170 is_secondary_widget_(true),
171 frame_type_(FRAME_TYPE_DEFAULT),
172 disable_inactive_rendering_(false),
173 widget_closed_(false),
174 saved_show_state_(ui::SHOW_STATE_DEFAULT),
175 focus_on_creation_(true),
176 is_top_level_(false),
177 native_widget_initialized_(false),
178 native_widget_destroyed_(false),
179 is_mouse_button_pressed_(false),
180 is_touch_down_(false),
181 last_mouse_event_was_move_(false),
182 auto_release_capture_(true),
183 root_layers_dirty_(false),
184 movement_disabled_(false) {
187 Widget::~Widget() {
188 DestroyRootView();
189 if (ownership_ == InitParams::WIDGET_OWNS_NATIVE_WIDGET) {
190 delete native_widget_;
191 } else {
192 DCHECK(native_widget_destroyed_)
193 << "Destroying a widget with a live native widget. "
194 << "Widget probably should use WIDGET_OWNS_NATIVE_WIDGET ownership.";
198 // static
199 Widget* Widget::CreateWindow(WidgetDelegate* delegate) {
200 return CreateWindowWithBounds(delegate, gfx::Rect());
203 // static
204 Widget* Widget::CreateWindowWithBounds(WidgetDelegate* delegate,
205 const gfx::Rect& bounds) {
206 Widget* widget = new Widget;
207 Widget::InitParams params;
208 params.bounds = bounds;
209 params.delegate = delegate;
210 params.top_level = true;
211 widget->Init(params);
212 return widget;
215 // static
216 Widget* Widget::CreateWindowWithParent(WidgetDelegate* delegate,
217 gfx::NativeWindow parent) {
218 return CreateWindowWithParentAndBounds(delegate, parent, gfx::Rect());
221 // static
222 Widget* Widget::CreateWindowWithParentAndBounds(WidgetDelegate* delegate,
223 gfx::NativeWindow parent,
224 const gfx::Rect& bounds) {
225 Widget* widget = new Widget;
226 Widget::InitParams params;
227 params.delegate = delegate;
228 params.parent = parent;
229 params.bounds = bounds;
230 widget->Init(params);
231 return widget;
234 // static
235 Widget* Widget::CreateWindowWithContext(WidgetDelegate* delegate,
236 gfx::NativeView context) {
237 return CreateWindowWithContextAndBounds(delegate, context, gfx::Rect());
240 // static
241 Widget* Widget::CreateWindowWithContextAndBounds(WidgetDelegate* delegate,
242 gfx::NativeView context,
243 const gfx::Rect& bounds) {
244 Widget* widget = new Widget;
245 Widget::InitParams params;
246 params.delegate = delegate;
247 params.context = context;
248 params.bounds = bounds;
249 widget->Init(params);
250 return widget;
253 // static
254 Widget* Widget::CreateWindowAsFramelessChild(WidgetDelegate* widget_delegate,
255 gfx::NativeView parent,
256 gfx::NativeView new_style_parent) {
257 views::Widget* widget = new views::Widget;
259 views::Widget::InitParams params;
260 params.delegate = widget_delegate;
261 params.child = true;
262 if (views::DialogDelegate::UseNewStyle()) {
263 params.parent = new_style_parent;
264 params.remove_standard_frame = true;
265 #if defined(USE_AURA)
266 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
267 #endif
268 } else {
269 params.parent = parent;
272 widget->Init(params);
274 return widget;
277 // static
278 Widget* Widget::GetWidgetForNativeView(gfx::NativeView native_view) {
279 internal::NativeWidgetPrivate* native_widget =
280 internal::NativeWidgetPrivate::GetNativeWidgetForNativeView(native_view);
281 return native_widget ? native_widget->GetWidget() : NULL;
284 // static
285 Widget* Widget::GetWidgetForNativeWindow(gfx::NativeWindow native_window) {
286 internal::NativeWidgetPrivate* native_widget =
287 internal::NativeWidgetPrivate::GetNativeWidgetForNativeWindow(
288 native_window);
289 return native_widget ? native_widget->GetWidget() : NULL;
292 // static
293 Widget* Widget::GetTopLevelWidgetForNativeView(gfx::NativeView native_view) {
294 internal::NativeWidgetPrivate* native_widget =
295 internal::NativeWidgetPrivate::GetTopLevelNativeWidget(native_view);
296 return native_widget ? native_widget->GetWidget() : NULL;
300 // static
301 void Widget::GetAllChildWidgets(gfx::NativeView native_view,
302 Widgets* children) {
303 internal::NativeWidgetPrivate::GetAllChildWidgets(native_view, children);
306 // static
307 void Widget::GetAllOwnedWidgets(gfx::NativeView native_view,
308 Widgets* owned) {
309 internal::NativeWidgetPrivate::GetAllOwnedWidgets(native_view, owned);
312 // static
313 void Widget::ReparentNativeView(gfx::NativeView native_view,
314 gfx::NativeView new_parent) {
315 internal::NativeWidgetPrivate::ReparentNativeView(native_view, new_parent);
318 // static
319 int Widget::GetLocalizedContentsWidth(int col_resource_id) {
320 return ui::GetLocalizedContentsWidthForFont(col_resource_id,
321 ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::BaseFont));
324 // static
325 int Widget::GetLocalizedContentsHeight(int row_resource_id) {
326 return ui::GetLocalizedContentsHeightForFont(row_resource_id,
327 ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::BaseFont));
330 // static
331 gfx::Size Widget::GetLocalizedContentsSize(int col_resource_id,
332 int row_resource_id) {
333 return gfx::Size(GetLocalizedContentsWidth(col_resource_id),
334 GetLocalizedContentsHeight(row_resource_id));
337 // static
338 bool Widget::RequiresNonClientView(InitParams::Type type) {
339 return type == InitParams::TYPE_WINDOW ||
340 type == InitParams::TYPE_PANEL ||
341 type == InitParams::TYPE_BUBBLE;
344 void Widget::Init(const InitParams& in_params) {
345 TRACE_EVENT0("views", "Widget::Init");
346 InitParams params = in_params;
348 is_top_level_ = params.top_level ||
349 (!params.child &&
350 params.type != InitParams::TYPE_CONTROL &&
351 params.type != InitParams::TYPE_TOOLTIP);
352 params.top_level = is_top_level_;
353 if (params.opacity == InitParams::INFER_OPACITY) {
354 #if defined(OS_WIN) && defined(USE_AURA)
355 // By default, make all top-level windows but the main window transparent
356 // initially so that they can be made to fade in.
357 if (is_top_level_ && params.type != InitParams::TYPE_WINDOW)
358 params.opacity = InitParams::TRANSLUCENT_WINDOW;
359 else
360 params.opacity = InitParams::OPAQUE_WINDOW;
361 #else
362 params.opacity = InitParams::OPAQUE_WINDOW;
363 #endif
366 if (ViewsDelegate::views_delegate)
367 ViewsDelegate::views_delegate->OnBeforeWidgetInit(&params, this);
369 widget_delegate_ = params.delegate ?
370 params.delegate : new DefaultWidgetDelegate(this, params);
371 ownership_ = params.ownership;
372 native_widget_ = CreateNativeWidget(params.native_widget, this)->
373 AsNativeWidgetPrivate();
374 root_view_.reset(CreateRootView());
375 default_theme_provider_.reset(new ui::DefaultThemeProvider);
376 if (params.type == InitParams::TYPE_MENU) {
377 is_mouse_button_pressed_ =
378 internal::NativeWidgetPrivate::IsMouseButtonDown();
380 native_widget_->InitNativeWidget(params);
381 if (RequiresNonClientView(params.type)) {
382 non_client_view_ = new NonClientView;
383 non_client_view_->SetFrameView(CreateNonClientFrameView());
384 // Create the ClientView, add it to the NonClientView and add the
385 // NonClientView to the RootView. This will cause everything to be parented.
386 non_client_view_->set_client_view(widget_delegate_->CreateClientView(this));
387 non_client_view_->SetOverlayView(widget_delegate_->CreateOverlayView());
388 SetContentsView(non_client_view_);
389 // Initialize the window's title before setting the window's initial bounds;
390 // the frame view's preferred height may depend on the presence of a title.
391 UpdateWindowTitle();
392 SetInitialBounds(params.bounds);
393 if (params.show_state == ui::SHOW_STATE_MAXIMIZED)
394 Maximize();
395 else if (params.show_state == ui::SHOW_STATE_MINIMIZED)
396 Minimize();
397 } else if (params.delegate) {
398 SetContentsView(params.delegate->GetContentsView());
399 SetInitialBoundsForFramelessWindow(params.bounds);
401 native_widget_initialized_ = true;
404 // Unconverted methods (see header) --------------------------------------------
406 gfx::NativeView Widget::GetNativeView() const {
407 return native_widget_->GetNativeView();
410 gfx::NativeWindow Widget::GetNativeWindow() const {
411 return native_widget_->GetNativeWindow();
414 void Widget::AddObserver(WidgetObserver* observer) {
415 observers_.AddObserver(observer);
418 void Widget::RemoveObserver(WidgetObserver* observer) {
419 observers_.RemoveObserver(observer);
422 bool Widget::HasObserver(WidgetObserver* observer) {
423 return observers_.HasObserver(observer);
426 bool Widget::GetAccelerator(int cmd_id, ui::Accelerator* accelerator) {
427 return false;
430 void Widget::ViewHierarchyChanged(
431 const View::ViewHierarchyChangedDetails& details) {
432 if (!details.is_add) {
433 if (details.child == dragged_view_)
434 dragged_view_ = NULL;
435 FocusManager* focus_manager = GetFocusManager();
436 if (focus_manager)
437 focus_manager->ViewRemoved(details.child);
438 ViewStorage::GetInstance()->ViewRemoved(details.child);
439 native_widget_->ViewRemoved(details.child);
443 void Widget::NotifyNativeViewHierarchyWillChange() {
444 FocusManager* focus_manager = GetFocusManager();
445 // We are being removed from a window hierarchy. Treat this as
446 // the root_view_ being removed.
447 if (focus_manager)
448 focus_manager->ViewRemoved(root_view_.get());
451 void Widget::NotifyNativeViewHierarchyChanged() {
452 root_view_->NotifyNativeViewHierarchyChanged();
455 // Converted methods (see header) ----------------------------------------------
457 Widget* Widget::GetTopLevelWidget() {
458 return const_cast<Widget*>(
459 static_cast<const Widget*>(this)->GetTopLevelWidget());
462 const Widget* Widget::GetTopLevelWidget() const {
463 // GetTopLevelNativeWidget doesn't work during destruction because
464 // property is gone after gobject gets deleted. Short circuit here
465 // for toplevel so that InputMethod can remove itself from
466 // focus manager.
467 return is_top_level() ? this : native_widget_->GetTopLevelWidget();
470 void Widget::SetContentsView(View* view) {
471 // Do not SetContentsView() again if it is already set to the same view.
472 if (view == GetContentsView())
473 return;
474 root_view_->SetContentsView(view);
475 if (non_client_view_ != view) {
476 // |non_client_view_| can only be non-NULL here if RequiresNonClientView()
477 // was true when the widget was initialized. Creating widgets with non
478 // client views and then setting the contents view can cause subtle
479 // problems on Windows, where the native widget thinks there is still a
480 // |non_client_view_|. If you get this error, either use a different type
481 // when initializing the widget, or don't call SetContentsView().
482 DCHECK(!non_client_view_);
483 non_client_view_ = NULL;
487 View* Widget::GetContentsView() {
488 return root_view_->GetContentsView();
491 gfx::Rect Widget::GetWindowBoundsInScreen() const {
492 return native_widget_->GetWindowBoundsInScreen();
495 gfx::Rect Widget::GetClientAreaBoundsInScreen() const {
496 return native_widget_->GetClientAreaBoundsInScreen();
499 gfx::Rect Widget::GetRestoredBounds() const {
500 return native_widget_->GetRestoredBounds();
503 void Widget::SetBounds(const gfx::Rect& bounds) {
504 native_widget_->SetBounds(bounds);
507 void Widget::SetSize(const gfx::Size& size) {
508 native_widget_->SetSize(size);
511 void Widget::CenterWindow(const gfx::Size& size) {
512 native_widget_->CenterWindow(size);
515 void Widget::SetBoundsConstrained(const gfx::Rect& bounds) {
516 gfx::Rect work_area =
517 gfx::Screen::GetScreenFor(GetNativeView())->GetDisplayNearestPoint(
518 bounds.origin()).work_area();
519 if (work_area.IsEmpty()) {
520 SetBounds(bounds);
521 } else {
522 // Inset the work area slightly.
523 work_area.Inset(10, 10, 10, 10);
524 work_area.AdjustToFit(bounds);
525 SetBounds(work_area);
529 void Widget::SetVisibilityChangedAnimationsEnabled(bool value) {
530 native_widget_->SetVisibilityChangedAnimationsEnabled(value);
533 Widget::MoveLoopResult Widget::RunMoveLoop(
534 const gfx::Vector2d& drag_offset,
535 MoveLoopSource source,
536 MoveLoopEscapeBehavior escape_behavior) {
537 return native_widget_->RunMoveLoop(drag_offset, source, escape_behavior);
540 void Widget::EndMoveLoop() {
541 native_widget_->EndMoveLoop();
544 void Widget::StackAboveWidget(Widget* widget) {
545 native_widget_->StackAbove(widget->GetNativeView());
548 void Widget::StackAbove(gfx::NativeView native_view) {
549 native_widget_->StackAbove(native_view);
552 void Widget::StackAtTop() {
553 native_widget_->StackAtTop();
556 void Widget::StackBelow(gfx::NativeView native_view) {
557 native_widget_->StackBelow(native_view);
560 void Widget::SetShape(gfx::NativeRegion shape) {
561 native_widget_->SetShape(shape);
564 void Widget::Close() {
565 if (widget_closed_) {
566 // It appears we can hit this code path if you close a modal dialog then
567 // close the last browser before the destructor is hit, which triggers
568 // invoking Close again.
569 return;
572 bool can_close = true;
573 if (non_client_view_)
574 can_close = non_client_view_->CanClose();
575 if (can_close) {
576 SaveWindowPlacement();
578 // During tear-down the top-level focus manager becomes unavailable to
579 // GTK tabbed panes and their children, so normal deregistration via
580 // |FormManager::ViewRemoved()| calls are fouled. We clear focus here
581 // to avoid these redundant steps and to avoid accessing deleted views
582 // that may have been in focus.
583 if (is_top_level() && focus_manager_.get())
584 focus_manager_->SetFocusedView(NULL);
586 FOR_EACH_OBSERVER(WidgetObserver, observers_, OnWidgetClosing(this));
587 native_widget_->Close();
588 widget_closed_ = true;
592 void Widget::CloseNow() {
593 FOR_EACH_OBSERVER(WidgetObserver, observers_, OnWidgetClosing(this));
594 native_widget_->CloseNow();
597 bool Widget::IsClosed() const {
598 return widget_closed_;
601 void Widget::Show() {
602 TRACE_EVENT0("views", "Widget::Show");
603 if (non_client_view_) {
604 // While initializing, the kiosk mode will go to full screen before the
605 // widget gets shown. In that case we stay in full screen mode, regardless
606 // of the |saved_show_state_| member.
607 if (saved_show_state_ == ui::SHOW_STATE_MAXIMIZED &&
608 !initial_restored_bounds_.IsEmpty() &&
609 !IsFullscreen()) {
610 native_widget_->ShowMaximizedWithBounds(initial_restored_bounds_);
611 } else {
612 native_widget_->ShowWithWindowState(
613 IsFullscreen() ? ui::SHOW_STATE_FULLSCREEN : saved_show_state_);
615 // |saved_show_state_| only applies the first time the window is shown.
616 // If we don't reset the value the window may be shown maximized every time
617 // it is subsequently shown after being hidden.
618 saved_show_state_ = ui::SHOW_STATE_NORMAL;
619 } else {
620 native_widget_->Show();
624 void Widget::Hide() {
625 native_widget_->Hide();
628 void Widget::ShowInactive() {
629 // If this gets called with saved_show_state_ == ui::SHOW_STATE_MAXIMIZED,
630 // call SetBounds()with the restored bounds to set the correct size. This
631 // normally should not happen, but if it does we should avoid showing unsized
632 // windows.
633 if (saved_show_state_ == ui::SHOW_STATE_MAXIMIZED &&
634 !initial_restored_bounds_.IsEmpty()) {
635 SetBounds(initial_restored_bounds_);
636 saved_show_state_ = ui::SHOW_STATE_NORMAL;
638 native_widget_->ShowWithWindowState(ui::SHOW_STATE_INACTIVE);
641 void Widget::Activate() {
642 native_widget_->Activate();
645 void Widget::Deactivate() {
646 native_widget_->Deactivate();
649 bool Widget::IsActive() const {
650 return native_widget_->IsActive();
653 void Widget::DisableInactiveRendering() {
654 SetInactiveRenderingDisabled(true);
657 void Widget::SetAlwaysOnTop(bool on_top) {
658 native_widget_->SetAlwaysOnTop(on_top);
661 bool Widget::IsAlwaysOnTop() const {
662 return native_widget_->IsAlwaysOnTop();
665 void Widget::Maximize() {
666 native_widget_->Maximize();
669 void Widget::Minimize() {
670 native_widget_->Minimize();
673 void Widget::Restore() {
674 native_widget_->Restore();
677 bool Widget::IsMaximized() const {
678 return native_widget_->IsMaximized();
681 bool Widget::IsMinimized() const {
682 return native_widget_->IsMinimized();
685 void Widget::SetFullscreen(bool fullscreen) {
686 native_widget_->SetFullscreen(fullscreen);
689 bool Widget::IsFullscreen() const {
690 return native_widget_->IsFullscreen();
693 void Widget::SetOpacity(unsigned char opacity) {
694 native_widget_->SetOpacity(opacity);
697 void Widget::SetUseDragFrame(bool use_drag_frame) {
698 native_widget_->SetUseDragFrame(use_drag_frame);
701 void Widget::FlashFrame(bool flash) {
702 native_widget_->FlashFrame(flash);
705 View* Widget::GetRootView() {
706 return root_view_.get();
709 const View* Widget::GetRootView() const {
710 return root_view_.get();
713 bool Widget::IsVisible() const {
714 return native_widget_->IsVisible();
717 ui::ThemeProvider* Widget::GetThemeProvider() const {
718 const Widget* root_widget = GetTopLevelWidget();
719 if (root_widget && root_widget != this) {
720 // Attempt to get the theme provider, and fall back to the default theme
721 // provider if not found.
722 ui::ThemeProvider* provider = root_widget->GetThemeProvider();
723 if (provider)
724 return provider;
726 provider = root_widget->default_theme_provider_.get();
727 if (provider)
728 return provider;
730 return default_theme_provider_.get();
733 const ui::NativeTheme* Widget::GetNativeTheme() const {
734 return native_widget_->GetNativeTheme();
737 FocusManager* Widget::GetFocusManager() {
738 Widget* toplevel_widget = GetTopLevelWidget();
739 return toplevel_widget ? toplevel_widget->focus_manager_.get() : NULL;
742 const FocusManager* Widget::GetFocusManager() const {
743 const Widget* toplevel_widget = GetTopLevelWidget();
744 return toplevel_widget ? toplevel_widget->focus_manager_.get() : NULL;
747 InputMethod* Widget::GetInputMethod() {
748 return const_cast<InputMethod*>(
749 const_cast<const Widget*>(this)->GetInputMethod());
752 const InputMethod* Widget::GetInputMethod() const {
753 if (is_top_level()) {
754 if (!input_method_.get())
755 input_method_ = const_cast<Widget*>(this)->CreateInputMethod().Pass();
756 return input_method_.get();
757 } else {
758 const Widget* toplevel = GetTopLevelWidget();
759 // If GetTopLevelWidget() returns itself which is not toplevel,
760 // the widget is detached from toplevel widget.
761 // TODO(oshima): Fix GetTopLevelWidget() to return NULL
762 // if there is no toplevel. We probably need to add GetTopMostWidget()
763 // to replace some use cases.
764 return (toplevel && toplevel != this) ? toplevel->GetInputMethod() : NULL;
768 void Widget::RunShellDrag(View* view,
769 const ui::OSExchangeData& data,
770 const gfx::Point& location,
771 int operation,
772 ui::DragDropTypes::DragEventSource source) {
773 dragged_view_ = view;
774 native_widget_->RunShellDrag(view, data, location, operation, source);
775 // If the view is removed during the drag operation, dragged_view_ is set to
776 // NULL.
777 if (view && dragged_view_ == view) {
778 dragged_view_ = NULL;
779 view->OnDragDone();
783 void Widget::SchedulePaintInRect(const gfx::Rect& rect) {
784 native_widget_->SchedulePaintInRect(rect);
787 void Widget::SetCursor(gfx::NativeCursor cursor) {
788 native_widget_->SetCursor(cursor);
791 bool Widget::IsMouseEventsEnabled() const {
792 return native_widget_->IsMouseEventsEnabled();
795 void Widget::SetNativeWindowProperty(const char* name, void* value) {
796 native_widget_->SetNativeWindowProperty(name, value);
799 void* Widget::GetNativeWindowProperty(const char* name) const {
800 return native_widget_->GetNativeWindowProperty(name);
803 void Widget::UpdateWindowTitle() {
804 if (!non_client_view_)
805 return;
807 // Update the native frame's text. We do this regardless of whether or not
808 // the native frame is being used, since this also updates the taskbar, etc.
809 string16 window_title = widget_delegate_->GetWindowTitle();
810 base::i18n::AdjustStringForLocaleDirection(&window_title);
811 native_widget_->SetWindowTitle(window_title);
812 non_client_view_->UpdateWindowTitle();
814 // If the non-client view is rendering its own title, it'll need to relayout
815 // now and to get a paint update later on.
816 non_client_view_->Layout();
819 void Widget::UpdateWindowIcon() {
820 if (non_client_view_)
821 non_client_view_->UpdateWindowIcon();
822 native_widget_->SetWindowIcons(widget_delegate_->GetWindowIcon(),
823 widget_delegate_->GetWindowAppIcon());
826 FocusTraversable* Widget::GetFocusTraversable() {
827 return static_cast<internal::RootView*>(root_view_.get());
830 void Widget::ThemeChanged() {
831 root_view_->ThemeChanged();
834 void Widget::LocaleChanged() {
835 root_view_->LocaleChanged();
838 void Widget::SetFocusTraversableParent(FocusTraversable* parent) {
839 root_view_->SetFocusTraversableParent(parent);
842 void Widget::SetFocusTraversableParentView(View* parent_view) {
843 root_view_->SetFocusTraversableParentView(parent_view);
846 void Widget::ClearNativeFocus() {
847 native_widget_->ClearNativeFocus();
850 NonClientFrameView* Widget::CreateNonClientFrameView() {
851 NonClientFrameView* frame_view =
852 widget_delegate_->CreateNonClientFrameView(this);
853 if (!frame_view)
854 frame_view = native_widget_->CreateNonClientFrameView();
855 if (!frame_view && ViewsDelegate::views_delegate) {
856 frame_view =
857 ViewsDelegate::views_delegate->CreateDefaultNonClientFrameView(this);
859 if (frame_view)
860 return frame_view;
862 CustomFrameView* custom_frame_view = new CustomFrameView;
863 custom_frame_view->Init(this);
864 return custom_frame_view;
867 bool Widget::ShouldUseNativeFrame() const {
868 if (frame_type_ != FRAME_TYPE_DEFAULT)
869 return frame_type_ == FRAME_TYPE_FORCE_NATIVE;
870 return native_widget_->ShouldUseNativeFrame();
873 void Widget::DebugToggleFrameType() {
874 if (frame_type_ == FRAME_TYPE_DEFAULT) {
875 frame_type_ = ShouldUseNativeFrame() ? FRAME_TYPE_FORCE_CUSTOM :
876 FRAME_TYPE_FORCE_NATIVE;
877 } else {
878 frame_type_ = frame_type_ == FRAME_TYPE_FORCE_CUSTOM ?
879 FRAME_TYPE_FORCE_NATIVE : FRAME_TYPE_FORCE_CUSTOM;
881 FrameTypeChanged();
884 void Widget::FrameTypeChanged() {
885 native_widget_->FrameTypeChanged();
888 const ui::Compositor* Widget::GetCompositor() const {
889 return native_widget_->GetCompositor();
892 ui::Compositor* Widget::GetCompositor() {
893 return native_widget_->GetCompositor();
896 ui::Layer* Widget::GetLayer() {
897 return native_widget_->GetLayer();
900 void Widget::ReorderNativeViews() {
901 native_widget_->ReorderNativeViews();
904 void Widget::UpdateRootLayers() {
905 // Calculate the layers requires traversing the tree, and since nearly any
906 // mutation of the tree can trigger this call we delay until absolutely
907 // necessary.
908 root_layers_dirty_ = true;
911 const NativeWidget* Widget::native_widget() const {
912 return native_widget_;
915 NativeWidget* Widget::native_widget() {
916 return native_widget_;
919 void Widget::SetCapture(View* view) {
920 if (internal::NativeWidgetPrivate::IsMouseButtonDown())
921 is_mouse_button_pressed_ = true;
922 if (internal::NativeWidgetPrivate::IsTouchDown())
923 is_touch_down_ = true;
924 root_view_->SetMouseHandler(view);
925 if (!native_widget_->HasCapture())
926 native_widget_->SetCapture();
929 void Widget::ReleaseCapture() {
930 if (native_widget_->HasCapture())
931 native_widget_->ReleaseCapture();
934 bool Widget::HasCapture() {
935 return native_widget_->HasCapture();
938 TooltipManager* Widget::GetTooltipManager() {
939 return native_widget_->GetTooltipManager();
942 const TooltipManager* Widget::GetTooltipManager() const {
943 return native_widget_->GetTooltipManager();
946 bool Widget::SetInitialFocus() {
947 View* v = widget_delegate_->GetInitiallyFocusedView();
948 if (!focus_on_creation_) {
949 // If not focusing the window now, tell the focus manager which view to
950 // focus when the window is restored.
951 if (v)
952 focus_manager_->SetStoredFocusView(v);
953 return true;
955 if (v)
956 v->RequestFocus();
957 return !!v;
960 gfx::Rect Widget::GetWorkAreaBoundsInScreen() const {
961 return native_widget_->GetWorkAreaBoundsInScreen();
964 void Widget::SynthesizeMouseMoveEvent() {
965 last_mouse_event_was_move_ = false;
966 ui::MouseEvent mouse_event(ui::ET_MOUSE_MOVED,
967 last_mouse_event_position_,
968 last_mouse_event_position_,
969 ui::EF_IS_SYNTHESIZED);
970 root_view_->OnMouseMoved(mouse_event);
973 void Widget::OnRootViewLayout() {
974 native_widget_->OnRootViewLayout();
977 void Widget::OnOwnerClosing() {
980 ////////////////////////////////////////////////////////////////////////////////
981 // Widget, NativeWidgetDelegate implementation:
983 bool Widget::IsModal() const {
984 return widget_delegate_->GetModalType() != ui::MODAL_TYPE_NONE;
987 bool Widget::IsDialogBox() const {
988 return !!widget_delegate_->AsDialogDelegate();
991 bool Widget::CanActivate() const {
992 return widget_delegate_->CanActivate();
995 bool Widget::IsInactiveRenderingDisabled() const {
996 return disable_inactive_rendering_;
999 void Widget::EnableInactiveRendering() {
1000 SetInactiveRenderingDisabled(false);
1003 void Widget::OnNativeWidgetActivationChanged(bool active) {
1004 // On windows we may end up here before we've completed initialization (from
1005 // an WM_NCACTIVATE). If that happens the WidgetDelegate likely doesn't know
1006 // the Widget and will crash attempting to access it.
1007 if (!active && native_widget_initialized_)
1008 SaveWindowPlacement();
1010 FOR_EACH_OBSERVER(WidgetObserver, observers_,
1011 OnWidgetActivationChanged(this, active));
1014 void Widget::OnNativeFocus(gfx::NativeView old_focused_view) {
1015 WidgetFocusManager::GetInstance()->OnWidgetFocusEvent(old_focused_view,
1016 GetNativeView());
1019 void Widget::OnNativeBlur(gfx::NativeView new_focused_view) {
1020 WidgetFocusManager::GetInstance()->OnWidgetFocusEvent(GetNativeView(),
1021 new_focused_view);
1024 void Widget::OnNativeWidgetVisibilityChanging(bool visible) {
1025 FOR_EACH_OBSERVER(WidgetObserver, observers_,
1026 OnWidgetVisibilityChanging(this, visible));
1029 void Widget::OnNativeWidgetVisibilityChanged(bool visible) {
1030 View* root = GetRootView();
1031 if (root)
1032 root->PropagateVisibilityNotifications(root, visible);
1033 FOR_EACH_OBSERVER(WidgetObserver, observers_,
1034 OnWidgetVisibilityChanged(this, visible));
1035 if (GetCompositor() && root && root->layer())
1036 root->layer()->SetVisible(visible);
1039 void Widget::OnNativeWidgetCreated(bool desktop_widget) {
1040 if (is_top_level())
1041 focus_manager_.reset(FocusManagerFactory::Create(this, desktop_widget));
1043 native_widget_->InitModalType(widget_delegate_->GetModalType());
1045 FOR_EACH_OBSERVER(WidgetObserver, observers_, OnWidgetCreated(this));
1048 void Widget::OnNativeWidgetDestroying() {
1049 // Tell the focus manager (if any) that root_view is being removed
1050 // in case that the focused view is under this root view.
1051 if (GetFocusManager())
1052 GetFocusManager()->ViewRemoved(root_view_.get());
1053 FOR_EACH_OBSERVER(WidgetObserver, observers_, OnWidgetDestroying(this));
1054 if (non_client_view_)
1055 non_client_view_->WindowClosing();
1056 widget_delegate_->WindowClosing();
1059 void Widget::OnNativeWidgetDestroyed() {
1060 FOR_EACH_OBSERVER(WidgetObserver, observers_, OnWidgetDestroyed(this));
1061 widget_delegate_->DeleteDelegate();
1062 widget_delegate_ = NULL;
1063 native_widget_destroyed_ = true;
1066 gfx::Size Widget::GetMinimumSize() {
1067 return non_client_view_ ? non_client_view_->GetMinimumSize() : gfx::Size();
1070 gfx::Size Widget::GetMaximumSize() {
1071 return non_client_view_ ? non_client_view_->GetMaximumSize() : gfx::Size();
1074 void Widget::OnNativeWidgetMove() {
1075 widget_delegate_->OnWidgetMove();
1076 FOR_EACH_OBSERVER(WidgetObserver, observers_, OnWidgetBoundsChanged(
1077 this,
1078 GetWindowBoundsInScreen()));
1081 void Widget::OnNativeWidgetSizeChanged(const gfx::Size& new_size) {
1082 root_view_->SetSize(new_size);
1084 // Size changed notifications can fire prior to full initialization
1085 // i.e. during session restore. Avoid saving session state during these
1086 // startup procedures.
1087 if (native_widget_initialized_)
1088 SaveWindowPlacement();
1090 FOR_EACH_OBSERVER(WidgetObserver, observers_, OnWidgetBoundsChanged(
1091 this,
1092 GetWindowBoundsInScreen()));
1095 void Widget::OnNativeWidgetBeginUserBoundsChange() {
1096 widget_delegate_->OnWindowBeginUserBoundsChange();
1099 void Widget::OnNativeWidgetEndUserBoundsChange() {
1100 widget_delegate_->OnWindowEndUserBoundsChange();
1103 bool Widget::HasFocusManager() const {
1104 return !!focus_manager_.get();
1107 bool Widget::OnNativeWidgetPaintAccelerated(const gfx::Rect& dirty_region) {
1108 ui::Compositor* compositor = GetCompositor();
1109 if (!compositor)
1110 return false;
1112 compositor->ScheduleRedrawRect(dirty_region);
1113 return true;
1116 void Widget::OnNativeWidgetPaint(gfx::Canvas* canvas) {
1117 // On Linux Aura, we can get here during Init() because of the
1118 // SetInitialBounds call.
1119 if (native_widget_initialized_)
1120 GetRootView()->Paint(canvas);
1123 int Widget::GetNonClientComponent(const gfx::Point& point) {
1124 int component = non_client_view_ ?
1125 non_client_view_->NonClientHitTest(point) :
1126 HTNOWHERE;
1128 if (movement_disabled_ && (component == HTCAPTION || component == HTSYSMENU))
1129 return HTNOWHERE;
1131 return component;
1134 void Widget::OnKeyEvent(ui::KeyEvent* event) {
1135 static_cast<internal::RootView*>(GetRootView())->
1136 DispatchKeyEvent(event);
1139 void Widget::OnMouseEvent(ui::MouseEvent* event) {
1140 View* root_view = GetRootView();
1141 switch (event->type()) {
1142 case ui::ET_MOUSE_PRESSED: {
1143 last_mouse_event_was_move_ = false;
1145 // We may get deleted by the time we return from OnMousePressed. So we
1146 // use an observer to make sure we are still alive.
1147 WidgetDeletionObserver widget_deletion_observer(this);
1149 // Make sure we're still visible before we attempt capture as the mouse
1150 // press processing may have made the window hide (as happens with menus).
1152 // It is possible for a View to show a context menu on mouse-press. Since
1153 // the menu does a capture and starts a nested message-loop, the release
1154 // would go to the menu. The next click (i.e. both mouse-press and release
1155 // events) also go to the menu. The menu (and the nested message-loop)
1156 // gets closed after this second release event. The code then resumes from
1157 // here. So make sure that the mouse-button is still down before doing a
1158 // capture.
1159 if (root_view && root_view->OnMousePressed(*event) &&
1160 widget_deletion_observer.IsWidgetAlive() && IsVisible() &&
1161 internal::NativeWidgetPrivate::IsMouseButtonDown()) {
1162 is_mouse_button_pressed_ = true;
1163 if (!native_widget_->HasCapture())
1164 native_widget_->SetCapture();
1165 event->SetHandled();
1167 return;
1169 case ui::ET_MOUSE_RELEASED:
1170 last_mouse_event_was_move_ = false;
1171 is_mouse_button_pressed_ = false;
1172 // Release capture first, to avoid confusion if OnMouseReleased blocks.
1173 if (auto_release_capture_ && native_widget_->HasCapture())
1174 native_widget_->ReleaseCapture();
1175 if (root_view)
1176 root_view->OnMouseReleased(*event);
1177 if ((event->flags() & ui::EF_IS_NON_CLIENT) == 0)
1178 event->SetHandled();
1179 return;
1180 case ui::ET_MOUSE_MOVED:
1181 case ui::ET_MOUSE_DRAGGED:
1182 if (native_widget_->HasCapture() && is_mouse_button_pressed_) {
1183 last_mouse_event_was_move_ = false;
1184 if (root_view)
1185 root_view->OnMouseDragged(*event);
1186 } else if (!last_mouse_event_was_move_ ||
1187 last_mouse_event_position_ != event->location()) {
1188 last_mouse_event_position_ = event->location();
1189 last_mouse_event_was_move_ = true;
1190 if (root_view)
1191 root_view->OnMouseMoved(*event);
1193 return;
1194 case ui::ET_MOUSE_EXITED:
1195 last_mouse_event_was_move_ = false;
1196 if (root_view)
1197 root_view->OnMouseExited(*event);
1198 return;
1199 case ui::ET_MOUSEWHEEL:
1200 if (root_view && root_view->OnMouseWheel(
1201 static_cast<const ui::MouseWheelEvent&>(*event)))
1202 event->SetHandled();
1203 return;
1204 default:
1205 return;
1207 event->SetHandled();
1210 void Widget::OnMouseCaptureLost() {
1211 if (is_mouse_button_pressed_ || is_touch_down_) {
1212 View* root_view = GetRootView();
1213 if (root_view)
1214 root_view->OnMouseCaptureLost();
1216 is_touch_down_ = false;
1217 is_mouse_button_pressed_ = false;
1220 void Widget::OnTouchEvent(ui::TouchEvent* event) {
1221 static_cast<internal::RootView*>(GetRootView())->
1222 DispatchTouchEvent(event);
1225 void Widget::OnScrollEvent(ui::ScrollEvent* event) {
1226 static_cast<internal::RootView*>(GetRootView())->
1227 DispatchScrollEvent(event);
1230 void Widget::OnGestureEvent(ui::GestureEvent* event) {
1231 switch (event->type()) {
1232 case ui::ET_GESTURE_TAP_DOWN:
1233 is_touch_down_ = true;
1234 // We explicitly don't capture here. Not capturing enables multiple
1235 // widgets to get tap events at the same time. Views (such as tab
1236 // dragging) may explicitly capture.
1237 break;
1239 case ui::ET_GESTURE_END:
1240 if (event->details().touch_points() == 1) {
1241 is_touch_down_ = false;
1242 if (auto_release_capture_)
1243 ReleaseCapture();
1245 break;
1247 default:
1248 break;
1250 static_cast<internal::RootView*>(GetRootView())->DispatchGestureEvent(event);
1253 bool Widget::ExecuteCommand(int command_id) {
1254 return widget_delegate_->ExecuteWindowsCommand(command_id);
1257 InputMethod* Widget::GetInputMethodDirect() {
1258 return input_method_.get();
1261 const std::vector<ui::Layer*>& Widget::GetRootLayers() {
1262 if (root_layers_dirty_) {
1263 root_layers_dirty_ = false;
1264 root_layers_.clear();
1265 BuildRootLayers(GetRootView(), &root_layers_);
1267 return root_layers_;
1270 bool Widget::HasHitTestMask() const {
1271 return widget_delegate_->WidgetHasHitTestMask();
1274 void Widget::GetHitTestMask(gfx::Path* mask) const {
1275 DCHECK(mask);
1276 widget_delegate_->GetWidgetHitTestMask(mask);
1279 Widget* Widget::AsWidget() {
1280 return this;
1283 const Widget* Widget::AsWidget() const {
1284 return this;
1287 ////////////////////////////////////////////////////////////////////////////////
1288 // Widget, FocusTraversable implementation:
1290 FocusSearch* Widget::GetFocusSearch() {
1291 return root_view_->GetFocusSearch();
1294 FocusTraversable* Widget::GetFocusTraversableParent() {
1295 // We are a proxy to the root view, so we should be bypassed when traversing
1296 // up and as a result this should not be called.
1297 NOTREACHED();
1298 return NULL;
1301 View* Widget::GetFocusTraversableParentView() {
1302 // We are a proxy to the root view, so we should be bypassed when traversing
1303 // up and as a result this should not be called.
1304 NOTREACHED();
1305 return NULL;
1308 ////////////////////////////////////////////////////////////////////////////////
1309 // Widget, protected:
1311 internal::RootView* Widget::CreateRootView() {
1312 return new internal::RootView(this);
1315 void Widget::DestroyRootView() {
1316 non_client_view_ = NULL;
1317 root_view_.reset();
1318 // Input method has to be destroyed before focus manager.
1319 input_method_.reset();
1322 ////////////////////////////////////////////////////////////////////////////////
1323 // Widget, private:
1325 void Widget::SetInactiveRenderingDisabled(bool value) {
1326 if (value == disable_inactive_rendering_)
1327 return;
1329 disable_inactive_rendering_ = value;
1330 if (non_client_view_)
1331 non_client_view_->SetInactiveRenderingDisabled(value);
1334 void Widget::SaveWindowPlacement() {
1335 // The window delegate does the actual saving for us. It seems like (judging
1336 // by go/crash) that in some circumstances we can end up here after
1337 // WM_DESTROY, at which point the window delegate is likely gone. So just
1338 // bail.
1339 if (!widget_delegate_)
1340 return;
1342 ui::WindowShowState show_state = ui::SHOW_STATE_NORMAL;
1343 gfx::Rect bounds;
1344 native_widget_->GetWindowPlacement(&bounds, &show_state);
1345 widget_delegate_->SaveWindowPlacement(bounds, show_state);
1348 void Widget::SetInitialBounds(const gfx::Rect& bounds) {
1349 if (!non_client_view_)
1350 return;
1352 gfx::Rect saved_bounds;
1353 if (GetSavedWindowPlacement(&saved_bounds, &saved_show_state_)) {
1354 if (saved_show_state_ == ui::SHOW_STATE_MAXIMIZED) {
1355 // If we're going to maximize, wait until Show is invoked to set the
1356 // bounds. That way we avoid a noticeable resize.
1357 initial_restored_bounds_ = saved_bounds;
1358 } else if (!saved_bounds.IsEmpty()) {
1359 // If the saved bounds are valid, use them.
1360 SetBounds(saved_bounds);
1362 } else {
1363 if (bounds.IsEmpty()) {
1364 // No initial bounds supplied, so size the window to its content and
1365 // center over its parent.
1366 native_widget_->CenterWindow(non_client_view_->GetPreferredSize());
1367 } else {
1368 // Use the supplied initial bounds.
1369 SetBoundsConstrained(bounds);
1374 void Widget::SetInitialBoundsForFramelessWindow(const gfx::Rect& bounds) {
1375 if (bounds.IsEmpty()) {
1376 View* contents_view = GetContentsView();
1377 DCHECK(contents_view);
1378 // No initial bounds supplied, so size the window to its content and
1379 // center over its parent if preferred size is provided.
1380 gfx::Size size = contents_view->GetPreferredSize();
1381 if (!size.IsEmpty())
1382 native_widget_->CenterWindow(size);
1383 } else {
1384 // Use the supplied initial bounds.
1385 SetBoundsConstrained(bounds);
1389 bool Widget::GetSavedWindowPlacement(gfx::Rect* bounds,
1390 ui::WindowShowState* show_state) {
1391 // First we obtain the window's saved show-style and store it. We need to do
1392 // this here, rather than in Show() because by the time Show() is called,
1393 // the window's size will have been reset (below) and the saved maximized
1394 // state will have been lost. Sadly there's no way to tell on Windows when
1395 // a window is restored from maximized state, so we can't more accurately
1396 // track maximized state independently of sizing information.
1398 // Restore the window's placement from the controller.
1399 if (widget_delegate_->GetSavedWindowPlacement(this, bounds, show_state)) {
1400 if (!widget_delegate_->ShouldRestoreWindowSize()) {
1401 bounds->set_size(non_client_view_->GetPreferredSize());
1402 } else {
1403 gfx::Size minimum_size = GetMinimumSize();
1404 // Make sure the bounds are at least the minimum size.
1405 if (bounds->width() < minimum_size.width())
1406 bounds->set_width(minimum_size.width());
1408 if (bounds->height() < minimum_size.height())
1409 bounds->set_height(minimum_size.height());
1411 return true;
1413 return false;
1416 scoped_ptr<InputMethod> Widget::CreateInputMethod() {
1417 scoped_ptr<InputMethod> input_method(native_widget_->CreateInputMethod());
1418 if (input_method.get())
1419 input_method->Init(this);
1420 return input_method.Pass();
1423 void Widget::ReplaceInputMethod(InputMethod* input_method) {
1424 input_method_.reset(input_method);
1425 input_method->SetDelegate(native_widget_->GetInputMethodDelegate());
1426 input_method->Init(this);
1429 namespace internal {
1431 ////////////////////////////////////////////////////////////////////////////////
1432 // internal::NativeWidgetPrivate, NativeWidget implementation:
1434 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() {
1435 return this;
1438 } // namespace internal
1439 } // namespace views