autocomplete_popup_gtk.cc revision 72a454cd3513ac24fbdd0e0cb9ad70b86a99b801
1// Copyright (c) 2011 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/views/autocomplete/autocomplete_popup_gtk.h"
6
7#include "chrome/browser/autocomplete/autocomplete_edit_view.h"
8#include "chrome/browser/autocomplete/autocomplete_popup_model.h"
9#include "chrome/browser/ui/gtk/gtk_util.h"
10#include "chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.h"
11#include "ui/gfx/insets.h"
12
13////////////////////////////////////////////////////////////////////////////////
14// AutocompletePopupGtk, public:
15
16AutocompletePopupGtk::AutocompletePopupGtk(
17    AutocompleteEditView* edit_view,
18    AutocompletePopupContentsView* contents)
19    : WidgetGtk(WidgetGtk::TYPE_POPUP) {
20  // Create the popup.
21  MakeTransparent();
22  WidgetGtk::Init(gtk_widget_get_parent(edit_view->GetNativeView()),
23                  contents->GetPopupBounds());
24  // The contents is owned by the LocationBarView.
25  contents->set_parent_owned(false);
26  SetContentsView(contents);
27
28  Show();
29
30  // Restack the popup window directly above the browser's toplevel window.
31  GtkWidget* toplevel = gtk_widget_get_toplevel(edit_view->GetNativeView());
32  DCHECK(GTK_WIDGET_TOPLEVEL(toplevel));
33  gtk_util::StackPopupWindow(GetNativeView(), toplevel);
34}
35
36AutocompletePopupGtk::~AutocompletePopupGtk() {
37}
38