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 <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 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 720 jobject obj, | 720 jobject obj, |
| 721 jobject web_contents_delegate) { | 721 jobject web_contents_delegate) { |
| 722 AwContents* tab = new AwContents(env, obj, web_contents_delegate); | 722 AwContents* tab = new AwContents(env, obj, web_contents_delegate); |
| 723 return reinterpret_cast<jint>(tab); | 723 return reinterpret_cast<jint>(tab); |
| 724 } | 724 } |
| 725 | 725 |
| 726 bool RegisterAwContents(JNIEnv* env) { | 726 bool RegisterAwContents(JNIEnv* env) { |
| 727 return RegisterNativesImpl(env) >= 0; | 727 return RegisterNativesImpl(env) >= 0; |
| 728 } | 728 } |
| 729 | 729 |
| 730 void AwContents::OnGeolocationShowPrompt(int render_process_id, | 730 namespace { |
| 731 int render_view_id, | 731 |
| 732 int bridge_id, | 732 void GeolocationShowPrompt(JavaObjectWeakGlobalRef java_ref, |
| 733 const GURL& requesting_frame) { | 733 const GURL& origin) { |
| 734 JNIEnv* env = AttachCurrentThread(); | 734 JNIEnv* env = AttachCurrentThread(); |
| 735 ScopedJavaLocalRef<jstring> j_requesting_frame( | 735 ScopedJavaLocalRef<jstring> j_origin( |
| 736 ConvertUTF8ToJavaString(env, requesting_frame.spec())); | 736 ConvertUTF8ToJavaString(env,origin.spec())); |
|
joth
2013/02/08 02:15:01
nit: space after comma
Kristian Monsen
2013/02/12 18:53:03
Done.
| |
| 737 Java_AwContents_onGeolocationPermissionsShowPrompt(env, | 737 Java_AwContents_onGeolocationPermissionsShowPrompt(env, |
| 738 java_ref_.get(env).obj(), render_process_id, render_view_id, bridge_id, | 738 java_ref.get(env).obj(), |
| 739 j_requesting_frame.obj()); | 739 j_origin.obj()); |
| 740 } | 740 } |
| 741 | 741 |
| 742 void AwContents::OnGeolocationHidePrompt() { | 742 } // anonymous namespace |
| 743 // TODO(kristianm): Implement this | 743 |
| 744 void AwContents::OnGeolocationShowPrompt(const GURL& requesting_frame, | |
| 745 base::Callback<void(bool)> callback) { | |
| 746 const GURL& origin = requesting_frame.GetOrigin(); | |
| 747 bool show_prompt = geolocation_callbacks_.empty(); | |
| 748 geolocation_callbacks_.push_back(OriginCallback(origin, callback)); | |
| 749 if (show_prompt) { | |
| 750 GeolocationShowPrompt(java_ref_, origin); | |
| 751 } | |
| 752 } | |
| 753 | |
| 754 void AwContents::InvokeGeolocationCallback(JNIEnv* env, | |
| 755 jobject obj, | |
| 756 jboolean value, | |
| 757 jstring origin) { | |
| 758 GURL callback_origin(base::android::ConvertJavaStringToUTF16(env, origin)); | |
| 759 if (callback_origin.GetOrigin() == geolocation_callbacks_.front().first) { | |
| 760 geolocation_callbacks_.front().second.Run(value); | |
| 761 geolocation_callbacks_.pop_front(); | |
| 762 if (!geolocation_callbacks_.empty()) { | |
| 763 GeolocationShowPrompt(java_ref_, geolocation_callbacks_.front().first); | |
|
joth
2013/02/08 02:15:01
this could create a callstack as deep as the numbe
Kristian Monsen
2013/02/12 18:53:03
Converted showprompt into a task, that actually fo
| |
| 764 } | |
| 765 } | |
| 766 } | |
| 767 | |
| 768 void AwContents::OnGeolocationHidePrompt(const GURL& origin) { | |
| 769 bool removed_current_outstanding_callback = false; | |
| 770 std::list<OriginCallback>::iterator it = geolocation_callbacks_.begin(); | |
| 771 for ( ; it != geolocation_callbacks_.end(); ) { | |
|
joth
2013/02/08 02:15:01
This construct has it's very own special syntax:
Kristian Monsen
2013/02/12 18:53:03
Done.
| |
| 772 if ((*it).first == origin.GetOrigin()) { | |
| 773 it = geolocation_callbacks_.erase(it); | |
| 774 if (it == geolocation_callbacks_.begin()) { | |
|
joth
2013/02/08 02:15:01
you still need to make this check *prior* to updat
Kristian Monsen
2013/02/12 18:53:03
I think it should fine, I did think of that. For t
| |
| 775 removed_current_outstanding_callback = true; | |
| 776 } | |
| 777 } else { | |
| 778 it++; | |
| 779 } | |
| 780 } | |
| 781 | |
| 782 if (removed_current_outstanding_callback) { | |
| 783 JNIEnv* env = AttachCurrentThread(); | |
| 784 Java_AwContents_onGeolocationPermissionsHidePrompt( | |
| 785 env, | |
| 786 java_ref_.get(env).obj()); | |
| 787 if (!geolocation_callbacks_.empty()) { | |
| 788 GeolocationShowPrompt(java_ref_, | |
| 789 geolocation_callbacks_.front().first); | |
| 790 } | |
| 791 } | |
| 744 } | 792 } |
| 745 | 793 |
| 746 jint AwContents::FindAllSync(JNIEnv* env, jobject obj, jstring search_string) { | 794 jint AwContents::FindAllSync(JNIEnv* env, jobject obj, jstring search_string) { |
| 747 return GetFindHelper()->FindAllSync( | 795 return GetFindHelper()->FindAllSync( |
| 748 ConvertJavaStringToUTF16(env, search_string)); | 796 ConvertJavaStringToUTF16(env, search_string)); |
| 749 } | 797 } |
| 750 | 798 |
| 751 void AwContents::FindAllAsync(JNIEnv* env, jobject obj, jstring search_string) { | 799 void AwContents::FindAllAsync(JNIEnv* env, jobject obj, jstring search_string) { |
| 752 GetFindHelper()->FindAllAsync(ConvertJavaStringToUTF16(env, search_string)); | 800 GetFindHelper()->FindAllAsync(ConvertJavaStringToUTF16(env, search_string)); |
| 753 } | 801 } |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1095 if (!picture) { | 1143 if (!picture) { |
| 1096 render_view_host_ext_->CapturePictureSync(); | 1144 render_view_host_ext_->CapturePictureSync(); |
| 1097 picture = RendererPictureMap::GetInstance()->GetRendererPicture( | 1145 picture = RendererPictureMap::GetInstance()->GetRendererPicture( |
| 1098 web_contents_->GetRoutingID()); | 1146 web_contents_->GetRoutingID()); |
| 1099 } | 1147 } |
| 1100 | 1148 |
| 1101 return picture; | 1149 return picture; |
| 1102 } | 1150 } |
| 1103 | 1151 |
| 1104 } // namespace android_webview | 1152 } // namespace android_webview |
| OLD | NEW |