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.webapps; | 5 package org.chromium.chrome.browser.webapps; |
6 | 6 |
7 import android.content.Intent; | 7 import android.content.Intent; |
8 | 8 |
9 import org.chromium.base.ContextUtils; | 9 import org.chromium.base.ContextUtils; |
10 import org.chromium.chrome.browser.ShortcutHelper; | 10 import org.chromium.chrome.browser.ShortcutHelper; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 @Override | 55 @Override |
56 public InterceptNavigationDelegateImpl createInterceptNavigationDele
gate(Tab tab) { | 56 public InterceptNavigationDelegateImpl createInterceptNavigationDele
gate(Tab tab) { |
57 return new InterceptNavigationDelegateImpl(tab) { | 57 return new InterceptNavigationDelegateImpl(tab) { |
58 @Override | 58 @Override |
59 public ExternalNavigationParams.Builder buildExternalNavigat
ionParams( | 59 public ExternalNavigationParams.Builder buildExternalNavigat
ionParams( |
60 NavigationParams navigationParams, | 60 NavigationParams navigationParams, |
61 TabRedirectHandler tabRedirectHandler, boolean shoul
dCloseTab) { | 61 TabRedirectHandler tabRedirectHandler, boolean shoul
dCloseTab) { |
62 ExternalNavigationParams.Builder builder = | 62 ExternalNavigationParams.Builder builder = |
63 super.buildExternalNavigationParams( | 63 super.buildExternalNavigationParams( |
64 navigationParams, tabRedirectHandler, sh
ouldCloseTab); | 64 navigationParams, tabRedirectHandler, sh
ouldCloseTab); |
65 builder.setIsWebApk(true); | 65 builder.setWebApkPackageName(getWebApkPackageName()); |
66 return builder; | 66 return builder; |
67 } | 67 } |
68 }; | 68 }; |
69 } | 69 } |
70 | 70 |
71 @Override | 71 @Override |
72 public AppBannerManager createAppBannerManager(Tab tab) { | 72 public AppBannerManager createAppBannerManager(Tab tab) { |
73 // Do not show app banners for WebAPKs regardless of the current
page URL. | 73 // Do not show app banners for WebAPKs regardless of the current
page URL. |
74 // A WebAPK can display a page outside of its WebAPK scope if a
page within the | 74 // A WebAPK can display a page outside of its WebAPK scope if a
page within the |
75 // WebAPK scope navigates via JavaScript while the WebAPK is in
the background. | 75 // WebAPK scope navigates via JavaScript while the WebAPK is in
the background. |
76 return null; | 76 return null; |
77 } | 77 } |
78 }; | 78 }; |
79 } | 79 } |
80 | 80 |
81 public void onStop() { | 81 public void onStop() { |
82 super.onStop(); | 82 super.onStop(); |
83 String packageName = getWebappInfo().webApkPackageName(); | |
84 WebApkServiceConnectionManager.getInstance().disconnect( | 83 WebApkServiceConnectionManager.getInstance().disconnect( |
85 ContextUtils.getApplicationContext(), packageName); | 84 ContextUtils.getApplicationContext(), getWebApkPackageName()); |
| 85 } |
| 86 |
| 87 /** |
| 88 * Returns the WebAPK's package name. |
| 89 */ |
| 90 private String getWebApkPackageName() { |
| 91 return getWebappInfo().webApkPackageName(); |
86 } | 92 } |
87 } | 93 } |
OLD | NEW |