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_main_parts.h" | 10 #include "android_webview/browser/aw_browser_main_parts.h" |
11 #include "android_webview/browser/aw_content_browser_client.h" | |
10 #include "android_webview/browser/net_disk_cache_remover.h" | 12 #include "android_webview/browser/net_disk_cache_remover.h" |
11 #include "android_webview/browser/renderer_host/aw_render_view_host_ext.h" | 13 #include "android_webview/browser/renderer_host/aw_render_view_host_ext.h" |
12 #include "android_webview/browser/renderer_host/aw_resource_dispatcher_host_dele gate.h" | 14 #include "android_webview/browser/renderer_host/aw_resource_dispatcher_host_dele gate.h" |
13 #include "android_webview/common/aw_hit_test_data.h" | 15 #include "android_webview/common/aw_hit_test_data.h" |
14 #include "android_webview/native/aw_browser_dependency_factory.h" | 16 #include "android_webview/native/aw_browser_dependency_factory.h" |
15 #include "android_webview/native/aw_contents_io_thread_client_impl.h" | 17 #include "android_webview/native/aw_contents_io_thread_client_impl.h" |
16 #include "android_webview/native/aw_web_contents_delegate.h" | 18 #include "android_webview/native/aw_web_contents_delegate.h" |
17 #include "android_webview/native/state_serializer.h" | 19 #include "android_webview/native/state_serializer.h" |
18 #include "android_webview/public/browser/draw_sw.h" | 20 #include "android_webview/public/browser/draw_sw.h" |
19 #include "base/android/jni_android.h" | 21 #include "base/android/jni_android.h" |
20 #include "base/android/jni_array.h" | 22 #include "base/android/jni_array.h" |
21 #include "base/android/jni_string.h" | 23 #include "base/android/jni_string.h" |
22 #include "base/bind.h" | 24 #include "base/bind.h" |
23 #include "base/callback.h" | 25 #include "base/callback.h" |
24 #include "base/debug/trace_event.h" | 26 #include "base/debug/trace_event.h" |
25 #include "base/message_loop.h" | 27 #include "base/message_loop.h" |
26 #include "base/pickle.h" | 28 #include "base/pickle.h" |
27 #include "base/supports_user_data.h" | 29 #include "base/supports_user_data.h" |
28 #include "cc/layer.h" | 30 #include "cc/layer.h" |
29 #include "content/components/navigation_interception/intercept_navigation_delega te.h" | 31 #include "content/components/navigation_interception/intercept_navigation_delega te.h" |
30 #include "content/public/browser/android/content_view_core.h" | 32 #include "content/public/browser/android/content_view_core.h" |
33 #include "content/public/browser/browser_context.h" | |
31 #include "content/public/browser/browser_thread.h" | 34 #include "content/public/browser/browser_thread.h" |
32 #include "content/public/browser/cert_store.h" | 35 #include "content/public/browser/cert_store.h" |
33 #include "content/public/browser/navigation_entry.h" | 36 #include "content/public/browser/navigation_entry.h" |
34 #include "content/public/browser/render_process_host.h" | 37 #include "content/public/browser/render_process_host.h" |
35 #include "content/public/browser/web_contents.h" | 38 #include "content/public/browser/web_contents.h" |
36 #include "content/public/common/ssl_status.h" | 39 #include "content/public/common/ssl_status.h" |
37 #include "jni/AwContents_jni.h" | 40 #include "jni/AwContents_jni.h" |
38 #include "net/base/x509_certificate.h" | 41 #include "net/base/x509_certificate.h" |
39 #include "third_party/skia/include/core/SkBitmap.h" | 42 #include "third_party/skia/include/core/SkBitmap.h" |
40 #include "third_party/skia/include/core/SkCanvas.h" | 43 #include "third_party/skia/include/core/SkCanvas.h" |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
159 is_composite_pending_(false), | 162 is_composite_pending_(false), |
160 last_scroll_x_(0), last_scroll_y_(0), | 163 last_scroll_x_(0), last_scroll_y_(0), |
161 last_frame_context_(NULL) { | 164 last_frame_context_(NULL) { |
162 android_webview::AwBrowserDependencyFactory* dependency_factory = | 165 android_webview::AwBrowserDependencyFactory* dependency_factory = |
163 android_webview::AwBrowserDependencyFactory::GetInstance(); | 166 android_webview::AwBrowserDependencyFactory::GetInstance(); |
164 | 167 |
165 // TODO(joth): rather than create and set the WebContents here, expose the | 168 // TODO(joth): rather than create and set the WebContents here, expose the |
166 // factory method to java side and have that orchestrate the construction | 169 // factory method to java side and have that orchestrate the construction |
167 // order. | 170 // order. |
168 SetWebContents(dependency_factory->CreateWebContents(private_browsing)); | 171 SetWebContents(dependency_factory->CreateWebContents(private_browsing)); |
172 | |
173 if (!web_contents_->GetBrowserContext()->GetGeolocationPermissionContext()) { | |
174 // TODO(kristianm): This is evil, look for another way out | |
175 AwBrowserContext* aw_browser_context = | |
176 static_cast<AwContentBrowserClient*>( | |
177 content::GetContentClient()->browser())->GetAwBrowserContext(); | |
178 if (aw_browser_context) | |
179 aw_browser_context->set_geolocation_permissions_context( | |
boliu
2013/01/03 08:14:38
BrowserContext outlives AwContents, it's equivalen
Kristian Monsen
2013/01/03 08:37:58
I just need some place in native/ to construct thi
boliu
2013/01/03 08:48:35
AwMainDelegate is in lib/ which can include native
Kristian Monsen
2013/01/04 06:14:21
Passed it in the ctor to AwContentBrowserClient.
| |
180 new AwGeolocationPermissionContext()); | |
181 } | |
169 } | 182 } |
170 | 183 |
171 void AwContents::ResetCompositor() { | 184 void AwContents::ResetCompositor() { |
172 if (UseCompositorDirectDraw()) { | 185 if (UseCompositorDirectDraw()) { |
173 compositor_.reset(content::Compositor::Create(this)); | 186 compositor_.reset(content::Compositor::Create(this)); |
174 if (scissor_clip_layer_.get()) | 187 if (scissor_clip_layer_.get()) |
175 AttachLayerTree(); | 188 AttachLayerTree(); |
176 } else { | 189 } else { |
177 LOG(WARNING) << "Running on unsupported device: using null Compositor"; | 190 LOG(WARNING) << "Running on unsupported device: using null Compositor"; |
178 compositor_.reset(new NullCompositor); | 191 compositor_.reset(new NullCompositor); |
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
640 jboolean private_browsing) { | 653 jboolean private_browsing) { |
641 AwContents* tab = new AwContents(env, obj, web_contents_delegate, | 654 AwContents* tab = new AwContents(env, obj, web_contents_delegate, |
642 private_browsing); | 655 private_browsing); |
643 return reinterpret_cast<jint>(tab); | 656 return reinterpret_cast<jint>(tab); |
644 } | 657 } |
645 | 658 |
646 bool RegisterAwContents(JNIEnv* env) { | 659 bool RegisterAwContents(JNIEnv* env) { |
647 return RegisterNativesImpl(env) >= 0; | 660 return RegisterNativesImpl(env) >= 0; |
648 } | 661 } |
649 | 662 |
663 void AwContents::GeolocationShowPrompt(int render_process_id, | |
664 int render_view_id, | |
665 int bridge_id, | |
666 const GURL& requesting_frame) { | |
667 JNIEnv* env = AttachCurrentThread(); | |
668 ScopedJavaLocalRef<jstring> j_requesting_frame( | |
669 ConvertUTF8ToJavaString(env, requesting_frame.spec())); | |
670 Java_AwContents_onGeolocationPermissionsShowPrompt(env, | |
671 java_ref_.get(env).obj(), render_process_id, render_view_id, bridge_id, | |
672 j_requesting_frame.obj()); | |
673 } | |
674 | |
675 void AwContents::GeolocationHidePrompt() { | |
676 } | |
677 | |
650 jint AwContents::FindAllSync(JNIEnv* env, jobject obj, jstring search_string) { | 678 jint AwContents::FindAllSync(JNIEnv* env, jobject obj, jstring search_string) { |
651 return GetFindHelper()->FindAllSync( | 679 return GetFindHelper()->FindAllSync( |
652 ConvertJavaStringToUTF16(env, search_string)); | 680 ConvertJavaStringToUTF16(env, search_string)); |
653 } | 681 } |
654 | 682 |
655 void AwContents::FindAllAsync(JNIEnv* env, jobject obj, jstring search_string) { | 683 void AwContents::FindAllAsync(JNIEnv* env, jobject obj, jstring search_string) { |
656 GetFindHelper()->FindAllAsync(ConvertJavaStringToUTF16(env, search_string)); | 684 GetFindHelper()->FindAllAsync(ConvertJavaStringToUTF16(env, search_string)); |
657 } | 685 } |
658 | 686 |
659 void AwContents::FindNext(JNIEnv* env, jobject obj, jboolean forward) { | 687 void AwContents::FindNext(JNIEnv* env, jobject obj, jboolean forward) { |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
860 | 888 |
861 void AwContents::FocusFirstNode(JNIEnv* env, jobject obj) { | 889 void AwContents::FocusFirstNode(JNIEnv* env, jobject obj) { |
862 web_contents_->FocusThroughTabTraversal(false); | 890 web_contents_->FocusThroughTabTraversal(false); |
863 } | 891 } |
864 | 892 |
865 jint AwContents::ReleasePopupWebContents(JNIEnv* env, jobject obj) { | 893 jint AwContents::ReleasePopupWebContents(JNIEnv* env, jobject obj) { |
866 return reinterpret_cast<jint>(pending_contents_.release()); | 894 return reinterpret_cast<jint>(pending_contents_.release()); |
867 } | 895 } |
868 | 896 |
869 } // namespace android_webview | 897 } // namespace android_webview |
OLD | NEW |