Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(605)

Side by Side Diff: chrome/browser/ui/gtk/constrained_window_gtk.cc

Issue 11633052: Rename platform-independent ConstrainedWindow types to WebContentsModalDialog types (part 2) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: use gtk_widget_get_toplevel for GetNativeWindow Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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"
11 #include "chrome/browser/ui/browser_list.h" 11 #include "chrome/browser/ui/browser_list.h"
12 #include "chrome/browser/ui/constrained_window_tab_helper.h"
13 #include "chrome/browser/ui/constrained_window_tab_helper_delegate.h"
14 #include "chrome/browser/ui/gtk/gtk_util.h" 12 #include "chrome/browser/ui/gtk/gtk_util.h"
15 #include "chrome/browser/ui/gtk/tab_contents/chrome_web_contents_view_delegate_g tk.h" 13 #include "chrome/browser/ui/gtk/tab_contents/chrome_web_contents_view_delegate_g tk.h"
14 #include "chrome/browser/ui/web_contents_modal_dialog_manager.h"
15 #include "chrome/browser/ui/web_contents_modal_dialog_manager_delegate.h"
16 #include "content/public/browser/browser_thread.h" 16 #include "content/public/browser/browser_thread.h"
17 #include "content/public/browser/web_contents.h" 17 #include "content/public/browser/web_contents.h"
18 #include "ui/base/gtk/focus_store_gtk.h" 18 #include "ui/base/gtk/focus_store_gtk.h"
19 #include "ui/base/gtk/gtk_compat.h" 19 #include "ui/base/gtk/gtk_compat.h"
20 #include "ui/base/gtk/gtk_hig_constants.h" 20 #include "ui/base/gtk/gtk_hig_constants.h"
21 21
22 using content::BrowserThread; 22 using content::BrowserThread;
23 23
24 ConstrainedWindowGtkDelegate::~ConstrainedWindowGtkDelegate() { 24 ConstrainedWindowGtkDelegate::~ConstrainedWindowGtkDelegate() {
25 } 25 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 border_.Own(ebox); 66 border_.Own(ebox);
67 67
68 BackgroundColorChanged(); 68 BackgroundColorChanged();
69 69
70 gtk_widget_add_events(widget(), GDK_KEY_PRESS_MASK); 70 gtk_widget_add_events(widget(), GDK_KEY_PRESS_MASK);
71 g_signal_connect(widget(), "key-press-event", G_CALLBACK(OnKeyPressThunk), 71 g_signal_connect(widget(), "key-press-event", G_CALLBACK(OnKeyPressThunk),
72 this); 72 this);
73 g_signal_connect(widget(), "hierarchy-changed", 73 g_signal_connect(widget(), "hierarchy-changed",
74 G_CALLBACK(OnHierarchyChangedThunk), this); 74 G_CALLBACK(OnHierarchyChangedThunk), this);
75 75
76 ConstrainedWindowTabHelper* constrained_window_tab_helper = 76 WebContentsModalDialogManager* web_contents_modal_dialog_manager =
77 ConstrainedWindowTabHelper::FromWebContents(web_contents_); 77 WebContentsModalDialogManager::FromWebContents(web_contents_);
78 constrained_window_tab_helper->AddDialog(this); 78 web_contents_modal_dialog_manager->AddDialog(this);
79 } 79 }
80 80
81 ConstrainedWindowGtk::~ConstrainedWindowGtk() { 81 ConstrainedWindowGtk::~ConstrainedWindowGtk() {
82 border_.Destroy(); 82 border_.Destroy();
83 } 83 }
84 84
85 void ConstrainedWindowGtk::ShowWebContentsModalDialog() { 85 void ConstrainedWindowGtk::ShowWebContentsModalDialog() {
86 gtk_widget_show_all(border_.get()); 86 gtk_widget_show_all(border_.get());
87 87
88 // We collaborate with WebContentsView and stick ourselves in the 88 // We collaborate with WebContentsView and stick ourselves in the
89 // WebContentsView's floating container. 89 // WebContentsView's floating container.
90 ContainingView()->AttachConstrainedWindow(this); 90 ContainingView()->AttachConstrainedWindow(this);
91 91
92 visible_ = true; 92 visible_ = true;
93 } 93 }
94 94
95 void ConstrainedWindowGtk::CloseWebContentsModalDialog() { 95 void ConstrainedWindowGtk::CloseWebContentsModalDialog() {
96 if (visible_) 96 if (visible_)
97 ContainingView()->RemoveConstrainedWindow(this); 97 ContainingView()->RemoveConstrainedWindow(this);
98 delegate_->DeleteDelegate(); 98 delegate_->DeleteDelegate();
99 ConstrainedWindowTabHelper* constrained_window_tab_helper = 99 WebContentsModalDialogManager* web_contents_modal_dialog_manager =
100 ConstrainedWindowTabHelper::FromWebContents(web_contents_); 100 WebContentsModalDialogManager::FromWebContents(web_contents_);
101 constrained_window_tab_helper->WillClose(this); 101 web_contents_modal_dialog_manager->WillClose(this);
102 102
103 delete this; 103 delete this;
104 } 104 }
105 105
106 void ConstrainedWindowGtk::FocusWebContentsModalDialog() { 106 void ConstrainedWindowGtk::FocusWebContentsModalDialog() {
107 GtkWidget* focus_widget = delegate_->GetFocusWidget(); 107 GtkWidget* focus_widget = delegate_->GetFocusWidget();
108 if (!focus_widget) 108 if (!focus_widget)
109 return; 109 return;
110 110
111 // The user may have focused another tab. In this case do not grab focus 111 // The user may have focused another tab. In this case do not grab focus
112 // until this tab is refocused. 112 // until this tab is refocused.
113 ConstrainedWindowTabHelper* helper = 113 WebContentsModalDialogManager* manager =
114 ConstrainedWindowTabHelper::FromWebContents(web_contents_); 114 WebContentsModalDialogManager::FromWebContents(web_contents_);
115 if ((!helper->delegate() || 115 if ((!manager->delegate() ||
116 helper->delegate()->ShouldFocusConstrainedWindow()) && 116 manager->delegate()->ShouldFocusWebContentsModalDialog()) &&
117 gtk_util::IsWidgetAncestryVisible(focus_widget)) { 117 gtk_util::IsWidgetAncestryVisible(focus_widget)) {
118 gtk_widget_grab_focus(focus_widget); 118 gtk_widget_grab_focus(focus_widget);
119 } else { 119 } else {
120 ContainingView()->focus_store()->SetWidget(focus_widget); 120 ContainingView()->focus_store()->SetWidget(focus_widget);
121 } 121 }
122 } 122 }
123 123
124 void ConstrainedWindowGtk::PulseWebContentsModalDialog() {
125 }
126
127 bool ConstrainedWindowGtk::CanShowWebContentsModalDialog() {
128 return true;
129 }
130
131 gfx::NativeWindow ConstrainedWindowGtk::GetNativeWindow() {
132 return GTK_WINDOW(gtk_widget_get_toplevel(widget()));
133 }
134
124 void ConstrainedWindowGtk::BackgroundColorChanged() { 135 void ConstrainedWindowGtk::BackgroundColorChanged() {
125 GdkColor background; 136 GdkColor background;
126 if (delegate_->GetBackgroundColor(&background)) { 137 if (delegate_->GetBackgroundColor(&background)) {
127 gtk_widget_modify_base(border_.get(), GTK_STATE_NORMAL, &background); 138 gtk_widget_modify_base(border_.get(), GTK_STATE_NORMAL, &background);
128 gtk_widget_modify_fg(border_.get(), GTK_STATE_NORMAL, &background); 139 gtk_widget_modify_fg(border_.get(), GTK_STATE_NORMAL, &background);
129 gtk_widget_modify_bg(border_.get(), GTK_STATE_NORMAL, &background); 140 gtk_widget_modify_bg(border_.get(), GTK_STATE_NORMAL, &background);
130 } 141 }
131 } 142 }
132 143
133 ConstrainedWindowGtk::TabContentsViewType* 144 ConstrainedWindowGtk::TabContentsViewType*
(...skipping 17 matching lines...) Expand all
151 } 162 }
152 163
153 void ConstrainedWindowGtk::OnHierarchyChanged(GtkWidget* sender, 164 void ConstrainedWindowGtk::OnHierarchyChanged(GtkWidget* sender,
154 GtkWidget* previous_toplevel) { 165 GtkWidget* previous_toplevel) {
155 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 166 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
156 if (!gtk_widget_is_toplevel(gtk_widget_get_toplevel(widget()))) 167 if (!gtk_widget_is_toplevel(gtk_widget_get_toplevel(widget())))
157 return; 168 return;
158 169
159 FocusWebContentsModalDialog(); 170 FocusWebContentsModalDialog();
160 } 171 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/constrained_window_gtk.h ('k') | chrome/browser/ui/gtk/ssl_client_certificate_selector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698