Chromium Code Reviews| 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 "chrome/browser/android/tab_android.h" | 5 #include "chrome/browser/android/tab_android.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
| 10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 66 #include "content/public/browser/interstitial_page.h" | 66 #include "content/public/browser/interstitial_page.h" |
| 67 #include "content/public/browser/navigation_entry.h" | 67 #include "content/public/browser/navigation_entry.h" |
| 68 #include "content/public/browser/notification_service.h" | 68 #include "content/public/browser/notification_service.h" |
| 69 #include "content/public/browser/render_frame_host.h" | 69 #include "content/public/browser/render_frame_host.h" |
| 70 #include "content/public/browser/render_process_host.h" | 70 #include "content/public/browser/render_process_host.h" |
| 71 #include "content/public/browser/render_view_host.h" | 71 #include "content/public/browser/render_view_host.h" |
| 72 #include "content/public/browser/user_metrics.h" | 72 #include "content/public/browser/user_metrics.h" |
| 73 #include "content/public/browser/web_contents.h" | 73 #include "content/public/browser/web_contents.h" |
| 74 #include "content/public/common/browser_controls_state.h" | 74 #include "content/public/common/browser_controls_state.h" |
| 75 #include "content/public/common/resource_request_body.h" | 75 #include "content/public/common/resource_request_body.h" |
| 76 #include "content/public/common/web_preferences.h" | |
| 76 #include "jni/Tab_jni.h" | 77 #include "jni/Tab_jni.h" |
| 77 #include "net/base/escape.h" | 78 #include "net/base/escape.h" |
| 78 #include "skia/ext/image_operations.h" | 79 #include "skia/ext/image_operations.h" |
| 79 #include "third_party/WebKit/public/platform/WebReferrerPolicy.h" | 80 #include "third_party/WebKit/public/platform/WebReferrerPolicy.h" |
| 80 #include "ui/android/view_android.h" | 81 #include "ui/android/view_android.h" |
| 81 #include "ui/android/window_android.h" | 82 #include "ui/android/window_android.h" |
| 82 #include "ui/base/resource/resource_bundle.h" | 83 #include "ui/base/resource/resource_bundle.h" |
| 83 #include "ui/base/window_open_disposition.h" | 84 #include "ui/base/window_open_disposition.h" |
| 84 #include "ui/display/display.h" | 85 #include "ui/display/display.h" |
| 85 #include "ui/display/screen.h" | 86 #include "ui/display/screen.h" |
| (...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 709 env, *offline_page); | 710 env, *offline_page); |
| 710 } | 711 } |
| 711 | 712 |
| 712 bool TabAndroid::HasPrerenderedUrl(JNIEnv* env, | 713 bool TabAndroid::HasPrerenderedUrl(JNIEnv* env, |
| 713 const JavaParamRef<jobject>& obj, | 714 const JavaParamRef<jobject>& obj, |
| 714 const JavaParamRef<jstring>& url) { | 715 const JavaParamRef<jstring>& url) { |
| 715 GURL gurl(base::android::ConvertJavaStringToUTF8(env, url)); | 716 GURL gurl(base::android::ConvertJavaStringToUTF8(env, url)); |
| 716 return HasPrerenderedUrl(gurl); | 717 return HasPrerenderedUrl(gurl); |
| 717 } | 718 } |
| 718 | 719 |
| 720 void TabAndroid::ConfigureEmbeddedMediaExperience( | |
| 721 JNIEnv* env, | |
| 722 const base::android::JavaParamRef<jobject>& obj) { | |
| 723 content::RenderViewHost* host = web_contents()->GetRenderViewHost(); | |
| 724 if (!host) | |
| 725 return; | |
| 726 | |
| 727 content::WebPreferences prefs = host->GetWebkitPreferences(); | |
| 728 prefs.user_gesture_required_for_media_playback = false; | |
|
mlamouri (slow - plz ping)
2017/02/17 10:01:43
Is it needed? Can't you simply autoplay from C++ t
shaktisahu
2017/02/17 19:18:06
Done. Thanks!
| |
| 729 prefs.embedded_media_experience_enabled = true; | |
| 730 host->UpdateWebkitPreferences(prefs); | |
|
mlamouri (slow - plz ping)
2017/02/17 10:01:43
That does not sound correct because if any one cal
shaktisahu
2017/02/17 19:18:06
I looked around and didn't find any function that
mlamouri (slow - plz ping)
2017/02/20 11:31:50
The issue is that you are calling UpdateWebkitPref
shaktisahu
2017/02/21 07:02:56
Done.
Thanks! I think this is especially useful fo
| |
| 731 } | |
| 732 | |
| 719 namespace { | 733 namespace { |
| 720 | 734 |
| 721 class ChromeInterceptNavigationDelegate : public InterceptNavigationDelegate { | 735 class ChromeInterceptNavigationDelegate : public InterceptNavigationDelegate { |
| 722 public: | 736 public: |
| 723 ChromeInterceptNavigationDelegate(JNIEnv* env, jobject jdelegate) | 737 ChromeInterceptNavigationDelegate(JNIEnv* env, jobject jdelegate) |
| 724 : InterceptNavigationDelegate(env, jdelegate) {} | 738 : InterceptNavigationDelegate(env, jdelegate) {} |
| 725 | 739 |
| 726 bool ShouldIgnoreNavigation( | 740 bool ShouldIgnoreNavigation( |
| 727 const NavigationParams& navigation_params) override { | 741 const NavigationParams& navigation_params) override { |
| 728 NavigationParams chrome_navigation_params(navigation_params); | 742 NavigationParams chrome_navigation_params(navigation_params); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 764 static void Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 778 static void Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
| 765 TRACE_EVENT0("native", "TabAndroid::Init"); | 779 TRACE_EVENT0("native", "TabAndroid::Init"); |
| 766 // This will automatically bind to the Java object and pass ownership there. | 780 // This will automatically bind to the Java object and pass ownership there. |
| 767 new TabAndroid(env, obj); | 781 new TabAndroid(env, obj); |
| 768 } | 782 } |
| 769 | 783 |
| 770 // static | 784 // static |
| 771 bool TabAndroid::RegisterTabAndroid(JNIEnv* env) { | 785 bool TabAndroid::RegisterTabAndroid(JNIEnv* env) { |
| 772 return RegisterNativesImpl(env); | 786 return RegisterNativesImpl(env); |
| 773 } | 787 } |
| OLD | NEW |