| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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.webapps; | 5 package org.chromium.chrome.browser.webapps; |
| 6 | 6 |
| 7 import android.content.Intent; | 7 import android.content.Intent; |
| 8 import android.graphics.Bitmap; | 8 import android.graphics.Bitmap; |
| 9 import android.graphics.Color; | 9 import android.graphics.Color; |
| 10 import android.graphics.drawable.Drawable; | 10 import android.graphics.drawable.Drawable; |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 super.onNewIntent(intent); | 101 super.onNewIntent(intent); |
| 102 | 102 |
| 103 WebappInfo newWebappInfo = createWebappInfo(intent); | 103 WebappInfo newWebappInfo = createWebappInfo(intent); |
| 104 if (newWebappInfo == null) { | 104 if (newWebappInfo == null) { |
| 105 Log.e(TAG, "Failed to parse new Intent: " + intent); | 105 Log.e(TAG, "Failed to parse new Intent: " + intent); |
| 106 ApiCompatibilityUtils.finishAndRemoveTask(this); | 106 ApiCompatibilityUtils.finishAndRemoveTask(this); |
| 107 } else if (!TextUtils.equals(mWebappInfo.id(), newWebappInfo.id())) { | 107 } else if (!TextUtils.equals(mWebappInfo.id(), newWebappInfo.id())) { |
| 108 mWebappInfo = newWebappInfo; | 108 mWebappInfo = newWebappInfo; |
| 109 resetSavedInstanceState(); | 109 resetSavedInstanceState(); |
| 110 if (mIsInitialized) initializeUI(null); | 110 if (mIsInitialized) initializeUI(null); |
| 111 } else if (newWebappInfo.shouldForceNavigation() && mIsInitialized) { |
| 112 getActivityTab().loadUrl(new LoadUrlParams( |
| 113 newWebappInfo.uri().toString(), PageTransition.AUTO_TOPLEVEL
)); |
| 111 } | 114 } |
| 112 } | 115 } |
| 113 | 116 |
| 114 protected boolean isInitialized() { | 117 protected boolean isInitialized() { |
| 115 return mIsInitialized; | 118 return mIsInitialized; |
| 116 } | 119 } |
| 117 | 120 |
| 118 protected WebappInfo createWebappInfo(Intent intent) { | 121 protected WebappInfo createWebappInfo(Intent intent) { |
| 119 return (intent == null) ? WebappInfo.createEmpty() : WebappInfo.create(i
ntent); | 122 return (intent == null) ? WebappInfo.createEmpty() : WebappInfo.create(i
ntent); |
| 120 } | 123 } |
| 121 | 124 |
| 122 private void initializeUI(Bundle savedInstanceState) { | 125 protected void initializeUI(Bundle savedInstanceState) { |
| 123 // We do not load URL when restoring from saved instance states. | 126 // We do not load URL when restoring from saved instance states. |
| 124 if (savedInstanceState == null && mWebappInfo.isInitialized()) { | 127 if (savedInstanceState == null && mWebappInfo.isInitialized()) { |
| 125 if (TextUtils.isEmpty(getActivityTab().getUrl())) { | 128 if (TextUtils.isEmpty(getActivityTab().getUrl())) { |
| 126 getActivityTab().loadUrl(new LoadUrlParams( | 129 getActivityTab().loadUrl(new LoadUrlParams( |
| 127 mWebappInfo.uri().toString(), PageTransition.AUTO_TOPLEV
EL)); | 130 mWebappInfo.uri().toString(), PageTransition.AUTO_TOPLEV
EL)); |
| 128 } | 131 } |
| 129 } else { | 132 } else { |
| 130 if (NetworkChangeNotifier.isOnline()) getActivityTab().reloadIgnorin
gCache(); | 133 if (NetworkChangeNotifier.isOnline()) getActivityTab().reloadIgnorin
gCache(); |
| 131 } | 134 } |
| 132 | 135 |
| (...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 702 return new WebappDelegateFactory(this); | 705 return new WebappDelegateFactory(this); |
| 703 } | 706 } |
| 704 | 707 |
| 705 // We're temporarily disable CS on webapp since there are some issues. (http
://crbug.com/471950) | 708 // We're temporarily disable CS on webapp since there are some issues. (http
://crbug.com/471950) |
| 706 // TODO(changwan): re-enable it once the issues are resolved. | 709 // TODO(changwan): re-enable it once the issues are resolved. |
| 707 @Override | 710 @Override |
| 708 protected boolean isContextualSearchAllowed() { | 711 protected boolean isContextualSearchAllowed() { |
| 709 return false; | 712 return false; |
| 710 } | 713 } |
| 711 } | 714 } |
| OLD | NEW |