Chromium Code Reviews| Index: chrome/android/webapk/libs/runtime_library/src/org/chromium/webapk/lib/runtime_library/WebApkServiceImpl.java |
| diff --git a/chrome/android/webapk/libs/runtime_library/src/org/chromium/webapk/lib/runtime_library/WebApkServiceImpl.java b/chrome/android/webapk/libs/runtime_library/src/org/chromium/webapk/lib/runtime_library/WebApkServiceImpl.java |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b0863486fe3e382c4366ed47a3ac867b2c9c5f67 |
| --- /dev/null |
| +++ b/chrome/android/webapk/libs/runtime_library/src/org/chromium/webapk/lib/runtime_library/WebApkServiceImpl.java |
| @@ -0,0 +1,53 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
|
Peter Beverloo
2016/05/19 15:59:00
nit: year++
|
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +package org.chromium.webapk.lib.runtime_library; |
| + |
| +import android.app.Notification; |
| +import android.app.NotificationManager; |
| +import android.content.Context; |
| + |
| +/** |
| + * Implements services offered by the WebAPK to Chrome. |
| + */ |
| +public class WebApkServiceImpl extends IWebApkApi.Stub { |
| + |
| + private static final String TAG = "WebApkServiceImpl"; |
| + |
| + private final Context mContext; |
| + |
| + /** |
| + * Id of icon to represent WebAPK notifications in status bar. |
| + */ |
| + private final int mSmallIconId; |
| + |
| + /** |
| + * Creates an instance of WebApkServiceImpl. |
| + * @param context |
| + * @param smallIconId Id of icon to represent notifications in status bar. |
| + */ |
| + public WebApkServiceImpl(Context context, int smallIconId) { |
| + mContext = context; |
| + mSmallIconId = smallIconId; |
| + } |
| + |
| + @Override |
| + public int getSmallIconId() { |
| + return mSmallIconId; |
| + } |
| + |
| + @Override |
| + public void displayNotification(String platformTag, int platformID, Notification notification) { |
| + getNotificationManager().notify(platformTag, platformID, notification); |
| + } |
| + |
| + @Override |
| + public void closeNotification(String platformTag, int platformID) { |
| + getNotificationManager().cancel(platformTag, platformID); |
| + } |
| + |
| + private NotificationManager getNotificationManager() { |
| + return (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE); |
| + } |
| +} |