diff options
-rw-r--r-- | base/android/base_jni_registrar.cc | 7 | ||||
-rw-r--r-- | base/android/context_types.cc | 26 | ||||
-rw-r--r-- | base/android/context_types.h | 22 | ||||
-rw-r--r-- | base/android/java/src/org/chromium/base/ContextTypes.java | 14 | ||||
-rw-r--r-- | base/base.gyp | 7 | ||||
-rw-r--r-- | base/base.gypi | 8 | ||||
-rw-r--r-- | chrome/browser/pepper_broker_infobar_delegate.cc | 32 |
7 files changed, 110 insertions, 6 deletions
diff --git a/base/android/base_jni_registrar.cc b/base/android/base_jni_registrar.cc index 606ab38..537933c 100644 --- a/base/android/base_jni_registrar.cc +++ b/base/android/base_jni_registrar.cc @@ -18,12 +18,19 @@ #include "base/message_pump_android.h" #include "base/power_monitor/power_monitor_android.h" +#if defined(GOOGLE_TV) +#include "base/android/context_types.h" +#endif + namespace base { namespace android { static RegistrationMethod kBaseRegisteredMethods[] = { { "ActivityStatus", base::android::ActivityStatus::RegisterBindings }, { "BuildInfo", base::android::BuildInfo::RegisterBindings }, +#if defined(GOOGLE_TV) + { "ContextTypes", base::android::RegisterContextTypes }, +#endif { "CpuFeatures", base::android::RegisterCpuFeatures }, { "ImportantFileWriterAndroid", base::android::RegisterImportantFileWriterAndroid }, diff --git a/base/android/context_types.cc b/base/android/context_types.cc new file mode 100644 index 0000000..084b136 --- /dev/null +++ b/base/android/context_types.cc @@ -0,0 +1,26 @@ +// Copyright (c) 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/android/context_types.h" + +#include "base/android/jni_android.h" +#include "base/android/scoped_java_ref.h" +#include "base/files/file_path.h" +#include "jni/ContextTypes_jni.h" + +namespace base { +namespace android { + +bool IsRunningInWebapp() { + JNIEnv* env = AttachCurrentThread(); + return static_cast<bool>( + Java_ContextTypes_isRunningInWebapp(env, GetApplicationContext())); +} + +bool RegisterContextTypes(JNIEnv* env) { + return RegisterNativesImpl(env); +} + +} // namespace android +} // namespace base diff --git a/base/android/context_types.h b/base/android/context_types.h new file mode 100644 index 0000000..a132167 --- /dev/null +++ b/base/android/context_types.h @@ -0,0 +1,22 @@ +// Copyright (c) 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef BASE_ANDROID_CONTEXT_TYPES_H_ +#define BASE_ANDROID_CONTEXT_TYPES_H_ + +#include <jni.h> + +#include "base/base_export.h" + +namespace base { +namespace android { + +BASE_EXPORT bool IsRunningInWebapp(); + +bool RegisterContextTypes(JNIEnv* env); + +} // namespace android +} // namespace base + +#endif // BASE_ANDROID_CONTEXT_TYPES_H_ diff --git a/base/android/java/src/org/chromium/base/ContextTypes.java b/base/android/java/src/org/chromium/base/ContextTypes.java index 18926aa..35ecd8f 100644 --- a/base/android/java/src/org/chromium/base/ContextTypes.java +++ b/base/android/java/src/org/chromium/base/ContextTypes.java @@ -19,7 +19,7 @@ import java.util.Map; */ public class ContextTypes { - // Available context types + // Available context types. public static final int CONTEXT_TYPE_NORMAL = 1; public static final int CONTEXT_TYPE_WEBAPP = 2; @@ -73,6 +73,18 @@ public class ContextTypes { } /** + * Returns whether activity is running in web app mode. + * + * @param appContext {@link Context} in interest + * @return {@code true} when activity is running in web app mode. + */ + @CalledByNative + public static boolean isRunningInWebapp(Context appContext) { + return ContextTypes.getInstance().getType(appContext) + == CONTEXT_TYPE_WEBAPP; + } + + /** * Checks if the mapping exists for the given context. * * @param context {@link Context} in interest diff --git a/base/base.gyp b/base/base.gyp index 8b3ebac..667ec00 100644 --- a/base/base.gyp +++ b/base/base.gyp @@ -1136,6 +1136,13 @@ 'android/java/src/org/chromium/base/SystemMessageHandler.java', 'android/java/src/org/chromium/base/ThreadUtils.java', ], + 'conditions': [ + ['google_tv==1', { + 'sources': [ + 'android/java/src/org/chromium/base/ContextTypes.java', + ], + }], + ], 'variables': { 'jni_gen_package': 'base', }, diff --git a/base/base.gypi b/base/base.gypi index 7194f24..bdade59 100644 --- a/base/base.gypi +++ b/base/base.gypi @@ -589,6 +589,14 @@ 'win/wrapped_window_proc.cc', 'win/wrapped_window_proc.h', ], + 'conditions': [ + ['google_tv==1', { + 'sources': [ + 'android/context_types.cc', + 'android/context_types.h', + ], + }], + ], 'defines': [ 'BASE_IMPLEMENTATION', ], diff --git a/chrome/browser/pepper_broker_infobar_delegate.cc b/chrome/browser/pepper_broker_infobar_delegate.cc index 459856f..4f959ca 100644 --- a/chrome/browser/pepper_broker_infobar_delegate.cc +++ b/chrome/browser/pepper_broker_infobar_delegate.cc @@ -24,15 +24,14 @@ #include "ui/base/resource/resource_bundle.h" #include "webkit/plugins/webplugininfo.h" +#if defined(GOOGLE_TV) +#include "base/android/context_types.h" +#endif + // The URL for the "learn more" article about the PPAPI broker. const char kPpapiBrokerLearnMoreUrl[] = "https://support.google.com/chrome/?p=ib_pepper_broker"; -#if defined(OS_CHROMEOS) -const char kNetflixPluginFileName[] = "libnetflixplugin2.so"; -const char kWidevinePluginFileName[] = "libwidevinecdmadapter.so"; -#endif - using content::OpenURLParams; using content::Referrer; using content::WebContents; @@ -57,6 +56,8 @@ void PepperBrokerInfoBarDelegate::Create( #if defined(OS_CHROMEOS) // On ChromeOS, we're ok with granting broker access to Netflix and Widevine // plugin, since it can only come installed with the OS. + const char kNetflixPluginFileName[] = "libnetflixplugin2.so"; + const char kWidevinePluginFileName[] = "libwidevinecdmadapter.so"; base::FilePath plugin_file_name = plugin_path.BaseName(); if (plugin_file_name.value() == FILE_PATH_LITERAL(kNetflixPluginFileName) || plugin_file_name.value() == FILE_PATH_LITERAL(kWidevinePluginFileName)) { @@ -66,6 +67,27 @@ void PepperBrokerInfoBarDelegate::Create( } #endif +#if defined(GOOGLE_TV) + // On GoogleTV, Netflix crypto plugin and DRM server adapter plugin can only + // come pre-installed with the OS, so we're willing to auto-grant access + // to them. PluginRootName should be matched with PEPPER_PLUGIN_ROOT + // in PepperPluginManager.java. + const char kPluginRootName[] = "/system/lib/pepperplugin"; + const char kNetflixCryptoPluginFileName[] = "libnrddpicrypto.so"; + const char kDrmServerAdapterPluginFileName[] = "libdrmserveradapter.so"; + base::FilePath::StringType plugin_dir_name = plugin_path.DirName().value(); + base::FilePath::StringType plugin_file_name = plugin_path.BaseName().value(); + if (base::android::IsRunningInWebapp() && + plugin_dir_name == FILE_PATH_LITERAL(kPluginRootName) && + (plugin_file_name == FILE_PATH_LITERAL(kNetflixCryptoPluginFileName) || + plugin_file_name == + FILE_PATH_LITERAL(kDrmServerAdapterPluginFileName))) { + tab_content_settings->SetPepperBrokerAllowed(true); + callback.Run(true); + return; + } +#endif + HostContentSettingsMap* content_settings = profile->GetHostContentSettingsMap(); ContentSetting setting = |