Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 <sys/system_properties.h> | 7 #include <sys/system_properties.h> |
| 8 | 8 |
| 9 #include "android_webview/browser/aw_browser_context.h" | 9 #include "android_webview/browser/aw_browser_context.h" |
| 10 #include "android_webview/browser/aw_browser_main_parts.h" | 10 #include "android_webview/browser/aw_browser_main_parts.h" |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 28 #include "base/pickle.h" | 28 #include "base/pickle.h" |
| 29 #include "base/string16.h" | 29 #include "base/string16.h" |
| 30 #include "base/supports_user_data.h" | 30 #include "base/supports_user_data.h" |
| 31 #include "cc/layer.h" | 31 #include "cc/layer.h" |
| 32 #include "components/navigation_interception/intercept_navigation_delegate.h" | 32 #include "components/navigation_interception/intercept_navigation_delegate.h" |
| 33 #include "content/public/browser/android/content_view_core.h" | 33 #include "content/public/browser/android/content_view_core.h" |
| 34 #include "content/public/browser/browser_thread.h" | 34 #include "content/public/browser/browser_thread.h" |
| 35 #include "content/public/browser/cert_store.h" | 35 #include "content/public/browser/cert_store.h" |
| 36 #include "content/public/browser/navigation_entry.h" | 36 #include "content/public/browser/navigation_entry.h" |
| 37 #include "content/public/browser/render_process_host.h" | 37 #include "content/public/browser/render_process_host.h" |
| 38 #include "content/public/browser/render_view_host.h" | |
| 38 #include "content/public/browser/web_contents.h" | 39 #include "content/public/browser/web_contents.h" |
| 39 #include "content/public/common/ssl_status.h" | 40 #include "content/public/common/ssl_status.h" |
| 40 #include "jni/AwContents_jni.h" | 41 #include "jni/AwContents_jni.h" |
| 41 #include "net/base/x509_certificate.h" | 42 #include "net/base/x509_certificate.h" |
| 42 #include "skia/ext/refptr.h" | 43 #include "skia/ext/refptr.h" |
| 43 #include "third_party/skia/include/core/SkBitmap.h" | 44 #include "third_party/skia/include/core/SkBitmap.h" |
| 44 #include "third_party/skia/include/core/SkCanvas.h" | 45 #include "third_party/skia/include/core/SkCanvas.h" |
| 45 #include "third_party/skia/include/core/SkDevice.h" | 46 #include "third_party/skia/include/core/SkDevice.h" |
| 46 #include "third_party/skia/include/core/SkPicture.h" | 47 #include "third_party/skia/include/core/SkPicture.h" |
| 47 #include "ui/gfx/android/java_bitmap.h" | 48 #include "ui/gfx/android/java_bitmap.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 108 AwContents* contents_; | 109 AwContents* contents_; |
| 109 }; | 110 }; |
| 110 | 111 |
| 111 } // namespace | 112 } // namespace |
| 112 | 113 |
| 113 // static | 114 // static |
| 114 AwContents* AwContents::FromWebContents(WebContents* web_contents) { | 115 AwContents* AwContents::FromWebContents(WebContents* web_contents) { |
| 115 return AwContentsUserData::GetContents(web_contents); | 116 return AwContentsUserData::GetContents(web_contents); |
| 116 } | 117 } |
| 117 | 118 |
| 119 // static | |
| 120 // The implementation is here to provide isolation of the browser/ layer | |
| 121 // from the implementation details of native/ layer. | |
| 122 AwCertificateErrorHandlerBase* AwCertificateErrorHandlerBase::FromID( | |
| 123 int render_process_id, | |
| 124 int render_view_id) { | |
| 125 | |
| 126 const content::RenderViewHost* host = | |
|
mkosiba (inactive)
2013/02/04 12:51:31
uber nit: normally this is called the rvh, not hos
sgurun-gerrit only
2013/02/21 23:32:32
Done.
| |
| 127 content::RenderViewHost::FromID(render_process_id, render_view_id); | |
| 128 DCHECK(host); | |
|
mkosiba (inactive)
2013/02/04 12:51:31
please make this robust to NULLs. It's likely for
sgurun-gerrit only
2013/02/21 23:32:32
Done.
| |
| 129 content::WebContents* web_contents = | |
| 130 content::WebContents::FromRenderViewHost(host); | |
| 131 DCHECK(web_contents); | |
| 132 return static_cast<AwCertificateErrorHandlerBase*> | |
|
mkosiba (inactive)
2013/02/04 12:51:31
nit: I think the common pattern is to leave the op
sgurun-gerrit only
2013/02/21 23:32:32
Done.
| |
| 133 (AwContents::FromWebContents(web_contents)); | |
| 134 } | |
| 135 | |
| 118 AwContents::AwContents(JNIEnv* env, | 136 AwContents::AwContents(JNIEnv* env, |
| 119 jobject obj, | 137 jobject obj, |
| 120 jobject web_contents_delegate) | 138 jobject web_contents_delegate) |
| 121 : java_ref_(env, obj), | 139 : java_ref_(env, obj), |
| 122 web_contents_delegate_( | 140 web_contents_delegate_( |
| 123 new AwWebContentsDelegate(env, web_contents_delegate)), | 141 new AwWebContentsDelegate(env, web_contents_delegate)), |
| 124 view_visible_(false), | 142 view_visible_(false), |
| 125 compositor_visible_(false), | 143 compositor_visible_(false), |
| 126 is_composite_pending_(false), | 144 is_composite_pending_(false), |
| 127 last_frame_context_(NULL) { | 145 last_frame_context_(NULL) { |
| (...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 910 void AwContents::OnPictureUpdated(int process_id, int render_view_id) { | 928 void AwContents::OnPictureUpdated(int process_id, int render_view_id) { |
| 911 CHECK_EQ(web_contents_->GetRenderProcessHost()->GetID(), process_id); | 929 CHECK_EQ(web_contents_->GetRenderProcessHost()->GetID(), process_id); |
| 912 if (render_view_id != web_contents_->GetRoutingID()) | 930 if (render_view_id != web_contents_->GetRoutingID()) |
| 913 return; | 931 return; |
| 914 | 932 |
| 915 // TODO(leandrogracia): delete when sw rendering uses Ubercompositor. | 933 // TODO(leandrogracia): delete when sw rendering uses Ubercompositor. |
| 916 // Invalidation should be provided by the compositor only. | 934 // Invalidation should be provided by the compositor only. |
| 917 Invalidate(); | 935 Invalidate(); |
| 918 } | 936 } |
| 919 | 937 |
| 938 void AwContents::AllowCertificateError( | |
| 939 int cert_error, | |
| 940 net::X509Certificate* cert, | |
| 941 const GURL& request_url, | |
| 942 const base::Callback<void(bool)>& callback, | |
| 943 bool* cancel_request) { | |
| 944 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
| 945 JNIEnv* env = AttachCurrentThread(); | |
| 946 | |
| 947 std::string der_string; | |
| 948 net::X509Certificate::GetDEREncoded(cert->os_cert_handle(),&der_string); | |
| 949 ScopedJavaLocalRef<jbyteArray> jcert = base::android::ToJavaByteArray(env, | |
| 950 reinterpret_cast<const uint8*>(der_string.data()), der_string.length()); | |
| 951 ScopedJavaLocalRef<jstring> jurl(ConvertUTF8ToJavaString( | |
| 952 env, request_url.spec())); | |
| 953 ssl_error_callback_ = callback; | |
|
boliu
2013/02/02 03:51:29
Only save callback if cancel_request is false? But
mkosiba (inactive)
2013/02/04 12:51:31
IMO it would be helpful if we had a bridge from Ch
sgurun-gerrit only
2013/02/21 23:32:32
Makes sense. adding a bridge for the aw_content_c
sgurun-gerrit only
2013/02/21 23:32:32
we are now saving all the callbacks.
On 2013/02/0
| |
| 954 *cancel_request = Java_AwContents_cancelCertificateError(env, | |
| 955 java_ref_.get(env).obj(), reinterpret_cast<jint>(cert_error), jcert.obj(), | |
| 956 jurl.obj()); | |
| 957 } | |
| 958 | |
| 959 void AwContents::ProceedSslError(JNIEnv* env, jobject obj, jboolean proceed) { | |
| 960 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
| 961 if (ssl_error_callback_.is_null()) { | |
| 962 LOG(WARNING) << "Ignoring unexpected ssl error proceed callback"; | |
| 963 return; | |
| 964 } | |
| 965 ssl_error_callback_.Run(proceed); | |
| 966 ssl_error_callback_.Reset(); | |
| 967 } | |
| 968 | |
| 969 | |
| 920 } // namespace android_webview | 970 } // namespace android_webview |
| OLD | NEW |