diff options
author | peter <peter@chromium.org> | 2015-02-17 09:49:46 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-02-17 17:50:31 +0000 |
commit | d948e026b32a9d86e79bb5b19ab93efc45c1b6ad (patch) | |
tree | 8a958953e7513049df321c29959aeaebee42a302 | |
parent | 124618917b61d243e424bc74d34b27a69ef57ca3 (diff) | |
download | chromium_src-d948e026b32a9d86e79bb5b19ab93efc45c1b6ad.zip chromium_src-d948e026b32a9d86e79bb5b19ab93efc45c1b6ad.tar.gz chromium_src-d948e026b32a9d86e79bb5b19ab93efc45c1b6ad.tar.bz2 |
Exceptions for enabling Web Notifications and the Push API by default.
These features will be available on all versions of Windows, Mac, Linux and
Chrome OS, on Android since the JellyBean release, but not yet in WebView.
This was covered in the two intent to ships.
Web Notifications for Service Workers:
https://groups.google.com/a/chromium.org/forum/#!topic/blink-dev/Cr7_GRSd2zM
Push API:
https://groups.google.com/a/chromium.org/forum/#!topic/blink-dev/UdGlL9PtBLo
This is patch of a two-sided patch, where the first enables the feature
by default on all platforms.
[1] https://codereview.chromium.org/919033003/
[2] This patch.
BUG=432527, 350378, 90795
Review URL: https://codereview.chromium.org/914373003
Cr-Commit-Position: refs/heads/master@{#316601}
-rw-r--r-- | android_webview/javatests/src/org/chromium/android_webview/test/AwContentsTest.java | 17 | ||||
-rw-r--r-- | android_webview/lib/main/aw_main_delegate.cc | 3 | ||||
-rw-r--r-- | base/android/build_info.h | 13 | ||||
-rw-r--r-- | chrome/browser/services/gcm/push_messaging_browsertest.cc | 85 | ||||
-rw-r--r-- | chrome/browser/services/gcm/push_messaging_service_impl.cc | 7 | ||||
-rw-r--r-- | content/browser/android/content_startup_flags.cc | 7 | ||||
-rw-r--r-- | content/browser/renderer_host/render_process_host_impl.cc | 1 | ||||
-rw-r--r-- | content/child/runtime_features.cc | 12 | ||||
-rw-r--r-- | content/public/common/content_switches.cc | 3 | ||||
-rw-r--r-- | content/public/common/content_switches.h | 1 |
10 files changed, 134 insertions, 15 deletions
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsTest.java index d05fbd5..bf6f174 100644 --- a/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsTest.java +++ b/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsTest.java @@ -564,4 +564,21 @@ public class AwContentsTest extends AwTestBase { loadUrlSync(awContents, mContentsClient.getOnPageFinishedHelper(), pageUrl); assertEquals(onSslErrorCallCount + 1, onReceivedSslErrorHelper.getCallCount()); } + + /** + * Verifies that Web Notifications and the Push API are not exposed in WebView. + */ + @Feature({"AndroidWebView"}) + @SmallTest + public void testPushAndNotificationsDisabled() throws Throwable { + AwTestContainerView testView = createAwTestContainerViewOnMainSync(mContentsClient); + AwContents awContents = testView.getAwContents(); + + String script = "window.Notification || window.PushManager"; + + enableJavaScriptOnUiThread(awContents); + loadUrlSync(awContents, mContentsClient.getOnPageFinishedHelper(), "about:blank"); + assertEquals("null", executeJavaScriptAndWaitForResult(awContents, mContentsClient, + script)); + } } diff --git a/android_webview/lib/main/aw_main_delegate.cc b/android_webview/lib/main/aw_main_delegate.cc index f8ea4a1..37b751e 100644 --- a/android_webview/lib/main/aw_main_delegate.cc +++ b/android_webview/lib/main/aw_main_delegate.cc @@ -75,6 +75,9 @@ bool AwMainDelegate::BasicStartupComplete(int* exit_code) { // File system API not supported (requires some new API; internal bug 6930981) cl->AppendSwitch(switches::kDisableFileSystem); + // Web Notification API and the Push API are not supported (crbug.com/434712) + cl->AppendSwitch(switches::kDisableNotifications); + #if defined(VIDEO_HOLE) // Support EME/L1 with hole-punching. cl->AppendSwitch(switches::kMediaDrmEnableNonCompositing); diff --git a/base/android/build_info.h b/base/android/build_info.h index cef8145..e4e84e8 100644 --- a/base/android/build_info.h +++ b/base/android/build_info.h @@ -15,6 +15,19 @@ namespace base { namespace android { +// This enumeration maps to the values returned by BuildInfo::sdk_int(), +// indicating the Android release associated with a given SDK version. +enum SdkVersion { + SDK_VERSION_ICE_CREAM_SANDWICH = 14, + SDK_VERSION_ICE_CREAM_SANDWICH_MR1 = 15, + SDK_VERSION_JELLY_BEAN = 16, + SDK_VERSION_JELLY_BEAN_MR1 = 17, + SDK_VERSION_JELLY_BEAN_MR2 = 18, + SDK_VERSION_KITKAT = 19, + SDK_VERSION_KITKAT_WEAR = 20, + SDK_VERSION_LOLLIPOP = 21 +}; + // BuildInfo is a singleton class that stores android build and device // information. It will be called from Android specific code and gets used // primarily in crash reporting. diff --git a/chrome/browser/services/gcm/push_messaging_browsertest.cc b/chrome/browser/services/gcm/push_messaging_browsertest.cc index d9432ab..9a1a15d 100644 --- a/chrome/browser/services/gcm/push_messaging_browsertest.cc +++ b/chrome/browser/services/gcm/push_messaging_browsertest.cc @@ -32,6 +32,10 @@ #include "content/public/test/browser_test_utils.h" #include "ui/base/window_open_disposition.h" +#if defined(OS_ANDROID) +#include "base/android/build_info.h" +#endif + namespace gcm { namespace { @@ -133,6 +137,19 @@ class NotificationAddedCallback { bool waiting_; }; +// The Push API depends on Web Notifications, which is only available on Android +// Jelly Bean and later. +bool IsPushSupported() { +#if defined(OS_ANDROID) + if (base::android::BuildInfo::GetInstance()->sdk_int() < + base::android::SDK_VERSION_JELLY_BEAN) { + DVLOG(0) << "The Push API is only supported in Android 4.1 and later."; + return false; + } +#endif + return true; +} + } // namespace class PushMessagingBrowserTest : public InProcessBrowserTest { @@ -144,9 +161,7 @@ class PushMessagingBrowserTest : public InProcessBrowserTest { void SetUpCommandLine(base::CommandLine* command_line) override { command_line->AppendSwitch( switches::kEnableExperimentalWebPlatformFeatures); - command_line->AppendSwitch( - switches::kEnablePushMessagePayload); - + command_line->AppendSwitch(switches::kEnablePushMessagePayload); InProcessBrowserTest::SetUpCommandLine(command_line); } @@ -256,6 +271,9 @@ class PushMessagingBadManifestBrowserTest : public PushMessagingBrowserTest { IN_PROC_BROWSER_TEST_F(PushMessagingBadManifestBrowserTest, RegisterFailsNotVisibleMessages) { + if (!IsPushSupported()) + return; + std::string script_result; ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); @@ -292,6 +310,9 @@ PushMessagingApplicationId PushMessagingBrowserTest::GetServiceWorkerAppId( IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, RegisterSuccessNotificationsGranted) { + if (!IsPushSupported()) + return; + TryToRegisterSuccessfully("1-0" /* expected_push_registration_id */); PushMessagingApplicationId app_id = GetServiceWorkerAppId(0LL); @@ -301,6 +322,9 @@ IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, RegisterSuccessNotificationsPrompt) { + if (!IsPushSupported()) + return; + std::string script_result; ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); @@ -317,6 +341,9 @@ IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, RegisterFailureNotificationsBlocked) { + if (!IsPushSupported()) + return; + std::string script_result; ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); @@ -332,6 +359,9 @@ IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, } IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, RegisterFailureNoManifest) { + if (!IsPushSupported()) + return; + std::string script_result; ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); @@ -352,6 +382,9 @@ IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, RegisterFailureNoManifest) { // TODO(johnme): Test registering from a worker - see https://crbug.com/437298. IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, RegisterPersisted) { + if (!IsPushSupported()) + return; + std::string script_result; // First, test that Service Worker registration IDs are assigned in order of @@ -406,6 +439,9 @@ IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, RegisterPersisted) { } IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, PushEventSuccess) { + if (!IsPushSupported()) + return; + std::string script_result; TryToRegisterSuccessfully("1-0" /* expected_push_registration_id */); @@ -430,6 +466,9 @@ IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, PushEventSuccess) { } IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, PushEventNoServiceWorker) { + if (!IsPushSupported()) + return; + std::string script_result; TryToRegisterSuccessfully("1-0" /* expected_push_registration_id */); @@ -469,6 +508,9 @@ IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, PushEventNoServiceWorker) { } IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, PushEventNoPermission) { + if (!IsPushSupported()) + return; + std::string script_result; TryToRegisterSuccessfully("1-0" /* expected_push_registration_id */); @@ -510,6 +552,9 @@ IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, PushEventNoPermission) { #if defined(ENABLE_NOTIFICATIONS) IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, PushEventEnforcesUserVisibleNotification) { + if (!IsPushSupported()) + return; + std::string script_result; TryToRegisterSuccessfully("1-0" /* expected_push_registration_id */); @@ -601,6 +646,9 @@ IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, PushEventNotificationWithoutEventWaitUntil) { + if (!IsPushSupported()) + return; + std::string script_result; content::WebContents* web_contents = browser()->tab_strip_model()->GetActiveWebContents(); @@ -642,6 +690,9 @@ IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, #endif IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, HasPermissionSaysDefault) { + if (!IsPushSupported()) + return; + std::string script_result; ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); @@ -652,6 +703,9 @@ IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, HasPermissionSaysDefault) { } IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, HasPermissionSaysGranted) { + if (!IsPushSupported()) + return; + std::string script_result; ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); @@ -669,6 +723,9 @@ IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, HasPermissionSaysGranted) { } IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, HasPermissionSaysDenied) { + if (!IsPushSupported()) + return; + std::string script_result; ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); @@ -687,6 +744,9 @@ IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, HasPermissionSaysDenied) { } IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, UnregisterSuccess) { + if (!IsPushSupported()) + return; + std::string script_result; TryToRegisterSuccessfully("1-0" /* expected_push_registration_id */); @@ -698,6 +758,9 @@ IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, UnregisterSuccess) { } IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, UnregisterNetworkError) { + if (!IsPushSupported()) + return; + std::string script_result; TryToRegisterSuccessfully("1-0" /* expected_push_registration_id */); @@ -711,6 +774,9 @@ IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, UnregisterNetworkError) { } IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, UnregisterUnknownError) { + if (!IsPushSupported()) + return; + std::string script_result; TryToRegisterSuccessfully("1-0" /* expected_push_registration_id */); @@ -723,4 +789,17 @@ IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, UnregisterUnknownError) { " push server.", script_result); } +#if defined(OS_ANDROID) +IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, PushUnavailableOnAndroidICS) { + // This test should only run on Android ICS to confirm that the Push API + // is not available on that version of Android. + if (IsPushSupported()) + return; + + std::string script_result; + ASSERT_TRUE(RunScript("window.PushManager", &script_result)); + EXPECT_EQ("undefined", script_result); +} +#endif + } // namespace gcm diff --git a/chrome/browser/services/gcm/push_messaging_service_impl.cc b/chrome/browser/services/gcm/push_messaging_service_impl.cc index fb7d8cd..3a955d1 100644 --- a/chrome/browser/services/gcm/push_messaging_service_impl.cc +++ b/chrome/browser/services/gcm/push_messaging_service_impl.cc @@ -91,13 +91,6 @@ void PushMessagingServiceImpl::RegisterProfilePrefs( // static void PushMessagingServiceImpl::InitializeForProfile(Profile* profile) { - // TODO(mvanouwerkerk): Make sure to remove this check at the same time as - // push graduates from experimental in Blink. - if (!base::CommandLine::ForCurrentProcess()->HasSwitch( - switches::kEnableExperimentalWebPlatformFeatures)) { - return; - } - // TODO(johnme): Consider whether push should be enabled in incognito. if (!profile || profile->IsOffTheRecord()) return; diff --git a/content/browser/android/content_startup_flags.cc b/content/browser/android/content_startup_flags.cc index 9254c28..e5acab9 100644 --- a/content/browser/android/content_startup_flags.cc +++ b/content/browser/android/content_startup_flags.cc @@ -4,6 +4,7 @@ #include "content/browser/android/content_startup_flags.h" +#include "base/android/build_info.h" #include "base/base_switches.h" #include "base/command_line.h" #include "base/logging.h" @@ -70,6 +71,12 @@ void SetContentCommandLineFlags(bool single_process, if (base::SysInfo::IsLowEndDevice()) parsed_command_line->AppendSwitch(switches::kInProcessGPU); + // Web Notifications are only supported on Android JellyBean and beyond. + if (base::android::BuildInfo::GetInstance()->sdk_int() < + base::android::SDK_VERSION_JELLY_BEAN) { + parsed_command_line->AppendSwitch(switches::kDisableNotifications); + } + parsed_command_line->AppendSwitch(switches::kEnableViewportMeta); parsed_command_line->AppendSwitch( switches::kMainFrameResizesAreOrientationChanges); diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc index 1557903..68b50c7 100644 --- a/content/browser/renderer_host/render_process_host_impl.cc +++ b/content/browser/renderer_host/render_process_host_impl.cc @@ -1219,6 +1219,7 @@ void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer( switches::kDisableLogging, switches::kDisableMediaSource, switches::kDisableMojoChannel, + switches::kDisableNotifications, switches::kDisableOverlayScrollbar, switches::kDisablePinch, switches::kDisablePrefixedEncryptedMedia, diff --git a/content/child/runtime_features.cc b/content/child/runtime_features.cc index 875dbcb..21bebcb 100644 --- a/content/child/runtime_features.cc +++ b/content/child/runtime_features.cc @@ -48,8 +48,6 @@ static void SetRuntimeFeatureDefaultsForPlatform() { // Android does not have support for PagePopup WebRuntimeFeatures::enablePagePopup(false); - // Android does not yet support the Web Notification API. crbug.com/115320 - WebRuntimeFeatures::enableNotifications(false); // Android does not yet support SharedWorker. crbug.com/154571 WebRuntimeFeatures::enableSharedWorker(false); // Android does not yet support NavigatorContentUtils. @@ -105,6 +103,13 @@ void SetRuntimeFeaturesDefaultsAndUpdateFromArgs( if (command_line.HasSwitch(switches::kDisableMediaSource)) WebRuntimeFeatures::enableMediaSource(false); + if (command_line.HasSwitch(switches::kDisableNotifications)) { + WebRuntimeFeatures::enableNotifications(false); + + // Chrome's Push Messaging implementation relies on Web Notifications. + WebRuntimeFeatures::enablePushMessaging(false); + } + if (command_line.HasSwitch(switches::kDisableSharedWorkers)) WebRuntimeFeatures::enableSharedWorker(false); @@ -112,9 +117,6 @@ void SetRuntimeFeaturesDefaultsAndUpdateFromArgs( if (command_line.HasSwitch(switches::kDisableWebRTC)) WebRuntimeFeatures::enablePeerConnection(false); - if (command_line.HasSwitch(switches::kEnableExperimentalWebPlatformFeatures)) - WebRuntimeFeatures::enableNotifications(true); - // WebAudio is enabled by default on ARM and X86, if the MediaCodec // API is available. WebRuntimeFeatures::enableWebAudio( diff --git a/content/public/common/content_switches.cc b/content/public/common/content_switches.cc index 60d3423..c11062ce 100644 --- a/content/public/common/content_switches.cc +++ b/content/public/common/content_switches.cc @@ -194,6 +194,9 @@ const char kDisableMediaSource[] = "disable-media-source"; // Disables usage of the namespace sandbox. const char kDisableNamespaceSandbox[] = "disable-namespace-sandbox"; +// Disables the Web Notification and the Push APIs. +const char kDisableNotifications[] = "disable-notifications"; + // Disable rasterizer that writes directly to GPU memory. // Overrides the kEnableOneCopy flag. const char kDisableOneCopy[] = "disable-one-copy"; diff --git a/content/public/common/content_switches.h b/content/public/common/content_switches.h index e678ada..2c87ae0 100644 --- a/content/public/common/content_switches.h +++ b/content/public/common/content_switches.h @@ -67,6 +67,7 @@ CONTENT_EXPORT extern const char kDisableLocalStorage[]; CONTENT_EXPORT extern const char kDisableLogging[]; CONTENT_EXPORT extern const char kDisableMediaSource[]; CONTENT_EXPORT extern const char kDisableNamespaceSandbox[]; +CONTENT_EXPORT extern const char kDisableNotifications[]; CONTENT_EXPORT extern const char kDisableOneCopy[]; extern const char kDisablePepper3d[]; CONTENT_EXPORT extern const char kDisablePinch[]; |