| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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; | 5 package org.chromium.chrome.browser; |
| 6 | 6 |
| 7 import android.app.Activity; | 7 import android.app.Activity; |
| 8 import android.content.Context; | 8 import android.content.Context; |
| 9 import android.content.Intent; | |
| 10 import android.content.SharedPreferences; | 9 import android.content.SharedPreferences; |
| 11 import android.os.SystemClock; | 10 import android.os.SystemClock; |
| 12 import android.util.Log; | |
| 13 | 11 |
| 14 import org.chromium.base.ActivityState; | 12 import org.chromium.base.ActivityState; |
| 15 import org.chromium.base.ApplicationStatus; | 13 import org.chromium.base.ApplicationStatus; |
| 16 import org.chromium.base.CommandLineInitUtil; | 14 import org.chromium.base.CommandLineInitUtil; |
| 17 import org.chromium.base.ContextUtils; | 15 import org.chromium.base.ContextUtils; |
| 18 import org.chromium.base.ThreadUtils; | 16 import org.chromium.base.ThreadUtils; |
| 19 import org.chromium.base.TraceEvent; | 17 import org.chromium.base.TraceEvent; |
| 20 import org.chromium.base.annotations.CalledByNative; | |
| 21 import org.chromium.base.annotations.MainDex; | 18 import org.chromium.base.annotations.MainDex; |
| 22 import org.chromium.base.annotations.SuppressFBWarnings; | 19 import org.chromium.base.annotations.SuppressFBWarnings; |
| 23 import org.chromium.base.library_loader.ProcessInitException; | 20 import org.chromium.base.library_loader.ProcessInitException; |
| 24 import org.chromium.chrome.browser.document.DocumentActivity; | 21 import org.chromium.chrome.browser.document.DocumentActivity; |
| 25 import org.chromium.chrome.browser.document.IncognitoDocumentActivity; | 22 import org.chromium.chrome.browser.document.IncognitoDocumentActivity; |
| 26 import org.chromium.chrome.browser.init.InvalidStartupDialog; | 23 import org.chromium.chrome.browser.init.InvalidStartupDialog; |
| 27 import org.chromium.chrome.browser.metrics.UmaUtils; | 24 import org.chromium.chrome.browser.metrics.UmaUtils; |
| 28 import org.chromium.chrome.browser.partnercustomizations.PartnerBrowserCustomiza
tions; | |
| 29 import org.chromium.chrome.browser.preferences.PreferencesLauncher; | |
| 30 import org.chromium.chrome.browser.preferences.password.SavePasswordsPreferences
; | |
| 31 import org.chromium.chrome.browser.tab.Tab; | |
| 32 import org.chromium.chrome.browser.tabmodel.document.ActivityDelegateImpl; | 25 import org.chromium.chrome.browser.tabmodel.document.ActivityDelegateImpl; |
| 33 import org.chromium.chrome.browser.tabmodel.document.DocumentTabModelSelector; | 26 import org.chromium.chrome.browser.tabmodel.document.DocumentTabModelSelector; |
| 34 import org.chromium.chrome.browser.tabmodel.document.StorageDelegate; | 27 import org.chromium.chrome.browser.tabmodel.document.StorageDelegate; |
| 35 import org.chromium.chrome.browser.tabmodel.document.TabDelegate; | 28 import org.chromium.chrome.browser.tabmodel.document.TabDelegate; |
| 36 import org.chromium.content.app.ContentApplication; | 29 import org.chromium.content.app.ContentApplication; |
| 37 | 30 |
| 38 /** | 31 /** |
| 39 * Basic application functionality that should be shared among all browser appli
cations that use | 32 * Basic application functionality that should be shared among all browser appli
cations that use |
| 40 * chrome layer. | 33 * chrome layer. |
| 41 */ | 34 */ |
| (...skipping 23 matching lines...) Expand all Loading... |
| 65 UmaUtils.recordMainEntryPointTime(); | 58 UmaUtils.recordMainEntryPointTime(); |
| 66 initCommandLine(); | 59 initCommandLine(); |
| 67 TraceEvent.maybeEnableEarlyTracing(); | 60 TraceEvent.maybeEnableEarlyTracing(); |
| 68 TraceEvent.begin("ChromeApplication.onCreate"); | 61 TraceEvent.begin("ChromeApplication.onCreate"); |
| 69 | 62 |
| 70 super.onCreate(); | 63 super.onCreate(); |
| 71 | 64 |
| 72 TraceEvent.end("ChromeApplication.onCreate"); | 65 TraceEvent.end("ChromeApplication.onCreate"); |
| 73 } | 66 } |
| 74 | 67 |
| 75 @CalledByNative | |
| 76 protected void showPasswordSettings() { | |
| 77 PreferencesLauncher.launchSettingsPage(this, | |
| 78 SavePasswordsPreferences.class.getName()); | |
| 79 } | |
| 80 | |
| 81 /** | 68 /** |
| 82 * Shows an error dialog following a startup error, and then exits the appli
cation. | 69 * Shows an error dialog following a startup error, and then exits the appli
cation. |
| 83 * @param e The exception reported by Chrome initialization. | 70 * @param e The exception reported by Chrome initialization. |
| 84 */ | 71 */ |
| 85 public static void reportStartupErrorAndExit(final ProcessInitException e) { | 72 public static void reportStartupErrorAndExit(final ProcessInitException e) { |
| 86 Activity activity = ApplicationStatus.getLastTrackedFocusedActivity(); | 73 Activity activity = ApplicationStatus.getLastTrackedFocusedActivity(); |
| 87 if (ApplicationStatus.getStateForActivity(activity) == ActivityState.DES
TROYED) { | 74 if (ApplicationStatus.getStateForActivity(activity) == ActivityState.DES
TROYED) { |
| 88 return; | 75 return; |
| 89 } | 76 } |
| 90 InvalidStartupDialog.show(activity, e.getErrorCode()); | 77 InvalidStartupDialog.show(activity, e.getErrorCode()); |
| 91 } | 78 } |
| 92 | 79 |
| 93 @Override | 80 @Override |
| 94 public void initCommandLine() { | 81 public void initCommandLine() { |
| 95 CommandLineInitUtil.initCommandLine(this, COMMAND_LINE_FILE); | 82 CommandLineInitUtil.initCommandLine(this, COMMAND_LINE_FILE); |
| 96 } | 83 } |
| 97 | 84 |
| 98 /** | 85 /** |
| 99 * Opens the UI to clear browsing data. | |
| 100 * @param tab The tab that triggered the request. | |
| 101 */ | |
| 102 @CalledByNative | |
| 103 protected void openClearBrowsingData(Tab tab) { | |
| 104 Activity activity = tab.getWindowAndroid().getActivity().get(); | |
| 105 if (activity == null) { | |
| 106 Log.e(TAG, | |
| 107 "Attempting to open clear browsing data for a tab without a
valid activity"); | |
| 108 return; | |
| 109 } | |
| 110 | |
| 111 Intent intent = PreferencesLauncher.createIntentForClearBrowsingDataPage
(activity); | |
| 112 activity.startActivity(intent); | |
| 113 } | |
| 114 | |
| 115 /** | |
| 116 * @return Whether parental controls are enabled. Returning true will disab
le | |
| 117 * incognito mode. | |
| 118 */ | |
| 119 @CalledByNative | |
| 120 protected boolean areParentalControlsEnabled() { | |
| 121 return PartnerBrowserCustomizations.isIncognitoDisabled(); | |
| 122 } | |
| 123 | |
| 124 /** | |
| 125 * @return The user agent string of Chrome. | 86 * @return The user agent string of Chrome. |
| 126 */ | 87 */ |
| 127 public static String getBrowserUserAgent() { | 88 public static String getBrowserUserAgent() { |
| 128 return nativeGetBrowserUserAgent(); | 89 return nativeGetBrowserUserAgent(); |
| 129 } | 90 } |
| 130 | 91 |
| 131 /** | 92 /** |
| 132 * The host activity should call this during its onPause() handler to ensure | 93 * The host activity should call this during its onPause() handler to ensure |
| 133 * all state is saved when the app is suspended. Calling ChromiumApplicatio
n.onStop() does | 94 * all state is saved when the app is suspended. Calling ChromiumApplicatio
n.onStop() does |
| 134 * this for you. | 95 * this for you. |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 ThreadUtils.assertOnUiThread(); | 142 ThreadUtils.assertOnUiThread(); |
| 182 if (sDocumentTabModelSelector == null) { | 143 if (sDocumentTabModelSelector == null) { |
| 183 ActivityDelegateImpl activityDelegate = new ActivityDelegateImpl( | 144 ActivityDelegateImpl activityDelegate = new ActivityDelegateImpl( |
| 184 DocumentActivity.class, IncognitoDocumentActivity.class); | 145 DocumentActivity.class, IncognitoDocumentActivity.class); |
| 185 sDocumentTabModelSelector = new DocumentTabModelSelector(activityDel
egate, | 146 sDocumentTabModelSelector = new DocumentTabModelSelector(activityDel
egate, |
| 186 new StorageDelegate(), new TabDelegate(false), new TabDelega
te(true)); | 147 new StorageDelegate(), new TabDelegate(false), new TabDelega
te(true)); |
| 187 } | 148 } |
| 188 return sDocumentTabModelSelector; | 149 return sDocumentTabModelSelector; |
| 189 } | 150 } |
| 190 } | 151 } |
| OLD | NEW |