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

Side by Side Diff: chrome/browser/autofill/autofill_external_delegate_gtk.cc

Issue 9235072: Adding Mouse Support for new GTK Autofill (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixing problem with autofillAgent browser tests Created 8 years, 10 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/autofill/autofill_external_delegate_gtk.h" 5 #include "chrome/browser/autofill/autofill_external_delegate_gtk.h"
6 6
7 #include "chrome/browser/ui/gtk/autofill/autofill_popup_view_gtk.h" 7 #include "chrome/browser/ui/gtk/autofill/autofill_popup_view_gtk.h"
8 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 8 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
9 #include "content/public/browser/web_contents.h" 9 #include "content/public/browser/web_contents.h"
10 #include "content/public/browser/web_contents_view.h" 10 #include "content/public/browser/web_contents_view.h"
(...skipping 10 matching lines...) Expand all
21 AutofillManager* autofill_manager) 21 AutofillManager* autofill_manager)
22 : AutofillExternalDelegate(tab_contents_wrapper, autofill_manager), 22 : AutofillExternalDelegate(tab_contents_wrapper, autofill_manager),
23 web_contents_(tab_contents_wrapper->web_contents()), 23 web_contents_(tab_contents_wrapper->web_contents()),
24 event_handler_id_(0) { 24 event_handler_id_(0) {
25 tab_native_view_ = web_contents_->GetView()->GetNativeView(); 25 tab_native_view_ = web_contents_->GetView()->GetNativeView();
26 } 26 }
27 27
28 AutofillExternalDelegateGtk::~AutofillExternalDelegateGtk() { 28 AutofillExternalDelegateGtk::~AutofillExternalDelegateGtk() {
29 } 29 }
30 30
31 void AutofillExternalDelegateGtk::HideAutofillPopupInternal() {
32 if (!view_.get())
33 return;
34
35 view_->Hide();
36 view_.reset();
37
38 GtkWidget* toplevel = gtk_widget_get_toplevel(tab_native_view_);
39 g_signal_handler_disconnect(toplevel, event_handler_id_);
40 }
41
31 void AutofillExternalDelegateGtk::OnQueryPlatformSpecific( 42 void AutofillExternalDelegateGtk::OnQueryPlatformSpecific(
32 int query_id, 43 int query_id,
33 const webkit::forms::FormData& form, 44 const webkit::forms::FormData& form,
34 const webkit::forms::FormField& field, 45 const webkit::forms::FormField& field,
35 const gfx::Rect& bounds) { 46 const gfx::Rect& bounds) {
36 CreateViewIfNeeded(); 47 CreateViewIfNeeded();
37 view_->set_element_bounds(bounds); 48 view_->set_element_bounds(bounds);
38 } 49 }
39 50
40 void AutofillExternalDelegateGtk::ApplyAutofillSuggestions( 51 void AutofillExternalDelegateGtk::ApplyAutofillSuggestions(
41 const std::vector<string16>& autofill_values, 52 const std::vector<string16>& autofill_values,
42 const std::vector<string16>& autofill_labels, 53 const std::vector<string16>& autofill_labels,
43 const std::vector<string16>& autofill_icons, 54 const std::vector<string16>& autofill_icons,
44 const std::vector<int>& autofill_unique_ids, 55 const std::vector<int>& autofill_unique_ids,
45 int separator_index) { 56 int separator_index) {
46 view_->Show(autofill_values, 57 view_->Show(autofill_values,
47 autofill_labels, 58 autofill_labels,
48 autofill_icons, 59 autofill_icons,
49 autofill_unique_ids, 60 autofill_unique_ids,
50 separator_index); 61 separator_index);
51 } 62 }
52 63
53 void AutofillExternalDelegateGtk::HideAutofillPopup() {
54 if (!view_.get())
55 return;
56
57 view_->Hide();
58 view_.reset();
59
60 GtkWidget* toplevel = gtk_widget_get_toplevel(tab_native_view_);
61 g_signal_handler_disconnect(toplevel, event_handler_id_);
62 }
63
64 void AutofillExternalDelegateGtk::CreateViewIfNeeded() { 64 void AutofillExternalDelegateGtk::CreateViewIfNeeded() {
65 if (view_.get()) 65 if (view_.get())
66 return; 66 return;
67 67
68 view_.reset(new AutofillPopupViewGtk(web_contents_, 68 view_.reset(new AutofillPopupViewGtk(web_contents_,
69 this,
69 tab_native_view_)); 70 tab_native_view_));
70 71
71 GtkWidget* toplevel = gtk_widget_get_toplevel(tab_native_view_); 72 GtkWidget* toplevel = gtk_widget_get_toplevel(tab_native_view_);
72 if (!g_signal_handler_is_connected(toplevel, event_handler_id_)) { 73 if (!g_signal_handler_is_connected(toplevel, event_handler_id_)) {
73 event_handler_id_ = g_signal_connect( 74 event_handler_id_ = g_signal_connect(
74 toplevel, 75 toplevel,
75 "focus-out-event", 76 "focus-out-event",
76 G_CALLBACK(HandleViewFocusOutThunk), 77 G_CALLBACK(HandleViewFocusOutThunk),
77 this); 78 this);
78 } 79 }
79 } 80 }
80 81
81 gboolean AutofillExternalDelegateGtk::HandleViewFocusOut(GtkWidget* sender, 82 gboolean AutofillExternalDelegateGtk::HandleViewFocusOut(GtkWidget* sender,
82 GdkEventFocus* event) { 83 GdkEventFocus* event) {
83 HideAutofillPopup(); 84 HideAutofillPopup();
84 85
85 return TRUE; 86 return TRUE;
86 } 87 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698