summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autofill/autofill_external_delegate_gtk.cc
diff options
context:
space:
mode:
authorcsharp@chromium.org <csharp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-05 18:18:42 +0000
committercsharp@chromium.org <csharp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-05 18:18:42 +0000
commit61fd4dc472f8990d53b6773d98ef9c090dc33789 (patch)
tree25eb6a9cb4ee1832a59ebfc1eda5a26166699f80 /chrome/browser/autofill/autofill_external_delegate_gtk.cc
parentc385b2015f0969f9885f1284123d23c578ed8d8b (diff)
downloadchromium_src-61fd4dc472f8990d53b6773d98ef9c090dc33789.zip
chromium_src-61fd4dc472f8990d53b6773d98ef9c090dc33789.tar.gz
chromium_src-61fd4dc472f8990d53b6773d98ef9c090dc33789.tar.bz2
First pass for new GTK Autofill popup.
This first pass just displays the new Autofill popup and then hides it at the correct times. The box is the correct size, but none of the text is drawn at the moment. This is only enabled when the --external-autofill-popup flag is enabled. BUG=51644 Review URL: http://codereview.chromium.org/8890035 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@116512 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autofill/autofill_external_delegate_gtk.cc')
-rw-r--r--chrome/browser/autofill/autofill_external_delegate_gtk.cc86
1 files changed, 86 insertions, 0 deletions
diff --git a/chrome/browser/autofill/autofill_external_delegate_gtk.cc b/chrome/browser/autofill/autofill_external_delegate_gtk.cc
new file mode 100644
index 0000000..e39b72e
--- /dev/null
+++ b/chrome/browser/autofill/autofill_external_delegate_gtk.cc
@@ -0,0 +1,86 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/autofill/autofill_external_delegate_gtk.h"
+
+#include "chrome/browser/ui/gtk/autofill/autofill_popup_view_gtk.h"
+#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
+#include "content/browser/tab_contents/tab_contents.h"
+#include "content/browser/tab_contents/tab_contents_view.h"
+#include "content/public/browser/web_contents.h"
+
+AutofillExternalDelegate* AutofillExternalDelegate::Create(
+ TabContentsWrapper* tab_contents_wrapper,
+ AutofillManager* autofill_manager) {
+ return new AutofillExternalDelegateGtk(tab_contents_wrapper,
+ autofill_manager);
+}
+
+AutofillExternalDelegateGtk::AutofillExternalDelegateGtk(
+ TabContentsWrapper* tab_contents_wrapper,
+ AutofillManager* autofill_manager)
+ : AutofillExternalDelegate(tab_contents_wrapper, autofill_manager),
+ web_contents_(tab_contents_wrapper->web_contents()) {
+ tab_native_view_ = web_contents_->GetView()->GetNativeView();
+}
+
+AutofillExternalDelegateGtk::~AutofillExternalDelegateGtk() {
+}
+
+void AutofillExternalDelegateGtk::OnQueryPlatformSpecific(
+ int query_id,
+ const webkit::forms::FormData& form,
+ const webkit::forms::FormField& field,
+ const gfx::Rect& bounds) {
+ CreateViewIfNeeded();
+ view_->set_element_bounds(bounds);
+}
+
+void AutofillExternalDelegateGtk::ApplyAutofillSuggestions(
+ const std::vector<string16>& autofill_values,
+ const std::vector<string16>& autofill_labels,
+ const std::vector<string16>& autofill_icons,
+ const std::vector<int>& autofill_unique_ids,
+ int separator_index) {
+ view_->Show(autofill_values,
+ autofill_labels,
+ autofill_icons,
+ autofill_unique_ids,
+ separator_index);
+}
+
+void AutofillExternalDelegateGtk::HideAutofillPopup() {
+ if (!view_.get())
+ return;
+
+ view_->Hide();
+ view_.reset();
+
+ GtkWidget* toplevel = gtk_widget_get_toplevel(tab_native_view_);
+ g_signal_handler_disconnect(toplevel, event_handler_id_);
+}
+
+void AutofillExternalDelegateGtk::CreateViewIfNeeded() {
+ if (view_.get())
+ return;
+
+ view_.reset(new AutofillPopupViewGtk(web_contents_,
+ tab_native_view_));
+
+ GtkWidget* toplevel = gtk_widget_get_toplevel(tab_native_view_);
+ if (!g_signal_handler_is_connected(toplevel, event_handler_id_)) {
+ event_handler_id_ = g_signal_connect(
+ toplevel,
+ "focus-out-event",
+ G_CALLBACK(HandleViewFocusOutThunk),
+ this);
+ }
+}
+
+gboolean AutofillExternalDelegateGtk::HandleViewFocusOut(GtkWidget* sender,
+ GdkEventFocus* event) {
+ HideAutofillPopup();
+
+ return TRUE;
+}