OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/ui/gtk/constrained_window_gtk.h" | 5 #include "chrome/browser/ui/gtk/constrained_window_gtk.h" |
6 | 6 |
7 #include <gdk/gdkkeysyms.h> | 7 #include <gdk/gdkkeysyms.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 ConstrainedWindowTabHelper* helper = | 119 ConstrainedWindowTabHelper* helper = |
120 wrapper_->constrained_window_tab_helper(); | 120 wrapper_->constrained_window_tab_helper(); |
121 if ((!helper->delegate() || | 121 if ((!helper->delegate() || |
122 helper->delegate()->ShouldFocusConstrainedWindow()) && | 122 helper->delegate()->ShouldFocusConstrainedWindow()) && |
123 gtk_util::IsWidgetAncestryVisible(focus_widget)) { | 123 gtk_util::IsWidgetAncestryVisible(focus_widget)) { |
124 gtk_widget_grab_focus(focus_widget); | 124 gtk_widget_grab_focus(focus_widget); |
125 } else { | 125 } else { |
126 // TODO(estade): this define should not need to be here because this class | 126 // TODO(estade): this define should not need to be here because this class |
127 // should not be used on linux/views. | 127 // should not be used on linux/views. |
128 #if defined(TOOLKIT_GTK) | 128 #if defined(TOOLKIT_GTK) |
129 static_cast<TabContentsViewGtk*>(wrapper_->view())-> | 129 static_cast<TabContentsViewGtk*>(wrapper_->tab_contents()->view())-> |
130 SetFocusedWidget(focus_widget); | 130 SetFocusedWidget(focus_widget); |
131 #endif | 131 #endif |
132 } | 132 } |
133 } | 133 } |
134 | 134 |
135 ConstrainedWindowGtk::TabContentsViewType* | 135 ConstrainedWindowGtk::TabContentsViewType* |
136 ConstrainedWindowGtk::ContainingView() { | 136 ConstrainedWindowGtk::ContainingView() { |
137 #if defined(TOOLKIT_VIEWS) | 137 #if defined(TOOLKIT_VIEWS) |
138 return static_cast<NativeTabContentsViewGtk*>( | 138 return static_cast<NativeTabContentsViewGtk*>( |
139 static_cast<TabContentsViewViews*>(wrapper_->view())-> | 139 static_cast<TabContentsViewViews*>(wrapper_->tab_contents()->view())-> |
140 native_tab_contents_view()); | 140 native_tab_contents_view()); |
141 #else | 141 #else |
142 return static_cast<TabContentsViewType*>( | 142 return static_cast<TabContentsViewType*>( |
143 static_cast<TabContentsViewGtk*>(wrapper_->view())-> | 143 static_cast<TabContentsViewGtk*>(wrapper_->tab_contents()->view())-> |
144 wrapper()); | 144 wrapper()); |
145 #endif | 145 #endif |
146 } | 146 } |
147 | 147 |
148 gboolean ConstrainedWindowGtk::OnKeyPress(GtkWidget* sender, | 148 gboolean ConstrainedWindowGtk::OnKeyPress(GtkWidget* sender, |
149 GdkEventKey* key) { | 149 GdkEventKey* key) { |
150 if (key->keyval == GDK_Escape) { | 150 if (key->keyval == GDK_Escape) { |
151 // Let the stack unwind so the event handler can release its ref | 151 // Let the stack unwind so the event handler can release its ref |
152 // on widget(). | 152 // on widget(). |
153 MessageLoop::current()->PostTask( | 153 MessageLoop::current()->PostTask( |
154 FROM_HERE, | 154 FROM_HERE, |
155 base::Bind(&ConstrainedWindowGtk::CloseConstrainedWindow, | 155 base::Bind(&ConstrainedWindowGtk::CloseConstrainedWindow, |
156 weak_factory_.GetWeakPtr())); | 156 weak_factory_.GetWeakPtr())); |
157 return TRUE; | 157 return TRUE; |
158 } | 158 } |
159 | 159 |
160 return FALSE; | 160 return FALSE; |
161 } | 161 } |
162 | 162 |
163 void ConstrainedWindowGtk::OnHierarchyChanged(GtkWidget* sender, | 163 void ConstrainedWindowGtk::OnHierarchyChanged(GtkWidget* sender, |
164 GtkWidget* previous_toplevel) { | 164 GtkWidget* previous_toplevel) { |
165 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 165 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
166 if (!gtk_widget_is_toplevel(gtk_widget_get_toplevel(widget()))) | 166 if (!gtk_widget_is_toplevel(gtk_widget_get_toplevel(widget()))) |
167 return; | 167 return; |
168 | 168 |
169 FocusConstrainedWindow(); | 169 FocusConstrainedWindow(); |
170 } | 170 } |
OLD | NEW |