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

Side by Side 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 unified diff | Download patch
OLDNEW
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/tab_contents/tab_contents_view_gtk.h" 5 #include "chrome/browser/tab_contents/tab_contents_view_gtk.h"
6 6
7 #include <gdk/gdk.h> 7 #include <gdk/gdk.h>
8 #include <gtk/gtk.h> 8 #include <gtk/gtk.h>
9 9
10 #include "base/string_util.h" 10 #include "base/string_util.h"
11 #include "base/gfx/point.h" 11 #include "base/gfx/point.h"
12 #include "base/gfx/rect.h" 12 #include "base/gfx/rect.h"
13 #include "base/gfx/size.h" 13 #include "base/gfx/size.h"
14 #include "build/build_config.h" 14 #include "build/build_config.h"
15 #include "chrome/browser/download/download_shelf.h" 15 #include "chrome/browser/download/download_shelf.h"
16 #include "chrome/browser/gtk/blocked_popup_container_view_gtk.h" 16 #include "chrome/browser/gtk/blocked_popup_container_view_gtk.h"
17 #include "chrome/browser/gtk/browser_window_gtk.h" 17 #include "chrome/browser/gtk/browser_window_gtk.h"
18 #include "chrome/browser/gtk/constrained_window_gtk.h"
18 #include "chrome/browser/gtk/gtk_floating_container.h" 19 #include "chrome/browser/gtk/gtk_floating_container.h"
19 #include "chrome/browser/gtk/sad_tab_gtk.h" 20 #include "chrome/browser/gtk/sad_tab_gtk.h"
20 #include "chrome/browser/renderer_host/render_view_host.h" 21 #include "chrome/browser/renderer_host/render_view_host.h"
21 #include "chrome/browser/renderer_host/render_view_host_factory.h" 22 #include "chrome/browser/renderer_host/render_view_host_factory.h"
22 #include "chrome/browser/renderer_host/render_widget_host_view_gtk.h" 23 #include "chrome/browser/renderer_host/render_widget_host_view_gtk.h"
23 #include "chrome/browser/tab_contents/interstitial_page.h" 24 #include "chrome/browser/tab_contents/interstitial_page.h"
24 #include "chrome/browser/tab_contents/render_view_context_menu_gtk.h" 25 #include "chrome/browser/tab_contents/render_view_context_menu_gtk.h"
25 #include "chrome/browser/tab_contents/tab_contents.h" 26 #include "chrome/browser/tab_contents/tab_contents.h"
26 #include "chrome/browser/tab_contents/tab_contents_delegate.h" 27 #include "chrome/browser/tab_contents/tab_contents_delegate.h"
27 #include "chrome/common/gtk_util.h" 28 #include "chrome/common/gtk_util.h"
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 popup_view->widget()); 133 popup_view->widget());
133 } 134 }
134 135
135 void TabContentsViewGtk::RemoveBlockedPopupView( 136 void TabContentsViewGtk::RemoveBlockedPopupView(
136 BlockedPopupContainerViewGtk* popup_view) { 137 BlockedPopupContainerViewGtk* popup_view) {
137 DCHECK(popup_view_ == popup_view); 138 DCHECK(popup_view_ == popup_view);
138 gtk_container_remove(GTK_CONTAINER(floating_.get()), popup_view->widget()); 139 gtk_container_remove(GTK_CONTAINER(floating_.get()), popup_view->widget());
139 popup_view_ = NULL; 140 popup_view_ = NULL;
140 } 141 }
141 142
143 void TabContentsViewGtk::AttachConstrainedWindow(
144 ConstrainedWindowGtk* constrained_window) {
145 DCHECK(find(constrained_windows_.begin(), constrained_windows_.end(),
146 constrained_window) == constrained_windows_.end());
147
148 constrained_windows_.push_back(constrained_window);
149 gtk_floating_container_add_floating(GTK_FLOATING_CONTAINER(floating_.get()),
150 constrained_window->widget());
151 }
152
153 void TabContentsViewGtk::RemoveConstrainedWindow(
154 ConstrainedWindowGtk* constrained_window) {
155 std::vector<ConstrainedWindowGtk*>::iterator item =
156 find(constrained_windows_.begin(), constrained_windows_.end(),
157 constrained_window);
158 DCHECK(item != constrained_windows_.end());
159
160 gtk_container_remove(GTK_CONTAINER(floating_.get()),
161 constrained_window->widget());
162 constrained_windows_.erase(item);
163 }
164
142 void TabContentsViewGtk::CreateView() { 165 void TabContentsViewGtk::CreateView() {
143 // Windows uses this to do initialization, but we do all our initialization 166 // Windows uses this to do initialization, but we do all our initialization
144 // in the constructor. 167 // in the constructor.
145 } 168 }
146 169
147 RenderWidgetHostView* TabContentsViewGtk::CreateViewForWidget( 170 RenderWidgetHostView* TabContentsViewGtk::CreateViewForWidget(
148 RenderWidgetHost* render_widget_host) { 171 RenderWidgetHost* render_widget_host) {
149 if (render_widget_host->view()) { 172 if (render_widget_host->view()) {
150 // During testing, the view will already be set up in most cases to the 173 // During testing, the view will already be set up in most cases to the
151 // test view, so we don't want to clobber it with a real one. To verify that 174 // test view, so we don't want to clobber it with a real one. To verify that
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 gtk_container_child_set_property(GTK_CONTAINER(floating_container), 400 gtk_container_child_set_property(GTK_CONTAINER(floating_container),
378 widget, "x", &value); 401 widget, "x", &value);
379 402
380 int child_y = std::max( 403 int child_y = std::max(
381 allocation->y + allocation->height - requisition.height, 0); 404 allocation->y + allocation->height - requisition.height, 0);
382 g_value_set_int(&value, child_y); 405 g_value_set_int(&value, child_y);
383 gtk_container_child_set_property(GTK_CONTAINER(floating_container), 406 gtk_container_child_set_property(GTK_CONTAINER(floating_container),
384 widget, "y", &value); 407 widget, "y", &value);
385 g_value_unset(&value); 408 g_value_unset(&value);
386 } 409 }
410
411 // Place each ConstrainedWindow in the center of the view.
412 int half_view_width = std::max((allocation->x + allocation->width) / 2, 0);
413 int half_view_height = std::max((allocation->y + allocation->height) / 2, 0);
414 std::vector<ConstrainedWindowGtk*>::iterator it =
415 tab_contents_view->constrained_windows_.begin();
416 std::vector<ConstrainedWindowGtk*>::iterator end =
417 tab_contents_view->constrained_windows_.end();
418 for (; it != end; ++it) {
419 GtkWidget* widget = (*it)->widget();
420 DCHECK(widget->parent == tab_contents_view->floating_.get());
421
422 GtkRequisition requisition;
423 gtk_widget_size_request(widget, &requisition);
424
425 GValue value = { 0, };
426 g_value_init(&value, G_TYPE_INT);
427
428 int child_x = std::max(half_view_width - (requisition.width / 2), 0);
429 g_value_set_int(&value, child_x);
430 gtk_container_child_set_property(GTK_CONTAINER(floating_container),
431 widget, "x", &value);
432
433 int child_y = std::max(half_view_height - (requisition.height / 2), 0);
434 g_value_set_int(&value, child_y);
435 gtk_container_child_set_property(GTK_CONTAINER(floating_container),
436 widget, "y", &value);
437 g_value_unset(&value);
438 }
387 } 439 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698