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 <android/bitmap.h> | 7 #include <android/bitmap.h> |
8 #include <sys/system_properties.h> | 8 #include <sys/system_properties.h> |
9 | 9 |
10 #include "android_webview/browser/aw_browser_context.h" | 10 #include "android_webview/browser/aw_browser_context.h" |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
208 SetWebContents(reinterpret_cast<content::WebContents*>(new_wc)); | 208 SetWebContents(reinterpret_cast<content::WebContents*>(new_wc)); |
209 } | 209 } |
210 | 210 |
211 AwContents::~AwContents() { | 211 AwContents::~AwContents() { |
212 DCHECK(AwContents::FromWebContents(web_contents_.get()) == this); | 212 DCHECK(AwContents::FromWebContents(web_contents_.get()) == this); |
213 web_contents_->RemoveUserData(kAwContentsUserDataKey); | 213 web_contents_->RemoveUserData(kAwContentsUserDataKey); |
214 if (find_helper_.get()) | 214 if (find_helper_.get()) |
215 find_helper_->SetListener(NULL); | 215 find_helper_->SetListener(NULL); |
216 if (icon_helper_.get()) | 216 if (icon_helper_.get()) |
217 icon_helper_->SetListener(NULL); | 217 icon_helper_->SetListener(NULL); |
218 geolocation_callbacks_.clear(); | |
218 } | 219 } |
219 | 220 |
220 void AwContents::DrawGL(AwDrawGLInfo* draw_info) { | 221 void AwContents::DrawGL(AwDrawGLInfo* draw_info) { |
221 | 222 |
222 TRACE_EVENT0("AwContents", "AwContents::DrawGL"); | 223 TRACE_EVENT0("AwContents", "AwContents::DrawGL"); |
223 | 224 |
224 if (view_size_.IsEmpty() || !scissor_clip_layer_ || | 225 if (view_size_.IsEmpty() || !scissor_clip_layer_ || |
225 draw_info->mode == AwDrawGLInfo::kModeProcess) | 226 draw_info->mode == AwDrawGLInfo::kModeProcess) |
226 return; | 227 return; |
227 | 228 |
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
704 jobject obj, | 705 jobject obj, |
705 jobject web_contents_delegate) { | 706 jobject web_contents_delegate) { |
706 AwContents* tab = new AwContents(env, obj, web_contents_delegate); | 707 AwContents* tab = new AwContents(env, obj, web_contents_delegate); |
707 return reinterpret_cast<jint>(tab); | 708 return reinterpret_cast<jint>(tab); |
708 } | 709 } |
709 | 710 |
710 bool RegisterAwContents(JNIEnv* env) { | 711 bool RegisterAwContents(JNIEnv* env) { |
711 return RegisterNativesImpl(env) >= 0; | 712 return RegisterNativesImpl(env) >= 0; |
712 } | 713 } |
713 | 714 |
714 void AwContents::OnGeolocationShowPrompt(int render_process_id, | 715 namespace { |
715 int render_view_id, | 716 |
716 int bridge_id, | 717 void GeolocationShowPrompt( |
717 const GURL& requesting_frame) { | 718 JavaObjectWeakGlobalRef java_ref, const GURL& origin) { |
benm (inactive)
2013/02/07 17:22:39
nit: one param per line for function definitions/d
Kristian Monsen
2013/02/08 00:07:44
Done.
| |
718 JNIEnv* env = AttachCurrentThread(); | 719 JNIEnv* env = AttachCurrentThread(); |
719 ScopedJavaLocalRef<jstring> j_requesting_frame( | 720 ScopedJavaLocalRef<jstring> j_origin( |
720 ConvertUTF8ToJavaString(env, requesting_frame.spec())); | 721 ConvertUTF8ToJavaString(env,origin.spec())); |
721 Java_AwContents_onGeolocationPermissionsShowPrompt(env, | 722 Java_AwContents_onGeolocationPermissionsShowPrompt( |
722 java_ref_.get(env).obj(), render_process_id, render_view_id, bridge_id, | 723 env, java_ref.get(env).obj(), j_origin.obj()); |
723 j_requesting_frame.obj()); | |
724 } | 724 } |
725 | 725 |
726 void AwContents::OnGeolocationHidePrompt() { | 726 } // anonymous namespace |
727 // TODO(kristianm): Implement this | 727 |
728 void AwContents::OnGeolocationShowPrompt( | |
729 const GURL& requesting_frame, base::Callback<void(bool)> callback) { | |
730 const GURL& origin = requesting_frame.GetOrigin(); | |
731 bool show_prompt = geolocation_callbacks_.empty(); | |
732 geolocation_callbacks_.push_back(OriginCallback(origin, callback)); | |
733 if (show_prompt) { | |
734 GeolocationShowPrompt(java_ref_, origin); | |
735 } | |
736 } | |
737 | |
738 void AwContents::InvokeGeolocationCallback( | |
739 JNIEnv* env, jobject obj, jboolean value, jstring origin) { | |
740 GURL callback_origin(base::android::ConvertJavaStringToUTF16(env, origin)); | |
741 if (callback_origin.GetOrigin() == geolocation_callbacks_.front().first) { | |
742 geolocation_callbacks_.front().second.Run(value); | |
743 geolocation_callbacks_.pop_front(); | |
744 if (!geolocation_callbacks_.empty()) { | |
745 GeolocationShowPrompt(java_ref_, geolocation_callbacks_.front().first); | |
746 } | |
747 } | |
748 } | |
749 | |
750 void AwContents::OnGeolocationHidePrompt(const GURL& origin) { | |
751 std::list<OriginCallback>::iterator it = geolocation_callbacks_.begin(); | |
752 bool removed_current_outstanding_callback = false; | |
753 for ( ; it != geolocation_callbacks_.end(); ) { | |
754 if ((*it).first == origin.GetOrigin()) { | |
755 it = geolocation_callbacks_.erase(it); | |
756 if (it == geolocation_callbacks_.begin()) { | |
757 removed_current_outstanding_callback = true; | |
758 } | |
759 } else { | |
760 it++; | |
761 } | |
762 } | |
763 if (removed_current_outstanding_callback) { | |
764 JNIEnv* env = AttachCurrentThread(); | |
765 Java_AwContents_onGeolocationPermissionsHidePrompt( | |
766 env, java_ref_.get(env).obj()); | |
767 if (!geolocation_callbacks_.empty()) { | |
768 GeolocationShowPrompt( | |
769 java_ref_, geolocation_callbacks_.front().first); | |
770 } | |
771 } | |
728 } | 772 } |
729 | 773 |
730 jint AwContents::FindAllSync(JNIEnv* env, jobject obj, jstring search_string) { | 774 jint AwContents::FindAllSync(JNIEnv* env, jobject obj, jstring search_string) { |
731 return GetFindHelper()->FindAllSync( | 775 return GetFindHelper()->FindAllSync( |
732 ConvertJavaStringToUTF16(env, search_string)); | 776 ConvertJavaStringToUTF16(env, search_string)); |
733 } | 777 } |
734 | 778 |
735 void AwContents::FindAllAsync(JNIEnv* env, jobject obj, jstring search_string) { | 779 void AwContents::FindAllAsync(JNIEnv* env, jobject obj, jstring search_string) { |
736 GetFindHelper()->FindAllAsync(ConvertJavaStringToUTF16(env, search_string)); | 780 GetFindHelper()->FindAllAsync(ConvertJavaStringToUTF16(env, search_string)); |
737 } | 781 } |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1076 if (!picture) { | 1120 if (!picture) { |
1077 render_view_host_ext_->CapturePictureSync(); | 1121 render_view_host_ext_->CapturePictureSync(); |
1078 picture = RendererPictureMap::GetInstance()->GetRendererPicture( | 1122 picture = RendererPictureMap::GetInstance()->GetRendererPicture( |
1079 web_contents_->GetRoutingID()); | 1123 web_contents_->GetRoutingID()); |
1080 } | 1124 } |
1081 | 1125 |
1082 return picture; | 1126 return picture; |
1083 } | 1127 } |
1084 | 1128 |
1085 } // namespace android_webview | 1129 } // namespace android_webview |
OLD | NEW |