summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk/constrained_window_gtk.cc
diff options
context:
space:
mode:
authorerg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-19 22:16:28 +0000
committererg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-19 22:16:28 +0000
commite838217a07f277f8bf751aaaac6fb1005a533d47 (patch)
treef34f7f4522a9eed3a8172751fb1a3202705c16f6 /chrome/browser/gtk/constrained_window_gtk.cc
parente804e052523e23df3881132ab2e31791e0c0d1b6 (diff)
downloadchromium_src-e838217a07f277f8bf751aaaac6fb1005a533d47.zip
chromium_src-e838217a07f277f8bf751aaaac6fb1005a533d47.tar.gz
chromium_src-e838217a07f277f8bf751aaaac6fb1005a533d47.tar.bz2
GTK: HTTP Auth dialogs under linux.
- Implements a ConstrainedWindowGtk which positions itself in the center of its corresponding TabContentsViewGtk. - Implements LoginPromptGtk. HTTP Auth now works under Linux. - Renames ConstrainedWindowImpl to ConstrainedWindowWin http://crbug.com/11512 Review URL: http://codereview.chromium.org/132047 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18864 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk/constrained_window_gtk.cc')
-rw-r--r--chrome/browser/gtk/constrained_window_gtk.cc63
1 files changed, 63 insertions, 0 deletions
diff --git a/chrome/browser/gtk/constrained_window_gtk.cc b/chrome/browser/gtk/constrained_window_gtk.cc
new file mode 100644
index 0000000..21b45b8
--- /dev/null
+++ b/chrome/browser/gtk/constrained_window_gtk.cc
@@ -0,0 +1,63 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/gtk/constrained_window_gtk.h"
+
+#include "chrome/browser/tab_contents/tab_contents.h"
+#include "chrome/browser/tab_contents/tab_contents_view_gtk.h"
+#include "chrome/common/gtk_util.h"
+
+// The minimal border around the edge of the notification.
+const int kSmallPadding = 2;
+
+ConstrainedWindowGtk::ConstrainedWindowGtk(
+ TabContents* owner, ConstrainedWindowGtkDelegate* delegate)
+ : owner_(owner),
+ delegate_(delegate) {
+ DCHECK(owner);
+ DCHECK(delegate);
+ GtkWidget* dialog = delegate->GetWidgetRoot();
+
+ // Unlike other users of CreateBorderBin, we need a dedicated frame around
+ // our "window".
+ GtkWidget* ebox = gtk_event_box_new();
+ GtkWidget* frame = gtk_frame_new(NULL);
+ gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_ETCHED_OUT);
+ GtkWidget* alignment = gtk_alignment_new(0.0, 0.0, 1.0, 1.0);
+ gtk_alignment_set_padding(GTK_ALIGNMENT(alignment),
+ kSmallPadding, kSmallPadding, kSmallPadding, kSmallPadding);
+ gtk_container_add(GTK_CONTAINER(alignment), dialog);
+ gtk_container_add(GTK_CONTAINER(frame), alignment);
+ gtk_container_add(GTK_CONTAINER(ebox), frame);
+ border_.Own(ebox);
+
+ gtk_widget_show_all(border_.get());
+
+ // We collaborate with TabContentsViewGtk and stick ourselves in the
+ // TabContentsViewGtk's floating container.
+ ContainingView()->AttachConstrainedWindow(this);
+}
+
+ConstrainedWindowGtk::~ConstrainedWindowGtk() {
+ border_.Destroy();
+}
+
+void ConstrainedWindowGtk::CloseConstrainedWindow() {
+ ContainingView()->RemoveConstrainedWindow(this);
+ delegate_->DeleteDelegate();
+ owner_->WillClose(this);
+
+ delete this;
+}
+
+TabContentsViewGtk* ConstrainedWindowGtk::ContainingView() {
+ return static_cast<TabContentsViewGtk*>(owner_->view());
+}
+
+// static
+ConstrainedWindow* ConstrainedWindow::CreateConstrainedDialog(
+ TabContents* parent,
+ ConstrainedWindowGtkDelegate* delegate) {
+ return new ConstrainedWindowGtk(parent, delegate);
+}