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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/notifications/ChannelsInitializer.java

Issue 2863623002: [Android] Refactor: move files to chrome/browser/notifications/channels (Closed)
Patch Set: rebase Created 3 years, 7 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: chrome/android/java/src/org/chromium/chrome/browser/notifications/ChannelsInitializer.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/notifications/ChannelsInitializer.java b/chrome/android/java/src/org/chromium/chrome/browser/notifications/ChannelsInitializer.java
deleted file mode 100644
index 299189c10f587f325c27e454bfc3e3f383e39c92..0000000000000000000000000000000000000000
--- a/chrome/android/java/src/org/chromium/chrome/browser/notifications/ChannelsInitializer.java
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright 2017 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.chrome.browser.notifications;
-
-/**
- * Initializes our notification channels.
- */
-public class ChannelsInitializer {
-
- private final NotificationManagerProxy mNotificationManager;
- private final ChannelDefinitions mChannelDefinitions;
-
- public ChannelsInitializer(NotificationManagerProxy notificationManagerProxy,
- ChannelDefinitions channelDefinitions) {
- mNotificationManager = notificationManagerProxy;
- mChannelDefinitions = channelDefinitions;
- }
-
- /**
- * Creates all the channels on the notification manager that we want to appear in our
- * channel settings from first launch onwards.
- */
- public void initializeStartupChannels() {
- for (String channelId : mChannelDefinitions.getStartupChannelIds()) {
- ensureInitialized(channelId);
- }
- }
-
- /**
- * Cleans up any old channels that are no longer required from previous versions of the app.
- * It's safe to call this multiple times since deleting an already-deleted channel is a no-op.
- */
- void deleteLegacyChannels() {
- for (String channelId : mChannelDefinitions.getLegacyChannelIds()) {
- mNotificationManager.deleteNotificationChannel(channelId);
- }
- }
-
- /**
- * Ensures the given channel has been created on the notification manager so a notification
- * can be safely posted to it. This should only be used for channels that are predefined in
- * {@link ChannelDefinitions.PredefinedChannels}.
- *
- * Calling this is a (potentially lengthy) no-op if the channel has already been created.
- *
- * @param channelId The ID of the channel to be initialized.
- */
- public void ensureInitialized(@ChannelDefinitions.ChannelId String channelId) {
- ChannelDefinitions.Channel channel = mChannelDefinitions.getChannelFromId(channelId);
- if (channel == null) {
- throw new IllegalStateException("Could not initialize channel: " + channelId);
- }
- // Channel group must be created before the channel.
- mNotificationManager.createNotificationChannelGroup(
- mChannelDefinitions.getChannelGroupFromId(channel));
- mNotificationManager.createNotificationChannel(channel);
- }
-
-}

Powered by Google App Engine
This is Rietveld 408576698