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

Unified Diff: chrome/browser/tab_contents/tab_contents_view_gtk.cc

Issue 132047: GTK: HTTP Auth dialogs under linux. (Closed)
Patch Set: Fix for evanm Created 11 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/tab_contents/tab_contents_view_gtk.cc
diff --git a/chrome/browser/tab_contents/tab_contents_view_gtk.cc b/chrome/browser/tab_contents/tab_contents_view_gtk.cc
index 3443b84549e13b2ee84d007815616bba12ac3237..9b62e55c8f785b65184d1c8d2e74a82e85ce1cbc 100644
--- a/chrome/browser/tab_contents/tab_contents_view_gtk.cc
+++ b/chrome/browser/tab_contents/tab_contents_view_gtk.cc
@@ -15,6 +15,7 @@
#include "chrome/browser/download/download_shelf.h"
#include "chrome/browser/gtk/blocked_popup_container_view_gtk.h"
#include "chrome/browser/gtk/browser_window_gtk.h"
+#include "chrome/browser/gtk/constrained_window_gtk.h"
#include "chrome/browser/gtk/gtk_floating_container.h"
#include "chrome/browser/gtk/sad_tab_gtk.h"
#include "chrome/browser/renderer_host/render_view_host.h"
@@ -139,6 +140,28 @@ void TabContentsViewGtk::RemoveBlockedPopupView(
popup_view_ = NULL;
}
+void TabContentsViewGtk::AttachConstrainedWindow(
+ ConstrainedWindowGtk* constrained_window) {
+ DCHECK(find(constrained_windows_.begin(), constrained_windows_.end(),
+ constrained_window) == constrained_windows_.end());
+
+ constrained_windows_.push_back(constrained_window);
+ gtk_floating_container_add_floating(GTK_FLOATING_CONTAINER(floating_.get()),
+ constrained_window->widget());
+}
+
+void TabContentsViewGtk::RemoveConstrainedWindow(
+ ConstrainedWindowGtk* constrained_window) {
+ std::vector<ConstrainedWindowGtk*>::iterator item =
+ find(constrained_windows_.begin(), constrained_windows_.end(),
+ constrained_window);
+ DCHECK(item != constrained_windows_.end());
+
+ gtk_container_remove(GTK_CONTAINER(floating_.get()),
+ constrained_window->widget());
+ constrained_windows_.erase(item);
+}
+
void TabContentsViewGtk::CreateView() {
// Windows uses this to do initialization, but we do all our initialization
// in the constructor.
@@ -384,4 +407,33 @@ void TabContentsViewGtk::OnSetFloatingPosition(
widget, "y", &value);
g_value_unset(&value);
}
+
+ // Place each ConstrainedWindow in the center of the view.
+ int half_view_width = std::max((allocation->x + allocation->width) / 2, 0);
+ int half_view_height = std::max((allocation->y + allocation->height) / 2, 0);
+ std::vector<ConstrainedWindowGtk*>::iterator it =
+ tab_contents_view->constrained_windows_.begin();
+ std::vector<ConstrainedWindowGtk*>::iterator end =
+ tab_contents_view->constrained_windows_.end();
+ for (; it != end; ++it) {
+ GtkWidget* widget = (*it)->widget();
+ DCHECK(widget->parent == tab_contents_view->floating_.get());
+
+ GtkRequisition requisition;
+ gtk_widget_size_request(widget, &requisition);
+
+ GValue value = { 0, };
+ g_value_init(&value, G_TYPE_INT);
+
+ int child_x = std::max(half_view_width - (requisition.width / 2), 0);
+ g_value_set_int(&value, child_x);
+ gtk_container_child_set_property(GTK_CONTAINER(floating_container),
+ widget, "x", &value);
+
+ int child_y = std::max(half_view_height - (requisition.height / 2), 0);
+ g_value_set_int(&value, child_y);
+ gtk_container_child_set_property(GTK_CONTAINER(floating_container),
+ widget, "y", &value);
+ g_value_unset(&value);
+ }
}

Powered by Google App Engine
This is Rietveld 408576698