Index: components/devtools_bridge/android/java/src/org/chromium/components/devtools_bridge/ui/ServiceUIFactory.java |
diff --git a/components/devtools_bridge/android/java/src/org/chromium/components/devtools_bridge/ui/ServiceUIFactory.java b/components/devtools_bridge/android/java/src/org/chromium/components/devtools_bridge/ui/ServiceUIFactory.java |
new file mode 100644 |
index 0000000000000000000000000000000000000000..8f1207e7a8e420edb1984ccef337706e21205e26 |
--- /dev/null |
+++ b/components/devtools_bridge/android/java/src/org/chromium/components/devtools_bridge/ui/ServiceUIFactory.java |
@@ -0,0 +1,43 @@ |
+// Copyright 2014 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.components.devtools_bridge.ui; |
+ |
+import android.app.Notification; |
+import android.app.PendingIntent; |
+import android.app.Service; |
+import android.content.Intent; |
+ |
+/** |
+ * UI factory for DevToolsBridgeServer. |
+ */ |
+public abstract class ServiceUIFactory { |
+ public Notification newForegroundNotification(Service host, String disconnectAction) { |
+ // TODO(serya): move strings to a string grid. |
+ |
+ Intent disconnectIntent = new Intent(host, host.getClass()); |
+ disconnectIntent.setAction(disconnectAction); |
+ PendingIntent disconnectPendingIntent = |
+ PendingIntent.getService(host, 0, disconnectIntent, 0); |
+ |
+ Notification.Builder builder = new Notification.Builder(host) |
+ // Mandatory fields |
+ .setSmallIcon(notificationSmallIcon()) |
+ .setContentTitle(productName()) |
+ .setContentText("Remote debugger connected") |
+ |
+ // Optional |
+ .addAction(android.R.drawable.ic_delete, |
+ "Disconnect", disconnectPendingIntent) |
+ .setOngoing(true) |
+ .setWhen(System.currentTimeMillis()); |
+ |
+ setupContentIntent(builder); |
+ return builder.build(); |
+ } |
+ |
+ protected abstract String productName(); |
+ protected abstract int notificationSmallIcon(); |
+ protected void setupContentIntent(Notification.Builder builder) {} |
+} |