OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.chrome.browser.download.items; | 5 package org.chromium.chrome.browser.download.items; |
6 | 6 |
7 import org.chromium.base.ThreadUtils; | 7 import org.chromium.base.ThreadUtils; |
| 8 import org.chromium.chrome.browser.download.DownloadManagerService; |
| 9 import org.chromium.chrome.browser.download.DownloadNotifier; |
8 import org.chromium.chrome.browser.profiles.Profile; | 10 import org.chromium.chrome.browser.profiles.Profile; |
9 import org.chromium.components.offline_items_collection.OfflineContentProvider; | 11 import org.chromium.components.offline_items_collection.OfflineContentProvider; |
10 | 12 |
11 /** | 13 /** |
12 * A factory meant to hold a singleton bridge between the notification UI and an | 14 * A factory meant to hold a singleton bridge between the notification UI and an |
13 * {@link OfflineContentProvider}. | 15 * {@link OfflineContentProvider}. |
14 */ | 16 */ |
15 public class OfflineContentAggregatorNotificationBridgeUiFactory { | 17 public class OfflineContentAggregatorNotificationBridgeUiFactory { |
16 private static OfflineContentAggregatorNotificationBridgeUi sBridgeUi; | 18 private static OfflineContentAggregatorNotificationBridgeUi sBridgeUi; |
17 | 19 |
18 /** | 20 /** |
19 * @return An {@link OfflineContentAggregatorNotificationBridgeUi} instance
singleton. If one | 21 * @return An {@link OfflineContentAggregatorNotificationBridgeUi} instance
singleton. If one |
20 * is not available this will create a new one. | 22 * is not available this will create a new one. |
21 */ | 23 */ |
22 public static OfflineContentAggregatorNotificationBridgeUi instance() { | 24 public static OfflineContentAggregatorNotificationBridgeUi instance() { |
23 ThreadUtils.assertOnUiThread(); | 25 ThreadUtils.assertOnUiThread(); |
24 if (sBridgeUi == null) { | 26 if (sBridgeUi == null) { |
25 Profile profile = Profile.getLastUsedProfile(); | 27 Profile profile = Profile.getLastUsedProfile(); |
26 OfflineContentProvider provider = OfflineContentAggregatorFactory.fo
rProfile(profile); | 28 OfflineContentProvider provider = OfflineContentAggregatorFactory.fo
rProfile(profile); |
| 29 DownloadNotifier ui = |
| 30 DownloadManagerService.getDownloadManagerService().getDownlo
adNotifier(); |
27 | 31 |
28 sBridgeUi = new OfflineContentAggregatorNotificationBridgeUi(provide
r); | 32 sBridgeUi = new OfflineContentAggregatorNotificationBridgeUi(provide
r, ui); |
29 } | 33 } |
30 | 34 |
31 return sBridgeUi; | 35 return sBridgeUi; |
32 } | 36 } |
33 | 37 |
34 /** | 38 /** |
35 * Destroys the internal singleton for {@link OfflineContentAggregatorNotifi
cationBridgeUi} if | 39 * Destroys the internal singleton for {@link OfflineContentAggregatorNotifi
cationBridgeUi} if |
36 * one exists. | 40 * one exists. |
37 */ | 41 */ |
38 public static void destroy() { | 42 public static void destroy() { |
39 ThreadUtils.assertOnUiThread(); | 43 ThreadUtils.assertOnUiThread(); |
40 if (sBridgeUi == null) return; | 44 if (sBridgeUi == null) return; |
41 | 45 |
42 sBridgeUi.destroy(); | 46 sBridgeUi.destroy(); |
43 sBridgeUi = null; | 47 sBridgeUi = null; |
44 } | 48 } |
45 | 49 |
46 private OfflineContentAggregatorNotificationBridgeUiFactory() {} | 50 private OfflineContentAggregatorNotificationBridgeUiFactory() {} |
47 } | 51 } |
OLD | NEW |