Chromium Code Reviews| 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 86 | 86 |
| 87 WebappInfo newWebappInfo = createWebappInfo(intent); | 87 WebappInfo newWebappInfo = createWebappInfo(intent); |
| 88 if (newWebappInfo == null) { | 88 if (newWebappInfo == null) { |
| 89 Log.e(TAG, "Failed to parse new Intent: " + intent); | 89 Log.e(TAG, "Failed to parse new Intent: " + intent); |
| 90 finish(); | 90 finish(); |
| 91 } else if (!TextUtils.equals(mWebappInfo.id(), newWebappInfo.id())) { | 91 } else if (!TextUtils.equals(mWebappInfo.id(), newWebappInfo.id())) { |
| 92 mWebappInfo = newWebappInfo; | 92 mWebappInfo = newWebappInfo; |
| 93 resetSavedInstanceState(); | 93 resetSavedInstanceState(); |
| 94 if (mIsInitialized) initializeUI(null); | 94 if (mIsInitialized) initializeUI(null); |
| 95 // TODO(dominickn): send the web app into fullscreen if mDisplayMode is | 95 // TODO(dominickn): send the web app into fullscreen if mDisplayMode is |
| 96 // WebDisplayMode.Fullscreen. See crbug.com/581522 | 96 // WebDisplayMode.Fullscreen. See crbug.com/581522 |
|
dominickn
2017/01/16 22:49:01
Nit: remove this TODO.
Leo
2017/01/18 23:03:12
Acknowledged.
| |
| 97 } | 97 } |
| 98 } | 98 } |
| 99 | 99 |
| 100 protected boolean isInitialized() { | 100 protected boolean isInitialized() { |
| 101 return mIsInitialized; | 101 return mIsInitialized; |
| 102 } | 102 } |
| 103 | 103 |
| 104 protected WebappInfo createWebappInfo(Intent intent) { | 104 protected WebappInfo createWebappInfo(Intent intent) { |
| 105 return (intent == null) ? WebappInfo.createEmpty() : WebappInfo.create(i ntent); | 105 return (intent == null) ? WebappInfo.createEmpty() : WebappInfo.create(i ntent); |
| 106 } | 106 } |
| 107 | 107 |
| 108 private void initializeUI(Bundle savedInstanceState) { | 108 private void initializeUI(Bundle savedInstanceState) { |
| 109 // We do not load URL when restoring from saved instance states. | 109 // We do not load URL when restoring from saved instance states. |
| 110 if (savedInstanceState == null && mWebappInfo.isInitialized()) { | 110 if (savedInstanceState == null && mWebappInfo.isInitialized()) { |
| 111 if (TextUtils.isEmpty(getActivityTab().getUrl())) { | 111 if (TextUtils.isEmpty(getActivityTab().getUrl())) { |
| 112 getActivityTab().loadUrl(new LoadUrlParams( | 112 getActivityTab().loadUrl(new LoadUrlParams( |
| 113 mWebappInfo.uri().toString(), PageTransition.AUTO_TOPLEV EL)); | 113 mWebappInfo.uri().toString(), PageTransition.AUTO_TOPLEV EL)); |
| 114 } | 114 } |
| 115 } else { | 115 } else { |
| 116 if (NetworkChangeNotifier.isOnline()) getActivityTab().reloadIgnorin gCache(); | 116 if (NetworkChangeNotifier.isOnline()) getActivityTab().reloadIgnorin gCache(); |
| 117 } | 117 } |
| 118 | 118 |
| 119 getActivityTab().addObserver(createTabObserver()); | 119 getActivityTab().addObserver(createTabObserver()); |
| 120 getActivityTab().getTabWebContentsDelegateAndroid().setDisplayMode( | 120 getActivityTab().getTabWebContentsDelegateAndroid().setDisplayMode( |
| 121 WebDisplayMode.Standalone); | 121 WebDisplayMode.Standalone); |
|
dominickn
2017/01/16 22:49:01
Nit: this should be:
getActivityTab().getTabWebCo
Leo
2017/01/18 05:09:40
Thanks for the tips. So what will happen if the di
dominickn
2017/01/18 05:56:17
Currently, minimal-ui does not open a WebappActivi
Leo
2017/01/18 23:03:12
Thanks for the explanation. Good to know that.
| |
| 122 // TODO(dominickn): send the web app into fullscreen if mDisplayMode is | 122 if (mWebappInfo.displayMode() == WebDisplayMode.Fullscreen) { |
| 123 // WebDisplayMode.Fullscreen. See crbug.com/581522 | 123 enterImmersiveMode(getWindow().getDecorView()); |
| 124 getActivityTab().getTabWebContentsDelegateAndroid().setDisplayMode( | |
| 125 WebDisplayMode.Fullscreen); | |
| 126 } | |
| 124 } | 127 } |
| 125 | 128 |
| 126 @Override | 129 @Override |
| 127 public void preInflationStartup() { | 130 public void preInflationStartup() { |
| 128 WebappInfo info = createWebappInfo(getIntent()); | 131 WebappInfo info = createWebappInfo(getIntent()); |
| 129 | 132 |
| 130 String id = ""; | 133 String id = ""; |
| 131 if (info != null) { | 134 if (info != null) { |
| 132 mWebappInfo = info; | 135 mWebappInfo = info; |
| 133 id = info.id(); | 136 id = info.id(); |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 583 return new WebappDelegateFactory(this); | 586 return new WebappDelegateFactory(this); |
| 584 } | 587 } |
| 585 | 588 |
| 586 // We're temporarily disable CS on webapp since there are some issues. (http ://crbug.com/471950) | 589 // We're temporarily disable CS on webapp since there are some issues. (http ://crbug.com/471950) |
| 587 // TODO(changwan): re-enable it once the issues are resolved. | 590 // TODO(changwan): re-enable it once the issues are resolved. |
| 588 @Override | 591 @Override |
| 589 protected boolean isContextualSearchAllowed() { | 592 protected boolean isContextualSearchAllowed() { |
| 590 return false; | 593 return false; |
| 591 } | 594 } |
| 592 } | 595 } |
| OLD | NEW |