OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "chrome/browser/gtk/constrained_window_gtk.h" | 5 #include "chrome/browser/gtk/constrained_window_gtk.h" |
6 | 6 |
7 #include <gdk/gdkkeysyms.h> | 7 #include <gdk/gdkkeysyms.h> |
8 | 8 |
9 #include "chrome/browser/browser_list.h" | 9 #include "chrome/browser/browser_list.h" |
10 #include "chrome/browser/gtk/gtk_util.h" | 10 #include "chrome/browser/gtk/gtk_util.h" |
11 #include "chrome/browser/tab_contents/tab_contents.h" | 11 #include "chrome/browser/tab_contents/tab_contents.h" |
| 12 |
| 13 #if defined(TOUCH_UI) |
| 14 #include "chrome/browser/ui/views/tab_contents/tab_contents_view_views.h" |
| 15 #else |
12 #include "chrome/browser/tab_contents/tab_contents_view_gtk.h" | 16 #include "chrome/browser/tab_contents/tab_contents_view_gtk.h" |
| 17 #endif |
13 | 18 |
14 ConstrainedWindowGtkDelegate::~ConstrainedWindowGtkDelegate() { | 19 ConstrainedWindowGtkDelegate::~ConstrainedWindowGtkDelegate() { |
15 } | 20 } |
16 | 21 |
17 bool ConstrainedWindowGtkDelegate::GetBackgroundColor(GdkColor* color) { | 22 bool ConstrainedWindowGtkDelegate::GetBackgroundColor(GdkColor* color) { |
18 return false; | 23 return false; |
19 } | 24 } |
20 | 25 |
21 ConstrainedWindowGtk::ConstrainedWindowGtk( | 26 ConstrainedWindowGtk::ConstrainedWindowGtk( |
22 TabContents* owner, ConstrainedWindowGtkDelegate* delegate) | 27 TabContents* owner, ConstrainedWindowGtkDelegate* delegate) |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 this); | 64 this); |
60 } | 65 } |
61 | 66 |
62 ConstrainedWindowGtk::~ConstrainedWindowGtk() { | 67 ConstrainedWindowGtk::~ConstrainedWindowGtk() { |
63 border_.Destroy(); | 68 border_.Destroy(); |
64 } | 69 } |
65 | 70 |
66 void ConstrainedWindowGtk::ShowConstrainedWindow() { | 71 void ConstrainedWindowGtk::ShowConstrainedWindow() { |
67 gtk_widget_show_all(border_.get()); | 72 gtk_widget_show_all(border_.get()); |
68 | 73 |
69 // We collaborate with TabContentsViewGtk and stick ourselves in the | 74 // We collaborate with TabContentsView and stick ourselves in the |
70 // TabContentsViewGtk's floating container. | 75 // TabContentsView's floating container. |
71 ContainingView()->AttachConstrainedWindow(this); | 76 ContainingView()->AttachConstrainedWindow(this); |
72 | 77 |
73 visible_ = true; | 78 visible_ = true; |
74 } | 79 } |
75 | 80 |
76 void ConstrainedWindowGtk::CloseConstrainedWindow() { | 81 void ConstrainedWindowGtk::CloseConstrainedWindow() { |
77 if (visible_) | 82 if (visible_) |
78 ContainingView()->RemoveConstrainedWindow(this); | 83 ContainingView()->RemoveConstrainedWindow(this); |
79 delegate_->DeleteDelegate(); | 84 delegate_->DeleteDelegate(); |
80 owner_->WillClose(this); | 85 owner_->WillClose(this); |
81 | 86 |
82 delete this; | 87 delete this; |
83 } | 88 } |
84 | 89 |
85 TabContentsViewGtk* ConstrainedWindowGtk::ContainingView() { | 90 ConstrainedWindowGtk::TabContentsViewType* ConstrainedWindowGtk::ContainingView(
) { |
86 return static_cast<TabContentsViewGtk*>(owner_->view()); | 91 return static_cast<TabContentsViewType*>(owner_->view()); |
87 } | 92 } |
88 | 93 |
89 gboolean ConstrainedWindowGtk::OnKeyPress(GtkWidget* sender, | 94 gboolean ConstrainedWindowGtk::OnKeyPress(GtkWidget* sender, |
90 GdkEventKey* key) { | 95 GdkEventKey* key) { |
91 if (key->keyval == GDK_Escape) { | 96 if (key->keyval == GDK_Escape) { |
92 // Let the stack unwind so the event handler can release its ref | 97 // Let the stack unwind so the event handler can release its ref |
93 // on widget(). | 98 // on widget(). |
94 MessageLoop::current()->PostTask(FROM_HERE, | 99 MessageLoop::current()->PostTask(FROM_HERE, |
95 factory_.NewRunnableMethod( | 100 factory_.NewRunnableMethod( |
96 &ConstrainedWindowGtk::CloseConstrainedWindow)); | 101 &ConstrainedWindowGtk::CloseConstrainedWindow)); |
97 return TRUE; | 102 return TRUE; |
98 } | 103 } |
99 | 104 |
100 return FALSE; | 105 return FALSE; |
101 } | 106 } |
102 | 107 |
103 // static | 108 // static |
104 ConstrainedWindow* ConstrainedWindow::CreateConstrainedDialog( | 109 ConstrainedWindow* ConstrainedWindow::CreateConstrainedDialog( |
105 TabContents* parent, | 110 TabContents* parent, |
106 ConstrainedWindowGtkDelegate* delegate) { | 111 ConstrainedWindowGtkDelegate* delegate) { |
107 return new ConstrainedWindowGtk(parent, delegate); | 112 return new ConstrainedWindowGtk(parent, delegate); |
108 } | 113 } |
OLD | NEW |