Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(619)

Unified Diff: chrome/android/webapk/shell_apk/src/org/chromium/webapk/shell_apk/NotificationSettingsLauncherActivity.java

Issue 2169743002: Makes WebAPK handle NOTIFICATION_PREFERENCES intents (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge branch 'master' into notification_settings Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/webapk/shell_apk/src/org/chromium/webapk/shell_apk/NotificationSettingsLauncherActivity.java
diff --git a/chrome/android/webapk/shell_apk/src/org/chromium/webapk/shell_apk/NotificationSettingsLauncherActivity.java b/chrome/android/webapk/shell_apk/src/org/chromium/webapk/shell_apk/NotificationSettingsLauncherActivity.java
new file mode 100644
index 0000000000000000000000000000000000000000..1eaa3b2a43218a377ec6dccac2694d6f61140f1c
--- /dev/null
+++ b/chrome/android/webapk/shell_apk/src/org/chromium/webapk/shell_apk/NotificationSettingsLauncherActivity.java
@@ -0,0 +1,45 @@
+// Copyright 2016 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.
+
+package org.chromium.webapk.shell_apk;
+
+import android.app.Activity;
+import android.content.ComponentName;
+import android.content.Intent;
+import android.os.Bundle;
+
+/**
+ * Forwards NOTIFICATION_PREFERENCES intent to host browser.
+ */
+public class NotificationSettingsLauncherActivity extends Activity {
+ private static final String META_HOST_BROWSER_NOTIFICATION_PREFERENCES_HANDLER =
+ "hostNotificationPreferencesHandler";
+
+ @Override
+ public void onCreate(Bundle savedInstance) {
+ super.onCreate(savedInstance);
+
+ String hostIntentHandlerClass = getHostBrowserPreferencesHandler();
+ if (hostIntentHandlerClass != null) {
+ String hostPackage = WebApkUtils.getHostBrowserPackageName(this);
+
+ Intent intent = getIntent();
+ intent.setPackage(hostPackage);
+ intent.setComponent(new ComponentName(hostPackage, hostIntentHandlerClass));
+ startActivity(intent);
+ }
+ finish();
+ }
+
+ /**
+ * Returns the class in the host browser's package which handles NOTIFICATION_PREFERENCES
+ * intents.
+ */
+ public String getHostBrowserPreferencesHandler() {
+ Bundle metaData = WebApkUtils.getMetaDataBundle(this);
+ return (metaData == null)
+ ? null
+ : metaData.getString(META_HOST_BROWSER_NOTIFICATION_PREFERENCES_HANDLER);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698