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

Unified Diff: components/devtools_bridge/android/java/src/org/chromium/components/devtools_bridge/ui/ServiceUIFactory.java

Issue 540383002: Implementation of DevToolsBridgeServer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@session
Patch Set: findbugs fixes. Created 6 years, 2 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: 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) {}
+}

Powered by Google App Engine
This is Rietveld 408576698