| OLD | NEW |
| 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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 new InProcessViewRenderer(this, java_renderer_helper(), | 128 new InProcessViewRenderer(this, java_renderer_helper(), |
| 129 web_contents_.get())) { | 129 web_contents_.get())) { |
| 130 icon_helper_.reset(new IconHelper(web_contents_.get())); | 130 icon_helper_.reset(new IconHelper(web_contents_.get())); |
| 131 icon_helper_->SetListener(this); | 131 icon_helper_->SetListener(this); |
| 132 web_contents_->SetUserData(kAwContentsUserDataKey, | 132 web_contents_->SetUserData(kAwContentsUserDataKey, |
| 133 new AwContentsUserData(this)); | 133 new AwContentsUserData(this)); |
| 134 render_view_host_ext_.reset( | 134 render_view_host_ext_.reset( |
| 135 new AwRenderViewHostExt(this, web_contents_.get())); | 135 new AwRenderViewHostExt(this, web_contents_.get())); |
| 136 | 136 |
| 137 AwAutofillManagerDelegate* autofill_manager_delegate = | 137 AwAutofillManagerDelegate* autofill_manager_delegate = |
| 138 AwBrowserContext::FromWebContents(web_contents_.get())-> | 138 AwAutofillManagerDelegate::FromWebContents(web_contents_.get()); |
| 139 AutofillManagerDelegate(); | |
| 140 if (autofill_manager_delegate) | 139 if (autofill_manager_delegate) |
| 141 InitAutofillIfNecessary(autofill_manager_delegate->GetSaveFormData()); | 140 InitAutofillIfNecessary(autofill_manager_delegate->GetSaveFormData()); |
| 142 } | 141 } |
| 143 | 142 |
| 144 void AwContents::SetJavaPeers(JNIEnv* env, | 143 void AwContents::SetJavaPeers(JNIEnv* env, |
| 145 jobject obj, | 144 jobject obj, |
| 146 jobject aw_contents, | 145 jobject aw_contents, |
| 147 jobject web_contents_delegate, | 146 jobject web_contents_delegate, |
| 148 jobject contents_client_bridge, | 147 jobject contents_client_bridge, |
| 149 jobject io_thread_client, | 148 jobject io_thread_client, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 173 web_contents_.get(), | 172 web_contents_.get(), |
| 174 make_scoped_ptr(new InterceptNavigationDelegate( | 173 make_scoped_ptr(new InterceptNavigationDelegate( |
| 175 env, intercept_navigation_delegate))); | 174 env, intercept_navigation_delegate))); |
| 176 } | 175 } |
| 177 | 176 |
| 178 void AwContents::SetSaveFormData(bool enabled) { | 177 void AwContents::SetSaveFormData(bool enabled) { |
| 179 InitAutofillIfNecessary(enabled); | 178 InitAutofillIfNecessary(enabled); |
| 180 // We need to check for the existence, since autofill_manager_delegate | 179 // We need to check for the existence, since autofill_manager_delegate |
| 181 // may not be created when the setting is false. | 180 // may not be created when the setting is false. |
| 182 if (AutofillDriverImpl::FromWebContents(web_contents_.get())) { | 181 if (AutofillDriverImpl::FromWebContents(web_contents_.get())) { |
| 183 AwAutofillManagerDelegate* autofill_manager_delegate = | 182 AwAutofillManagerDelegate::FromWebContents(web_contents_.get())-> |
| 184 AwBrowserContext::FromWebContents(web_contents_.get())-> | 183 SetSaveFormData(enabled); |
| 185 AutofillManagerDelegate(); | |
| 186 autofill_manager_delegate->SetSaveFormData(enabled); | |
| 187 } | 184 } |
| 188 } | 185 } |
| 189 | 186 |
| 190 void AwContents::InitAutofillIfNecessary(bool enabled) { | 187 void AwContents::InitAutofillIfNecessary(bool enabled) { |
| 191 // Do not initialize if the feature is not enabled. | 188 // Do not initialize if the feature is not enabled. |
| 192 if (!enabled) | 189 if (!enabled) |
| 193 return; | 190 return; |
| 194 // Check if the autofill manager already exists. | 191 // Check if the autofill manager already exists. |
| 195 content::WebContents* web_contents = web_contents_.get(); | 192 content::WebContents* web_contents = web_contents_.get(); |
| 196 if (AutofillDriverImpl::FromWebContents(web_contents)) | 193 if (AutofillDriverImpl::FromWebContents(web_contents)) |
| 197 return; | 194 return; |
| 198 | 195 |
| 196 AwBrowserContext::FromWebContents(web_contents)-> |
| 197 CreateUserPrefServiceIfNecessary(); |
| 198 AwAutofillManagerDelegate::CreateForWebContents(web_contents); |
| 199 AutofillDriverImpl::CreateForWebContentsAndDelegate( | 199 AutofillDriverImpl::CreateForWebContentsAndDelegate( |
| 200 web_contents, | 200 web_contents, |
| 201 AwBrowserContext::FromWebContents(web_contents)-> | 201 AwAutofillManagerDelegate::FromWebContents(web_contents), |
| 202 CreateAutofillManagerDelegate(enabled), | |
| 203 l10n_util::GetDefaultLocale(), | 202 l10n_util::GetDefaultLocale(), |
| 204 AutofillManager::DISABLE_AUTOFILL_DOWNLOAD_MANAGER, | 203 AutofillManager::DISABLE_AUTOFILL_DOWNLOAD_MANAGER, |
| 205 true); | 204 true); |
| 206 } | 205 } |
| 207 | 206 |
| 208 AwContents::~AwContents() { | 207 AwContents::~AwContents() { |
| 209 DCHECK(AwContents::FromWebContents(web_contents_.get()) == this); | 208 DCHECK(AwContents::FromWebContents(web_contents_.get()) == this); |
| 210 web_contents_->RemoveUserData(kAwContentsUserDataKey); | 209 web_contents_->RemoveUserData(kAwContentsUserDataKey); |
| 211 if (find_helper_.get()) | 210 if (find_helper_.get()) |
| 212 find_helper_->SetListener(NULL); | 211 find_helper_->SetListener(NULL); |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 689 return browser_view_renderer_->CapturePicture(); | 688 return browser_view_renderer_->CapturePicture(); |
| 690 } | 689 } |
| 691 | 690 |
| 692 void AwContents::EnableOnNewPicture(JNIEnv* env, | 691 void AwContents::EnableOnNewPicture(JNIEnv* env, |
| 693 jobject obj, | 692 jobject obj, |
| 694 jboolean enabled) { | 693 jboolean enabled) { |
| 695 browser_view_renderer_->EnableOnNewPicture(enabled); | 694 browser_view_renderer_->EnableOnNewPicture(enabled); |
| 696 } | 695 } |
| 697 | 696 |
| 698 } // namespace android_webview | 697 } // namespace android_webview |
| OLD | NEW |