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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkDisclosureNotificationManager.java

Issue 2841193002: Implement privacy disclosure for an unbound webapk. (Closed)
Patch Set: Implement privacy disclosure for an unbound webapk. Created 3 years, 8 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/java/src/org/chromium/chrome/browser/webapps/WebApkDisclosureNotificationManager.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkDisclosureNotificationManager.java b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkDisclosureNotificationManager.java
new file mode 100644
index 0000000000000000000000000000000000000000..f14503e2a7a62f395c2b021fcda8a22eb4abf707
--- /dev/null
+++ b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkDisclosureNotificationManager.java
@@ -0,0 +1,77 @@
+// Copyright 2017 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.chrome.browser.webapps;
+
+import android.app.Notification;
+import android.app.NotificationManager;
+import android.app.PendingIntent;
+import android.content.Context;
+import android.content.Intent;
+import android.net.Uri;
+
+import org.chromium.base.ContextUtils;
+import org.chromium.chrome.R;
+import org.chromium.chrome.browser.document.ChromeLauncherActivity;
+import org.chromium.chrome.browser.notifications.ChannelDefinitions;
awdf 2017/05/04 15:49:30 fyi i just hit 'submit' on this cl which moves Cha
+import org.chromium.chrome.browser.notifications.ChromeNotificationBuilder;
+import org.chromium.chrome.browser.notifications.NotificationBuilderFactory;
+import org.chromium.chrome.browser.notifications.NotificationConstants;
+import org.chromium.chrome.browser.notifications.NotificationUmaTracker;
+
+/**
+ * Manages the notification indicating that a WebApk is backed by chrome code and may share data.
+ */
+public class WebApkDisclosureNotificationManager {
+ private static final String WEBAPK_OPEN_TAG = "webapk_notification";
+ private static final int WEBAPK_OPEN_ID = 100;
+
+ private static PendingIntent getDisclosureIntent(Context context) {
+ Intent intent = new Intent(context, ChromeLauncherActivity.class);
+ intent.setData(Uri.parse("https://www.google.com/chrome/browser/privacy/"));
+ return PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
+ }
+
+ /**
+ * Shows the privacy disclosure informing the user that Chrome is being used.
+ * @param mWebappInfo Web App this is currently displayed fullscreen.
+ */
+ public static void showDisclosure(WebappInfo mWebappInfo) {
awdf 2017/05/02 12:33:35 nit: s/mWebAppInfo/webAppInfo (& in param document
Yaron 2017/05/24 01:13:16 Done.
+ Context context = ContextUtils.getApplicationContext();
+ String actionMessage =
+ context.getResources().getString(R.string.webapk_disclosure_notification);
+ String title = mWebappInfo.shortName();
+
+ ChromeNotificationBuilder builder =
+ NotificationBuilderFactory
+ .createChromeNotificationBuilder(
+ true /* preferCompat */, ChannelDefinitions.CHANNEL_ID_BROWSER)
+ .setContentTitle(title)
+ .addAction(0, context.getResources().getString(R.string.learn_more),
+ getDisclosureIntent(context))
+ .setOngoing(true)
+ .setVisibility(Notification.VISIBILITY_SECRET)
+ .setSmallIcon(R.drawable.ic_chrome)
+ .setLargeIcon(mWebappInfo.icon())
+ .setShowWhen(false)
+ .setLocalOnly(true)
+ .setPriority(Notification.PRIORITY_MIN)
+ .setGroup(NotificationConstants.GROUP_WEBAPK);
+ NotificationManager nm =
+ (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
+ nm.notify(WEBAPK_OPEN_TAG, WEBAPK_OPEN_ID, builder.buildWithBigTextStyle(actionMessage));
+ NotificationUmaTracker.getInstance().onNotificationShown(
+ NotificationUmaTracker.WEBAPK, ChannelDefinitions.CHANNEL_ID_BROWSER);
+ }
+
+ /**
+ * Dismisses the notification.
+ */
+ public static void dismissNotification() {
+ Context context = ContextUtils.getApplicationContext();
+ NotificationManager nm =
+ (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
+ nm.cancel(WEBAPK_OPEN_TAG, WEBAPK_OPEN_ID);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698