1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 package org.chromium.components.devtools_bridge.ui;
7 import android.app.Notification;
8 import android.app.PendingIntent;
9 import android.app.Service;
10 import android.content.Intent;
13 * UI factory for DevToolsBridgeServer.
15 public abstract class ServiceUIFactory {
16 public Notification newForegroundNotification(Service host, String disconnectAction) {
17 // TODO(serya): move strings to a string grid.
19 Intent disconnectIntent = new Intent(host, host.getClass());
20 disconnectIntent.setAction(disconnectAction);
21 PendingIntent disconnectPendingIntent =
22 PendingIntent.getService(host, 0, disconnectIntent, 0);
24 Notification.Builder builder = new Notification.Builder(host)
26 .setSmallIcon(notificationSmallIcon())
27 .setContentTitle(productName())
28 .setContentText("Remote debugger connected")
31 .addAction(android.R.drawable.ic_delete,
32 "Disconnect", disconnectPendingIntent)
34 .setWhen(System.currentTimeMillis());
36 setupContentIntent(builder);
37 return builder.build();
40 protected abstract String productName();
41 protected abstract int notificationSmallIcon();
42 protected void setupContentIntent(Notification.Builder builder) {}