Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "android_webview/browser/aw_autofill_manager_delegate.h" | 5 #include "android_webview/native/aw_autofill_manager_delegate.h" |
| 6 | |
| 6 #include "android_webview/browser/aw_browser_context.h" | 7 #include "android_webview/browser/aw_browser_context.h" |
| 7 #include "android_webview/browser/aw_content_browser_client.h" | 8 #include "android_webview/browser/aw_content_browser_client.h" |
| 8 #include "android_webview/browser/aw_pref_store.h" | 9 #include "android_webview/browser/aw_pref_store.h" |
| 10 #include "android_webview/native/aw_contents.h" | |
| 9 #include "base/logging.h" | 11 #include "base/logging.h" |
| 10 #include "base/prefs/pref_registry_simple.h" | 12 #include "base/prefs/pref_registry_simple.h" |
| 11 #include "base/prefs/pref_service.h" | 13 #include "base/prefs/pref_service.h" |
| 12 #include "base/prefs/pref_service_builder.h" | 14 #include "base/prefs/pref_service_builder.h" |
| 13 #include "components/autofill/browser/autocheckout/whitelist_manager.h" | 15 #include "components/autofill/browser/autocheckout/whitelist_manager.h" |
| 16 #include "components/autofill/browser/autofill_external_delegate.h" | |
| 14 #include "components/autofill/browser/webdata/autofill_webdata_service.h" | 17 #include "components/autofill/browser/webdata/autofill_webdata_service.h" |
| 15 #include "components/autofill/common/autofill_pref_names.h" | 18 #include "components/autofill/common/autofill_pref_names.h" |
| 16 #include "components/user_prefs/user_prefs.h" | 19 #include "components/user_prefs/user_prefs.h" |
| 17 #include "content/public/browser/web_contents.h" | 20 #include "content/public/browser/web_contents.h" |
| 21 #include "content/public/browser/web_contents_view.h" | |
| 18 | 22 |
| 19 using content::WebContents; | 23 using content::WebContents; |
| 20 | 24 |
| 21 DEFINE_WEB_CONTENTS_USER_DATA_KEY(android_webview::AwAutofillManagerDelegate); | 25 DEFINE_WEB_CONTENTS_USER_DATA_KEY(android_webview::AwAutofillManagerDelegate); |
| 22 | 26 |
| 23 namespace android_webview { | 27 namespace android_webview { |
| 24 | 28 |
| 25 AwAutofillManagerDelegate::AwAutofillManagerDelegate(WebContents* contents) { } | 29 AwAutofillManagerDelegate::AwAutofillManagerDelegate( |
| 30 WebContents* web_contents) { | |
| 31 web_contents_ = web_contents; | |
| 32 } | |
| 26 | 33 |
| 27 AwAutofillManagerDelegate::~AwAutofillManagerDelegate() { } | 34 AwAutofillManagerDelegate::~AwAutofillManagerDelegate() { |
| 35 HideAutofillPopup(); | |
| 36 } | |
| 28 | 37 |
| 29 void AwAutofillManagerDelegate::SetSaveFormData(bool enabled) { | 38 void AwAutofillManagerDelegate::SetSaveFormData(bool enabled) { |
| 30 save_form_data_ = enabled; | 39 save_form_data_ = enabled; |
| 31 } | 40 } |
| 32 | 41 |
| 33 bool AwAutofillManagerDelegate::GetSaveFormData() { | 42 bool AwAutofillManagerDelegate::GetSaveFormData() { |
| 34 return save_form_data_; | 43 return save_form_data_; |
| 35 } | 44 } |
| 36 | 45 |
| 37 PrefService* AwAutofillManagerDelegate::GetPrefs() { | 46 PrefService* AwAutofillManagerDelegate::GetPrefs() { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 71 } | 80 } |
| 72 | 81 |
| 73 void AwAutofillManagerDelegate::HideAutocheckoutBubble() { | 82 void AwAutofillManagerDelegate::HideAutocheckoutBubble() { |
| 74 } | 83 } |
| 75 | 84 |
| 76 void AwAutofillManagerDelegate::ShowRequestAutocompleteDialog( | 85 void AwAutofillManagerDelegate::ShowRequestAutocompleteDialog( |
| 77 const autofill::FormData& form, | 86 const autofill::FormData& form, |
| 78 const GURL& source_url, | 87 const GURL& source_url, |
| 79 autofill::DialogType dialog_type, | 88 autofill::DialogType dialog_type, |
| 80 const base::Callback<void(const autofill::FormStructure*, | 89 const base::Callback<void(const autofill::FormStructure*, |
| 81 const std::string&)>& callback) { | 90 const std::string&)>& callback) { |
|
joth
2013/06/04 01:14:46
feels like these empty methods should have a NOTIM
sgurun-gerrit only
2013/06/15 01:16:51
I am not sure if all the methods qualify for a NOT
benm (inactive)
2013/06/17 09:48:52
I think I may have talked about adding NOTREACHED(
joth
2013/06/17 17:00:54
0/ empty method with a comment makes sense for som
| |
| 82 } | 91 } |
| 83 | 92 |
| 84 void AwAutofillManagerDelegate::ShowAutofillPopup( | 93 void AwAutofillManagerDelegate::ShowAutofillPopup( |
| 85 const gfx::RectF& element_bounds, | 94 const gfx::RectF& element_bounds, |
| 86 const std::vector<string16>& values, | 95 const std::vector<string16>& values, |
| 87 const std::vector<string16>& labels, | 96 const std::vector<string16>& labels, |
| 88 const std::vector<string16>& icons, | 97 const std::vector<string16>& icons, |
| 89 const std::vector<int>& identifiers, | 98 const std::vector<int>& identifiers, |
| 90 base::WeakPtr<autofill::AutofillPopupDelegate> delegate) { | 99 base::WeakPtr<autofill::AutofillPopupDelegate> delegate) { |
| 100 | |
| 101 values_ = values; | |
| 102 identifiers_ = identifiers; | |
| 103 delegate_ = delegate; | |
| 104 | |
| 105 // Convert element_bounds to be in screen space. | |
| 106 gfx::Rect client_area; | |
| 107 web_contents_->GetView()->GetContainerBounds(&client_area); | |
| 108 gfx::RectF element_bounds_in_screen_space = | |
| 109 element_bounds + client_area.OffsetFromOrigin(); | |
| 110 | |
| 111 AwContents* aw_contents = AwContents::FromWebContents(web_contents_); | |
| 112 if (!aw_contents) | |
| 113 return; | |
| 114 aw_contents->ShowAutofillPopup(element_bounds_in_screen_space, | |
|
joth
2013/06/04 01:14:46
If moving AwAutofillManagerDelegate into aw/native
sgurun-gerrit only
2013/06/15 01:16:51
Done. I have created the peer from the native side
| |
| 115 values, | |
| 116 labels, | |
| 117 identifiers); | |
| 91 } | 118 } |
| 92 | 119 |
| 93 void AwAutofillManagerDelegate::HideAutofillPopup() { | 120 void AwAutofillManagerDelegate::HideAutofillPopup() { |
| 121 AwContents* aw_contents = AwContents::FromWebContents(web_contents_); | |
| 122 if (!aw_contents) | |
| 123 return; | |
| 124 aw_contents->HideAutofillPopup(); | |
|
benm (inactive)
2013/06/04 13:35:18
reset delegate_?
sgurun-gerrit only
2013/06/15 01:16:51
Done.
| |
| 94 } | 125 } |
| 95 | 126 |
| 96 void AwAutofillManagerDelegate::UpdateProgressBar(double value) { | 127 void AwAutofillManagerDelegate::UpdateProgressBar(double value) { |
| 97 } | 128 } |
| 98 | 129 |
| 130 void AwAutofillManagerDelegate::SuggestionSelected(int position) { | |
| 131 delegate_->DidAcceptSuggestion(values_[position], identifiers_[position]); | |
|
benm (inactive)
2013/06/04 13:35:18
check delegate_ is set and still valid (as it's we
sgurun-gerrit only
2013/06/15 01:16:51
done
| |
| 132 } | |
| 133 | |
| 99 } // namespace android_webview | 134 } // namespace android_webview |
| OLD | NEW |