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/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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 this); | 60 this); |
56 } | 61 } |
57 | 62 |
58 ConstrainedWindowGtk::~ConstrainedWindowGtk() { | 63 ConstrainedWindowGtk::~ConstrainedWindowGtk() { |
59 border_.Destroy(); | 64 border_.Destroy(); |
60 } | 65 } |
61 | 66 |
62 void ConstrainedWindowGtk::ShowConstrainedWindow() { | 67 void ConstrainedWindowGtk::ShowConstrainedWindow() { |
63 gtk_widget_show_all(border_.get()); | 68 gtk_widget_show_all(border_.get()); |
64 | 69 |
65 // We collaborate with TabContentsViewGtk and stick ourselves in the | 70 // We collaborate with TabContentsView and stick ourselves in the |
66 // TabContentsViewGtk's floating container. | 71 // TabContentsView's floating container. |
67 ContainingView()->AttachConstrainedWindow(this); | 72 ContainingView()->AttachConstrainedWindow(this); |
68 | 73 |
69 visible_ = true; | 74 visible_ = true; |
70 } | 75 } |
71 | 76 |
72 void ConstrainedWindowGtk::CloseConstrainedWindow() { | 77 void ConstrainedWindowGtk::CloseConstrainedWindow() { |
73 if (visible_) | 78 if (visible_) |
74 ContainingView()->RemoveConstrainedWindow(this); | 79 ContainingView()->RemoveConstrainedWindow(this); |
75 delegate_->DeleteDelegate(); | 80 delegate_->DeleteDelegate(); |
76 owner_->WillClose(this); | 81 owner_->WillClose(this); |
77 | 82 |
78 delete this; | 83 delete this; |
79 } | 84 } |
80 | 85 |
81 TabContentsViewGtk* ConstrainedWindowGtk::ContainingView() { | 86 TabContentsViewType* ConstrainedWindowGtk::ContainingView() { |
82 return static_cast<TabContentsViewGtk*>(owner_->view()); | 87 return static_cast<TabContentsViewType*>(owner_->view()); |
83 } | 88 } |
84 | 89 |
85 gboolean ConstrainedWindowGtk::OnKeyPress(GtkWidget* sender, | 90 gboolean ConstrainedWindowGtk::OnKeyPress(GtkWidget* sender, |
86 GdkEventKey* key) { | 91 GdkEventKey* key) { |
87 if (key->keyval == GDK_Escape) { | 92 if (key->keyval == GDK_Escape) { |
88 // Let the stack unwind so the event handler can release its ref | 93 // Let the stack unwind so the event handler can release its ref |
89 // on widget(). | 94 // on widget(). |
90 MessageLoop::current()->PostTask(FROM_HERE, | 95 MessageLoop::current()->PostTask(FROM_HERE, |
91 factory_.NewRunnableMethod( | 96 factory_.NewRunnableMethod( |
92 &ConstrainedWindowGtk::CloseConstrainedWindow)); | 97 &ConstrainedWindowGtk::CloseConstrainedWindow)); |
93 return TRUE; | 98 return TRUE; |
94 } | 99 } |
95 | 100 |
96 return FALSE; | 101 return FALSE; |
97 } | 102 } |
98 | 103 |
99 // static | 104 // static |
100 ConstrainedWindow* ConstrainedWindow::CreateConstrainedDialog( | 105 ConstrainedWindow* ConstrainedWindow::CreateConstrainedDialog( |
101 TabContents* parent, | 106 TabContents* parent, |
102 ConstrainedWindowGtkDelegate* delegate) { | 107 ConstrainedWindowGtkDelegate* delegate) { |
103 return new ConstrainedWindowGtk(parent, delegate); | 108 return new ConstrainedWindowGtk(parent, delegate); |
104 } | 109 } |
OLD | NEW |