| Index: chrome/android/java/src/org/chromium/chrome/browser/ChromeActivity.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ChromeActivity.java b/chrome/android/java/src/org/chromium/chrome/browser/ChromeActivity.java
|
| index d9f07392501309ecc0707ec4e864757ad68554aa..d400bdf0505ebc60877846e302bd4e81e185471a 100644
|
| --- a/chrome/android/java/src/org/chromium/chrome/browser/ChromeActivity.java
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/ChromeActivity.java
|
| @@ -761,36 +761,50 @@ public abstract class ChromeActivity extends AsyncInitializationActivity
|
| @SuppressLint("NewApi")
|
| @Override
|
| protected final void onDestroy() {
|
| - if (mReaderModeActivityDelegate != null) mReaderModeActivityDelegate.destroy();
|
| - if (mContextualSearchManager != null) mContextualSearchManager.destroy();
|
| - if (mTabModelSelectorTabObserver != null) mTabModelSelectorTabObserver.destroy();
|
| + if (mReaderModeActivityDelegate != null) {
|
| + mReaderModeActivityDelegate.destroy();
|
| + mReaderModeActivityDelegate = null;
|
| + }
|
| +
|
| + if (mContextualSearchManager != null) {
|
| + mContextualSearchManager.destroy();
|
| + mContextualSearchManager = null;
|
| + }
|
| +
|
| + if (mTabModelSelectorTabObserver != null) {
|
| + mTabModelSelectorTabObserver.destroy();
|
| + mTabModelSelectorTabObserver = null;
|
| + }
|
| +
|
| if (mCompositorViewHolder != null) {
|
| if (mCompositorViewHolder.getLayoutManager() != null) {
|
| mCompositorViewHolder.getLayoutManager().removeSceneChangeObserver(this);
|
| }
|
| mCompositorViewHolder.shutDown();
|
| + mCompositorViewHolder = null;
|
| }
|
| +
|
| onDestroyInternal();
|
|
|
| + if (mToolbarManager != null) {
|
| + mToolbarManager.destroy();
|
| + mToolbarManager = null;
|
| + }
|
| +
|
| TabModelSelector selector = getTabModelSelector();
|
| if (selector != null) selector.destroy();
|
|
|
| - if (mWindowAndroid != null) mWindowAndroid.destroy();
|
| - if (!Locale.getDefault().equals(mCurrentLocale)) {
|
| - // This is a hack to relaunch renderer processes. Killing the main process also kills
|
| - // its dependent (renderer) processes, and Android's activity manager service seems to
|
| - // still relaunch the activity even when process dies in onDestroy().
|
| - // This shouldn't be moved to ChromeActivity since it may cause a crash if
|
| - // you kill the process from EmbedContentViewActivity since Preferences looks up
|
| - // ChildAccountManager#hasChildAccount() when it is not set.
|
| - // TODO(changwan): Implement a more generic and safe relaunch mechanism such as
|
| - // killing dependent processes on onDestroy and launching them at onCreate().
|
| - Log.w(TAG, "Forcefully killing process...");
|
| - Process.killProcess(Process.myPid());
|
| + if (mWindowAndroid != null) {
|
| + mWindowAndroid.destroy();
|
| + mWindowAndroid = null;
|
| }
|
| +
|
| getChromeApplication().removePolicyChangeListener(this);
|
| - if (mTabContentManager != null) mTabContentManager.destroy();
|
| - if (mTabModelSelectorTabObserver != null) mTabModelSelectorTabObserver.destroy();
|
| +
|
| + if (mTabContentManager != null) {
|
| + mTabContentManager.destroy();
|
| + mTabContentManager = null;
|
| + }
|
|
|
| AccessibilityManager manager = (AccessibilityManager)
|
| getBaseContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
|
| @@ -798,7 +812,18 @@ public abstract class ChromeActivity extends AsyncInitializationActivity
|
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
| manager.removeTouchExplorationStateChangeListener(mTouchExplorationStateChangeListener);
|
| }
|
| +
|
| super.onDestroy();
|
| +
|
| + if (!Locale.getDefault().equals(mCurrentLocale)) {
|
| + // This is a hack to relaunch renderer processes. Killing the main process also kills
|
| + // its dependent (renderer) processes, and Android's activity manager service seems to
|
| + // still relaunch the activity even when process dies in onDestroy().
|
| + // TODO(changwan): Implement a more generic and safe relaunch mechanism, like killing
|
| + // dependent processes in onDestroy() and launching them at onCreate().
|
| + Log.w(TAG, "Forcefully killing process...");
|
| + Process.killProcess(Process.myPid());
|
| + }
|
| }
|
|
|
| /**
|
| @@ -810,7 +835,6 @@ public abstract class ChromeActivity extends AsyncInitializationActivity
|
| * by the {@link WindowAndroid}.
|
| */
|
| protected void onDestroyInternal() {
|
| - if (mToolbarManager != null) mToolbarManager.destroy();
|
| }
|
|
|
| /**
|
|
|