OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 <gtk/gtk.h> | 5 #include <gtk/gtk.h> |
6 | 6 |
7 #include "views/focus/focus_manager.h" | 7 #include "views/focus/focus_manager.h" |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "views/widget/widget_gtk.h" | 10 #include "views/widget/widget_gtk.h" |
11 | 11 |
12 namespace views { | 12 namespace views { |
13 | 13 |
14 void FocusManager::ClearNativeFocus() { | 14 void FocusManager::ClearNativeFocus() { |
15 gtk_widget_grab_focus(widget_->GetNativeView()); | 15 gtk_widget_grab_focus(widget_->GetNativeView()); |
16 } | 16 } |
17 | 17 |
18 void FocusManager::FocusNativeView(gfx::NativeView native_view) { | 18 void FocusManager::FocusNativeView(gfx::NativeView native_view) { |
19 if (native_view && !gtk_widget_is_focus(native_view)) | 19 if (native_view && !gtk_widget_is_focus(native_view)) |
20 gtk_widget_grab_focus(native_view); | 20 gtk_widget_grab_focus(native_view); |
21 } | 21 } |
22 | 22 |
23 // static | 23 // static |
24 FocusManager* FocusManager::GetFocusManagerForNativeView( | 24 FocusManager* FocusManager::GetFocusManagerForNativeView( |
25 gfx::NativeView native_view) { | 25 gfx::NativeView native_view) { |
26 GtkWidget* root = gtk_widget_get_toplevel(native_view); | 26 GtkWidget* root = gtk_widget_get_toplevel(native_view); |
27 if (!root || !GTK_WIDGET_TOPLEVEL(root)) | 27 if (!root || !GTK_WIDGET_TOPLEVEL(root)) |
28 return NULL; | 28 return NULL; |
29 | 29 |
30 WidgetGtk* widget = WidgetGtk::GetViewForNative(root); | 30 WidgetGtk* widget = WidgetGtk::GetViewForNative(root); |
31 if (!widget) { | 31 if (!widget) { |
32 NOTREACHED(); | 32 // TODO(jcampan): http://crbug.com/21378 Reenable this NOTREACHED() when the |
| 33 // options page is only based on views. |
| 34 // NOTREACHED(); |
33 return NULL; | 35 return NULL; |
34 } | 36 } |
35 FocusManager* focus_manager = widget->GetFocusManager(); | 37 FocusManager* focus_manager = widget->GetFocusManager(); |
36 DCHECK(focus_manager) << "no FocusManager for top level Widget"; | 38 DCHECK(focus_manager) << "no FocusManager for top level Widget"; |
37 return focus_manager; | 39 return focus_manager; |
38 } | 40 } |
39 | 41 |
40 } // namespace views | 42 } // namespace views |
OLD | NEW |