Chromium Code Reviews| 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..02865978ec9c7cdd315e63790941d602c1b81988 |
| --- /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 fiends |
|
mnaganov (inactive)
2014/10/02 14:48:00
typo: fields?
SeRya
2014/10/03 09:49:35
Done.
|
| + .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) {} |
| +} |