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 "android_webview/native/aw_autofill_manager_delegate.h" | 5 #include "android_webview/native/aw_autofill_manager_delegate.h" |
6 | 6 |
7 #include "android_webview/browser/aw_browser_context.h" | 7 #include "android_webview/browser/aw_browser_context.h" |
8 #include "android_webview/browser/aw_content_browser_client.h" | 8 #include "android_webview/browser/aw_content_browser_client.h" |
9 #include "android_webview/browser/aw_form_database_service.h" | 9 #include "android_webview/browser/aw_form_database_service.h" |
10 #include "android_webview/browser/aw_pref_store.h" | 10 #include "android_webview/browser/aw_pref_store.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 AwAutofillManagerDelegate::GetDatabase() { | 77 AwAutofillManagerDelegate::GetDatabase() { |
78 android_webview::AwFormDatabaseService* service = | 78 android_webview::AwFormDatabaseService* service = |
79 static_cast<android_webview::AwBrowserContext*>( | 79 static_cast<android_webview::AwBrowserContext*>( |
80 web_contents_->GetBrowserContext())->GetFormDatabaseService(); | 80 web_contents_->GetBrowserContext())->GetFormDatabaseService(); |
81 return service->get_autofill_webdata_service(); | 81 return service->get_autofill_webdata_service(); |
82 } | 82 } |
83 | 83 |
84 void AwAutofillManagerDelegate::ShowAutofillPopup( | 84 void AwAutofillManagerDelegate::ShowAutofillPopup( |
85 const gfx::RectF& element_bounds, | 85 const gfx::RectF& element_bounds, |
86 base::i18n::TextDirection text_direction, | 86 base::i18n::TextDirection text_direction, |
87 const std::vector<string16>& values, | 87 const std::vector<base::string16>& values, |
88 const std::vector<string16>& labels, | 88 const std::vector<base::string16>& labels, |
89 const std::vector<string16>& icons, | 89 const std::vector<base::string16>& icons, |
90 const std::vector<int>& identifiers, | 90 const std::vector<int>& identifiers, |
91 base::WeakPtr<autofill::AutofillPopupDelegate> delegate) { | 91 base::WeakPtr<autofill::AutofillPopupDelegate> delegate) { |
92 | 92 |
93 values_ = values; | 93 values_ = values; |
94 identifiers_ = identifiers; | 94 identifiers_ = identifiers; |
95 delegate_ = delegate; | 95 delegate_ = delegate; |
96 | 96 |
97 // Convert element_bounds to be in screen space. | 97 // Convert element_bounds to be in screen space. |
98 gfx::Rect client_area; | 98 gfx::Rect client_area; |
99 web_contents_->GetView()->GetContainerBounds(&client_area); | 99 web_contents_->GetView()->GetContainerBounds(&client_area); |
100 gfx::RectF element_bounds_in_screen_space = | 100 gfx::RectF element_bounds_in_screen_space = |
101 element_bounds + client_area.OffsetFromOrigin(); | 101 element_bounds + client_area.OffsetFromOrigin(); |
102 | 102 |
103 ShowAutofillPopupImpl(element_bounds_in_screen_space, | 103 ShowAutofillPopupImpl(element_bounds_in_screen_space, |
104 values, | 104 values, |
105 labels, | 105 labels, |
106 identifiers); | 106 identifiers); |
107 } | 107 } |
108 | 108 |
109 void AwAutofillManagerDelegate::ShowAutofillPopupImpl( | 109 void AwAutofillManagerDelegate::ShowAutofillPopupImpl( |
110 const gfx::RectF& element_bounds, | 110 const gfx::RectF& element_bounds, |
111 const std::vector<string16>& values, | 111 const std::vector<base::string16>& values, |
112 const std::vector<string16>& labels, | 112 const std::vector<base::string16>& labels, |
113 const std::vector<int>& identifiers) { | 113 const std::vector<int>& identifiers) { |
114 JNIEnv* env = AttachCurrentThread(); | 114 JNIEnv* env = AttachCurrentThread(); |
115 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 115 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
116 if (obj.is_null()) | 116 if (obj.is_null()) |
117 return; | 117 return; |
118 | 118 |
119 // We need an array of AutofillSuggestion. | 119 // We need an array of AutofillSuggestion. |
120 size_t count = values.size(); | 120 size_t count = values.size(); |
121 | 121 |
122 ScopedJavaLocalRef<jobjectArray> data_array = | 122 ScopedJavaLocalRef<jobjectArray> data_array = |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 const GURL& source_url, | 193 const GURL& source_url, |
194 const base::Callback<void(const autofill::FormStructure*)>& callback) { | 194 const base::Callback<void(const autofill::FormStructure*)>& callback) { |
195 NOTIMPLEMENTED(); | 195 NOTIMPLEMENTED(); |
196 } | 196 } |
197 | 197 |
198 bool RegisterAwAutofillManagerDelegate(JNIEnv* env) { | 198 bool RegisterAwAutofillManagerDelegate(JNIEnv* env) { |
199 return RegisterNativesImpl(env) >= 0; | 199 return RegisterNativesImpl(env) >= 0; |
200 } | 200 } |
201 | 201 |
202 } // namespace android_webview | 202 } // namespace android_webview |
OLD | NEW |