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

Side by Side Diff: android_webview/native/aw_contents.cc

Issue 16286020: Abstract WebContentsObserver from Autofill shared code (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Response to review of PS #6 Created 7 years, 6 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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_contents.h" 5 #include "android_webview/native/aw_contents.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_browser_main_parts.h" 8 #include "android_webview/browser/aw_browser_main_parts.h"
9 #include "android_webview/browser/gpu_memory_buffer_impl.h" 9 #include "android_webview/browser/gpu_memory_buffer_impl.h"
10 #include "android_webview/browser/in_process_view_renderer.h" 10 #include "android_webview/browser/in_process_view_renderer.h"
(...skipping 10 matching lines...) Expand all
21 #include "base/android/jni_android.h" 21 #include "base/android/jni_android.h"
22 #include "base/android/jni_array.h" 22 #include "base/android/jni_array.h"
23 #include "base/android/jni_string.h" 23 #include "base/android/jni_string.h"
24 #include "base/android/scoped_java_ref.h" 24 #include "base/android/scoped_java_ref.h"
25 #include "base/bind.h" 25 #include "base/bind.h"
26 #include "base/callback.h" 26 #include "base/callback.h"
27 #include "base/message_loop.h" 27 #include "base/message_loop.h"
28 #include "base/pickle.h" 28 #include "base/pickle.h"
29 #include "base/strings/string16.h" 29 #include "base/strings/string16.h"
30 #include "base/supports_user_data.h" 30 #include "base/supports_user_data.h"
31 #include "components/autofill/browser/autofill_external_delegate.h"
32 #include "components/autofill/browser/autofill_manager.h" 31 #include "components/autofill/browser/autofill_manager.h"
33 #include "components/autofill/browser/webdata/autofill_webdata_service.h" 32 #include "components/autofill/browser/webdata/autofill_webdata_service.h"
33 #include "components/autofill/content/browser/autofill_driver_impl.h"
34 #include "components/navigation_interception/intercept_navigation_delegate.h" 34 #include "components/navigation_interception/intercept_navigation_delegate.h"
35 #include "content/public/browser/android/content_view_core.h" 35 #include "content/public/browser/android/content_view_core.h"
36 #include "content/public/browser/browser_thread.h" 36 #include "content/public/browser/browser_thread.h"
37 #include "content/public/browser/cert_store.h" 37 #include "content/public/browser/cert_store.h"
38 #include "content/public/browser/navigation_entry.h" 38 #include "content/public/browser/navigation_entry.h"
39 #include "content/public/browser/render_process_host.h" 39 #include "content/public/browser/render_process_host.h"
40 #include "content/public/browser/render_view_host.h" 40 #include "content/public/browser/render_view_host.h"
41 #include "content/public/browser/web_contents.h" 41 #include "content/public/browser/web_contents.h"
42 #include "content/public/common/ssl_status.h" 42 #include "content/public/common/ssl_status.h"
43 #include "jni/AwContents_jni.h" 43 #include "jni/AwContents_jni.h"
44 #include "net/cert/x509_certificate.h" 44 #include "net/cert/x509_certificate.h"
45 #include "ui/base/l10n/l10n_util_android.h" 45 #include "ui/base/l10n/l10n_util_android.h"
46 #include "ui/gfx/android/java_bitmap.h" 46 #include "ui/gfx/android/java_bitmap.h"
47 47
48 struct AwDrawSWFunctionTable; 48 struct AwDrawSWFunctionTable;
49 struct AwDrawGLFunctionTable; 49 struct AwDrawGLFunctionTable;
50 50
51 using autofill::AutofillExternalDelegate; 51 using autofill::AutofillDriverImpl;
52 using autofill::AutofillManager; 52 using autofill::AutofillManager;
53 using base::android::AttachCurrentThread; 53 using base::android::AttachCurrentThread;
54 using base::android::ConvertJavaStringToUTF16; 54 using base::android::ConvertJavaStringToUTF16;
55 using base::android::ConvertJavaStringToUTF8; 55 using base::android::ConvertJavaStringToUTF8;
56 using base::android::ConvertUTF16ToJavaString; 56 using base::android::ConvertUTF16ToJavaString;
57 using base::android::ConvertUTF8ToJavaString; 57 using base::android::ConvertUTF8ToJavaString;
58 using base::android::JavaRef; 58 using base::android::JavaRef;
59 using base::android::ScopedJavaGlobalRef; 59 using base::android::ScopedJavaGlobalRef;
60 using base::android::ScopedJavaLocalRef; 60 using base::android::ScopedJavaLocalRef;
61 using navigation_interception::InterceptNavigationDelegate; 61 using navigation_interception::InterceptNavigationDelegate;
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 AwBrowserContext::FromWebContents(web_contents_.get())-> 157 AwBrowserContext::FromWebContents(web_contents_.get())->
158 AutofillManagerDelegate(); 158 AutofillManagerDelegate();
159 if (autofill_manager_delegate) 159 if (autofill_manager_delegate)
160 InitAutofillIfNecessary(autofill_manager_delegate->GetSaveFormData()); 160 InitAutofillIfNecessary(autofill_manager_delegate->GetSaveFormData());
161 } 161 }
162 162
163 void AwContents::SetSaveFormData(bool enabled) { 163 void AwContents::SetSaveFormData(bool enabled) {
164 InitAutofillIfNecessary(enabled); 164 InitAutofillIfNecessary(enabled);
165 // We need to check for the existence, since autofill_manager_delegate 165 // We need to check for the existence, since autofill_manager_delegate
166 // may not be created when the setting is false. 166 // may not be created when the setting is false.
167 if (AutofillManager::FromWebContents(web_contents_.get())) { 167 if (AutofillDriverImpl::FromWebContents(web_contents_.get())) {
168 AwAutofillManagerDelegate* autofill_manager_delegate = 168 AwAutofillManagerDelegate* autofill_manager_delegate =
169 AwBrowserContext::FromWebContents(web_contents_.get())-> 169 AwBrowserContext::FromWebContents(web_contents_.get())->
170 AutofillManagerDelegate(); 170 AutofillManagerDelegate();
171 autofill_manager_delegate->SetSaveFormData(enabled); 171 autofill_manager_delegate->SetSaveFormData(enabled);
172 } 172 }
173 } 173 }
174 174
175 void AwContents::InitAutofillIfNecessary(bool enabled) { 175 void AwContents::InitAutofillIfNecessary(bool enabled) {
176 // Do not initialize if the feature is not enabled. 176 // Do not initialize if the feature is not enabled.
177 if (!enabled) 177 if (!enabled)
178 return; 178 return;
179 // Check if the autofill manager already exists. 179 // Check if the autofill manager already exists.
180 content::WebContents* web_contents = web_contents_.get(); 180 content::WebContents* web_contents = web_contents_.get();
181 if (AutofillManager::FromWebContents(web_contents)) 181 if (AutofillDriverImpl::FromWebContents(web_contents))
182 return; 182 return;
183 183
184 AutofillManager::CreateForWebContentsAndDelegate( 184 AutofillDriverImpl::CreateForWebContentsAndDelegate(
185 web_contents, 185 web_contents,
186 AwBrowserContext::FromWebContents(web_contents)-> 186 AwBrowserContext::FromWebContents(web_contents)->
187 CreateAutofillManagerDelegate(enabled), 187 CreateAutofillManagerDelegate(enabled),
188 l10n_util::GetDefaultLocale(), 188 l10n_util::GetDefaultLocale(),
189 AutofillManager::DISABLE_AUTOFILL_DOWNLOAD_MANAGER); 189 AutofillManager::DISABLE_AUTOFILL_DOWNLOAD_MANAGER,
190 AutofillManager* autofill_manager = 190 true);
191 AutofillManager::FromWebContents(web_contents);
192 AutofillExternalDelegate::CreateForWebContentsAndManager(
193 web_contents,
194 autofill_manager);
195 autofill_manager->SetExternalDelegate(
196 AutofillExternalDelegate::FromWebContents(web_contents));
197 } 191 }
198 192
199 void AwContents::SetWebContents(JNIEnv* env, jobject obj, jint new_wc) { 193 void AwContents::SetWebContents(JNIEnv* env, jobject obj, jint new_wc) {
200 SetWebContents(reinterpret_cast<content::WebContents*>(new_wc)); 194 SetWebContents(reinterpret_cast<content::WebContents*>(new_wc));
201 } 195 }
202 196
203 AwContents::~AwContents() { 197 AwContents::~AwContents() {
204 DCHECK(AwContents::FromWebContents(web_contents_.get()) == this); 198 DCHECK(AwContents::FromWebContents(web_contents_.get()) == this);
205 web_contents_->RemoveUserData(kAwContentsUserDataKey); 199 web_contents_->RemoveUserData(kAwContentsUserDataKey);
206 if (find_helper_.get()) 200 if (find_helper_.get())
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 return browser_view_renderer_->CapturePicture(); 704 return browser_view_renderer_->CapturePicture();
711 } 705 }
712 706
713 void AwContents::EnableOnNewPicture(JNIEnv* env, 707 void AwContents::EnableOnNewPicture(JNIEnv* env,
714 jobject obj, 708 jobject obj,
715 jboolean enabled) { 709 jboolean enabled) {
716 browser_view_renderer_->EnableOnNewPicture(enabled); 710 browser_view_renderer_->EnableOnNewPicture(enabled);
717 } 711 }
718 712
719 } // namespace android_webview 713 } // namespace android_webview
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698