OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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; | 5 package org.chromium.chrome.browser.download; |
6 | 6 |
7 import android.app.Activity; | |
8 import android.content.Intent; | |
9 import android.os.Bundle; | 7 import android.os.Bundle; |
10 | 8 |
11 import org.chromium.chrome.browser.IntentHandler; | 9 import org.chromium.chrome.browser.IntentHandler; |
12 import org.chromium.chrome.browser.SnackbarActivity; | 10 import org.chromium.chrome.browser.SnackbarActivity; |
13 import org.chromium.chrome.browser.download.ui.DownloadManagerUi; | 11 import org.chromium.chrome.browser.download.ui.DownloadManagerUi; |
| 12 import org.chromium.chrome.browser.util.IntentUtils; |
14 | 13 |
15 /** | 14 /** |
16 * Activity for managing downloads handled through Chrome. | 15 * Activity for managing downloads handled through Chrome. |
17 */ | 16 */ |
18 public class DownloadActivity extends SnackbarActivity { | 17 public class DownloadActivity extends SnackbarActivity { |
19 private DownloadManagerUi mDownloadManagerUi; | 18 private DownloadManagerUi mDownloadManagerUi; |
20 | 19 |
21 @Override | 20 @Override |
22 public void onCreate(Bundle savedInstanceState) { | 21 public void onCreate(Bundle savedInstanceState) { |
23 super.onCreate(savedInstanceState); | 22 super.onCreate(savedInstanceState); |
24 | 23 |
25 mDownloadManagerUi = new DownloadManagerUi(this); | 24 boolean isIncognito = IntentUtils.safeGetBooleanExtra( |
| 25 getIntent(), IntentHandler.EXTRA_OPEN_NEW_INCOGNITO_TAB, false); |
| 26 mDownloadManagerUi = new DownloadManagerUi(this, isIncognito); |
26 setContentView(mDownloadManagerUi.getView()); | 27 setContentView(mDownloadManagerUi.getView()); |
27 } | 28 } |
28 | 29 |
29 @Override | 30 @Override |
30 public void onBackPressed() { | 31 public void onBackPressed() { |
31 if (!mDownloadManagerUi.onBackPressed()) super.onBackPressed(); | 32 if (!mDownloadManagerUi.onBackPressed()) super.onBackPressed(); |
32 } | 33 } |
33 | 34 |
34 @Override | 35 @Override |
35 protected void onDestroy() { | 36 protected void onDestroy() { |
36 mDownloadManagerUi.onDestroyed(); | 37 mDownloadManagerUi.onDestroyed(); |
37 super.onDestroy(); | 38 super.onDestroy(); |
38 } | 39 } |
39 | |
40 /** | |
41 * Convenience method for launching this Activity. | |
42 * @param activity Activity that is launching this the Downloads page. | |
43 */ | |
44 public static void launch(Activity activity) { | |
45 Intent intent = new Intent(); | |
46 intent.setClass(activity, DownloadActivity.class); | |
47 intent.putExtra(IntentHandler.EXTRA_PARENT_COMPONENT, activity.getCompon
entName()); | |
48 activity.startActivity(intent); | |
49 } | |
50 } | 40 } |
OLD | NEW |