OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "components/autofill/core/browser/autofill_external_delegate.h" | 5 #include "components/autofill/core/browser/autofill_external_delegate.h" |
6 | 6 |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "components/autofill/core/browser/autocomplete_history_manager.h" | 8 #include "components/autofill/core/browser/autocomplete_history_manager.h" |
9 #include "components/autofill/core/browser/autofill_manager.h" | 9 #include "components/autofill/core/browser/autofill_manager.h" |
10 #include "components/autofill/core/common/autofill_messages.h" | 10 #include "components/autofill/core/common/autofill_messages.h" |
11 #include "content/public/browser/navigation_controller.h" | |
12 #include "content/public/browser/notification_service.h" | |
13 #include "content/public/browser/notification_source.h" | |
14 #include "content/public/browser/notification_types.h" | |
15 #include "content/public/browser/render_view_host.h" | 11 #include "content/public/browser/render_view_host.h" |
16 #include "content/public/browser/web_contents.h" | 12 #include "content/public/browser/web_contents.h" |
17 #include "grit/component_strings.h" | 13 #include "grit/component_strings.h" |
18 #include "third_party/WebKit/public/web/WebAutofillClient.h" | 14 #include "third_party/WebKit/public/web/WebAutofillClient.h" |
19 #include "ui/base/l10n/l10n_util.h" | 15 #include "ui/base/l10n/l10n_util.h" |
20 | 16 |
21 #if defined(OS_ANDROID) | 17 #if defined(OS_ANDROID) |
22 #include "content/public/browser/android/content_view_core.h" | 18 #include "content/public/browser/android/content_view_core.h" |
23 #endif | 19 #endif |
24 | 20 |
25 using content::RenderViewHost; | 21 using content::RenderViewHost; |
26 using WebKit::WebAutofillClient; | 22 using WebKit::WebAutofillClient; |
27 | 23 |
28 namespace autofill { | 24 namespace autofill { |
29 | 25 |
30 AutofillExternalDelegate::AutofillExternalDelegate( | 26 AutofillExternalDelegate::AutofillExternalDelegate( |
31 content::WebContents* web_contents, | 27 content::WebContents* web_contents, |
32 AutofillManager* autofill_manager) | 28 AutofillManager* autofill_manager) |
33 : web_contents_(web_contents), | 29 : web_contents_(web_contents), |
34 autofill_manager_(autofill_manager), | 30 autofill_manager_(autofill_manager), |
35 password_autofill_manager_(web_contents), | 31 password_autofill_manager_(web_contents), |
36 autofill_query_id_(0), | 32 autofill_query_id_(0), |
37 display_warning_if_disabled_(false), | 33 display_warning_if_disabled_(false), |
38 has_autofill_suggestion_(false), | 34 has_autofill_suggestion_(false), |
39 has_shown_autofill_popup_for_current_edit_(false), | 35 has_shown_autofill_popup_for_current_edit_(false), |
40 registered_keyboard_listener_with_(NULL), | 36 registered_keyboard_listener_with_(NULL), |
41 weak_ptr_factory_(this) { | 37 weak_ptr_factory_(this) { |
42 DCHECK(autofill_manager); | 38 DCHECK(autofill_manager); |
43 | |
44 registrar_.Add(this, | |
45 content::NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED, | |
46 content::Source<content::WebContents>(web_contents)); | |
47 registrar_.Add( | |
48 this, | |
49 content::NOTIFICATION_NAV_ENTRY_COMMITTED, | |
50 content::Source<content::NavigationController>( | |
51 &(web_contents->GetController()))); | |
52 } | 39 } |
53 | 40 |
54 AutofillExternalDelegate::~AutofillExternalDelegate() {} | 41 AutofillExternalDelegate::~AutofillExternalDelegate() {} |
55 | 42 |
56 void AutofillExternalDelegate::OnQuery(int query_id, | 43 void AutofillExternalDelegate::OnQuery(int query_id, |
57 const FormData& form, | 44 const FormData& form, |
58 const FormFieldData& field, | 45 const FormFieldData& field, |
59 const gfx::RectF& element_bounds, | 46 const gfx::RectF& element_bounds, |
60 bool display_warning_if_disabled) { | 47 bool display_warning_if_disabled) { |
61 autofill_query_form_ = form; | 48 autofill_query_form_ = form; |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 data_list_labels_.begin(), | 355 data_list_labels_.begin(), |
369 data_list_labels_.end()); | 356 data_list_labels_.end()); |
370 autofill_icons->insert(autofill_icons->begin(), | 357 autofill_icons->insert(autofill_icons->begin(), |
371 data_list_icons_.begin(), | 358 data_list_icons_.begin(), |
372 data_list_icons_.end()); | 359 data_list_icons_.end()); |
373 autofill_unique_ids->insert(autofill_unique_ids->begin(), | 360 autofill_unique_ids->insert(autofill_unique_ids->begin(), |
374 data_list_unique_ids_.begin(), | 361 data_list_unique_ids_.begin(), |
375 data_list_unique_ids_.end()); | 362 data_list_unique_ids_.end()); |
376 } | 363 } |
377 | 364 |
378 void AutofillExternalDelegate::Observe( | |
379 int type, | |
380 const content::NotificationSource& source, | |
381 const content::NotificationDetails& details) { | |
382 if (type == content::NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED) { | |
383 if (!*content::Details<bool>(details).ptr()) | |
384 autofill_manager_->delegate()->HideAutofillPopup(); | |
385 } else if (type == content::NOTIFICATION_NAV_ENTRY_COMMITTED) { | |
386 autofill_manager_->delegate()->HideAutofillPopup(); | |
387 } else { | |
388 NOTREACHED(); | |
389 } | |
390 } | |
391 | |
392 } // namespace autofill | 365 } // namespace autofill |
OLD | NEW |