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

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

Issue 10828259: Move AutofillExternalDelegateGtk to chrome/browser/ui/gtk/autofill, where it belongs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head Created 8 years, 4 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/autofill/autofill_external_delegate_gtk.h"
6
7 #include "chrome/browser/ui/gtk/autofill/autofill_popup_view_gtk.h"
8 #include "chrome/browser/ui/gtk/gtk_theme_service.h"
9 #include "chrome/browser/ui/tab_contents/tab_contents.h"
10 #include "content/public/browser/web_contents.h"
11 #include "content/public/browser/web_contents_view.h"
12
13 AutofillExternalDelegate* AutofillExternalDelegate::Create(
14 TabContents* tab_contents,
15 AutofillManager* autofill_manager) {
16 return new AutofillExternalDelegateGtk(tab_contents,
17 autofill_manager);
18 }
19
20 AutofillExternalDelegateGtk::AutofillExternalDelegateGtk(
21 TabContents* tab_contents,
22 AutofillManager* autofill_manager)
23 : AutofillExternalDelegate(tab_contents, autofill_manager),
24 web_contents_(tab_contents->web_contents()),
25 event_handler_id_(0) {
26 tab_native_view_ = web_contents_->GetView()->GetNativeView();
27 }
28
29 AutofillExternalDelegateGtk::~AutofillExternalDelegateGtk() {
30 }
31
32 void AutofillExternalDelegateGtk::HideAutofillPopupInternal() {
33 if (!view_.get())
34 return;
35
36 view_->Hide();
37 view_.reset();
38
39 GtkWidget* toplevel = gtk_widget_get_toplevel(tab_native_view_);
40 g_signal_handler_disconnect(toplevel, event_handler_id_);
41 }
42
43 void AutofillExternalDelegateGtk::OnQueryPlatformSpecific(
44 int query_id,
45 const webkit::forms::FormData& form,
46 const webkit::forms::FormField& field,
47 const gfx::Rect& bounds) {
48 CreateViewIfNeeded();
49 view_->set_element_bounds(bounds);
50 }
51
52 void AutofillExternalDelegateGtk::ApplyAutofillSuggestions(
53 const std::vector<string16>& autofill_values,
54 const std::vector<string16>& autofill_labels,
55 const std::vector<string16>& autofill_icons,
56 const std::vector<int>& autofill_unique_ids) {
57 view_->Show(autofill_values,
58 autofill_labels,
59 autofill_icons,
60 autofill_unique_ids);
61 }
62
63 void AutofillExternalDelegateGtk::SetBounds(const gfx::Rect& bounds) {
64 CreateViewIfNeeded();
65 view_->set_element_bounds(bounds);
66 }
67
68 void AutofillExternalDelegateGtk::CreateViewIfNeeded() {
69 if (view_.get())
70 return;
71
72 view_.reset(new AutofillPopupViewGtk(web_contents_,
73 GtkThemeService::GetFrom(profile()),
74 this,
75 tab_native_view_));
76
77 GtkWidget* toplevel = gtk_widget_get_toplevel(tab_native_view_);
78 if (!g_signal_handler_is_connected(toplevel, event_handler_id_)) {
79 event_handler_id_ = g_signal_connect(
80 toplevel,
81 "focus-out-event",
82 G_CALLBACK(HandleViewFocusOutThunk),
83 this);
84 }
85 }
86
87 gboolean AutofillExternalDelegateGtk::HandleViewFocusOut(GtkWidget* sender,
88 GdkEventFocus* event) {
89 HideAutofillPopup();
90
91 return TRUE;
92 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698