OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/ui/gtk/extensions/web_auth_flow_window_gtk.h" | |
6 | |
7 #include "content/public/browser/web_contents.h" | |
8 #include "content/public/browser/web_contents_view.h" | |
9 #include "ui/gfx/native_widget_types.h" | |
10 | |
11 using content::BrowserContext; | |
12 using content::WebContents; | |
13 | |
14 WebAuthFlowWindowGtk::WebAuthFlowWindowGtk( | |
15 Delegate* delegate, | |
16 BrowserContext* browser_context, | |
17 WebContents* contents) | |
18 : WebAuthFlowWindow(delegate, browser_context, contents), | |
19 window_(NULL) { | |
20 } | |
21 | |
22 void WebAuthFlowWindowGtk::Show() { | |
23 window_ = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL)); | |
24 gfx::NativeView native_view = contents()->GetView()->GetNativeView(); | |
25 gtk_container_add(GTK_CONTAINER(window_), native_view); | |
26 gtk_window_set_default_size(window_, kDefaultWidth, kDefaultHeight); | |
27 | |
28 g_signal_connect(window_, "delete-event", | |
29 G_CALLBACK(OnMainWindowDeleteEventThunk), this); | |
30 | |
31 gtk_window_present(window_); | |
32 } | |
33 | |
34 WebAuthFlowWindowGtk::~WebAuthFlowWindowGtk() { | |
35 if (window_) | |
36 gtk_widget_destroy(GTK_WIDGET(window_)); | |
37 } | |
38 | |
39 // Callback for the delete event. This event is fired when the user tries to | |
40 // close the window (e.g., clicking on the X in the window manager title bar). | |
41 gboolean WebAuthFlowWindowGtk::OnMainWindowDeleteEvent( | |
42 GtkWidget* widget, GdkEvent* event) { | |
43 if (delegate()) | |
44 delegate()->OnClose(); | |
45 | |
46 // Return FALSE to tell the caller to delete the window. | |
47 return FALSE; | |
48 } | |
49 | |
50 // static | |
51 WebAuthFlowWindow* WebAuthFlowWindow::Create( | |
52 Delegate* delegate, | |
53 BrowserContext* browser_context, | |
54 WebContents* contents) { | |
55 return new WebAuthFlowWindowGtk(delegate, browser_context, contents); | |
56 } | |
OLD | NEW |