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

Side by Side Diff: chrome/browser/views/autocomplete/autocomplete_popup_gtk.cc

Issue 391011: Avoid inconsistent state (leading to checkfailures) due to Windows minimize/r... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
2 // source code is governed by a BSD-style license that can be found in the 2 // source code is governed by a BSD-style license that can be found in the
3 // LICENSE file. 3 // LICENSE file.
4 4
5 #include "chrome/browser/views/autocomplete/autocomplete_popup_gtk.h" 5 #include "chrome/browser/views/autocomplete/autocomplete_popup_gtk.h"
6 6
7 #include "app/gfx/insets.h" 7 #include "app/gfx/insets.h"
8 #include "chrome/browser/autocomplete/autocomplete_edit_view.h" 8 #include "chrome/browser/autocomplete/autocomplete_edit_view.h"
9 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" 9 #include "chrome/browser/autocomplete/autocomplete_popup_model.h"
10 #include "chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h" 10 #include "chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h"
11 #include "chrome/common/gtk_util.h" 11 #include "chrome/common/gtk_util.h"
12 12
13 //////////////////////////////////////////////////////////////////////////////// 13 ////////////////////////////////////////////////////////////////////////////////
14 // AutocompletePopupGtk, public: 14 // AutocompletePopupGtk, public:
15 15
16 AutocompletePopupGtk::AutocompletePopupGtk( 16 AutocompletePopupGtk::AutocompletePopupGtk(
17 AutocompleteEditView* edit_view,
17 AutocompletePopupContentsView* contents) 18 AutocompletePopupContentsView* contents)
18 : WidgetGtk(WidgetGtk::TYPE_POPUP), 19 : WidgetGtk(WidgetGtk::TYPE_POPUP) {
19 contents_(contents), 20 // Create the popup. // Owned by |contents|.
20 edit_view_(NULL),
21 is_open_(false) {
22 set_delete_on_destroy(false); 21 set_delete_on_destroy(false);
22 MakeTransparent();
23 WidgetGtk::Init(gtk_widget_get_parent(edit_view->GetNativeView()),
24 contents->GetPopupBounds());
25 // The contents is owned by the LocationBarView.
26 contents->set_parent_owned(false);
27 SetContentsView(contents);
28
29 Show();
30
31 // Restack the popup window directly above the browser's toplevel window.
32 GtkWidget* toplevel = gtk_widget_get_toplevel(edit_view->GetNativeView());
33 DCHECK(GTK_WIDGET_TOPLEVEL(toplevel));
34 gtk_util::StackPopupWindow(GetNativeView(), toplevel);
23 } 35 }
24 36
25 AutocompletePopupGtk::~AutocompletePopupGtk() { 37 AutocompletePopupGtk::~AutocompletePopupGtk() {
26 } 38 }
27
28 void AutocompletePopupGtk::Show() {
29 // Move the popup to the place appropriate for the window's current position -
30 // it may have been moved since it was last shown.
31 SetBounds(contents_->GetPopupBounds());
32 if (!IsVisible()) {
33 WidgetGtk::Show();
34 StackWindow();
35 }
36 is_open_ = true;
37 }
38
39 void AutocompletePopupGtk::Hide() {
40 WidgetGtk::Hide();
41 is_open_ = false;
42 }
43
44 void AutocompletePopupGtk::Init(AutocompleteEditView* edit_view,
45 views::View* contents) {
46 MakeTransparent();
47 // Create the popup
48 WidgetGtk::Init(gtk_widget_get_parent(edit_view->GetNativeView()),
49 contents_->GetPopupBounds());
50 // The contents is owned by the LocationBarView.
51 contents_->set_parent_owned(false);
52 SetContentsView(contents_);
53
54 edit_view_ = edit_view;
55
56 Show();
57 }
58
59 bool AutocompletePopupGtk::IsOpen() const {
60 const bool is_open = IsCreated() && IsVisible();
61 CHECK(is_open == is_open_);
62 return is_open;
63 }
64
65 bool AutocompletePopupGtk::IsCreated() const {
66 return GTK_IS_WIDGET(GetNativeView());
67 }
68
69 void AutocompletePopupGtk::StackWindow() {
70 GtkWidget* toplevel = gtk_widget_get_toplevel(edit_view_->GetNativeView());
71 DCHECK(GTK_WIDGET_TOPLEVEL(toplevel));
72 gtk_util::StackPopupWindow(GetNativeView(), toplevel);
73 }
OLDNEW
« no previous file with comments | « chrome/browser/views/autocomplete/autocomplete_popup_gtk.h ('k') | chrome/browser/views/autocomplete/autocomplete_popup_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698