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 /** | 7 /** |
8 * Type of WebappActivity that has the ability to swap out the webapp it is curr
ently showing for a | 8 * Type of WebappActivity that has the ability to swap out the webapp it is curr
ently showing for a |
9 * new one. This is necessary on Android versions older than L because the frame
work had no way of | 9 * new one. This is necessary on Android versions older than L because the frame
work had no way of |
10 * allowing multiple instances of an Activity to be launched and show up as diff
erent tasks. | 10 * allowing multiple instances of an Activity to be launched and show up as diff
erent tasks. |
(...skipping 17 matching lines...) Expand all Loading... |
28 | 28 |
29 @Override | 29 @Override |
30 protected String getId() { | 30 protected String getId() { |
31 return String.valueOf(mActivityIndex); | 31 return String.valueOf(mActivityIndex); |
32 } | 32 } |
33 | 33 |
34 /** | 34 /** |
35 * Marks that this WebappActivity is recently used to prevent other webapps
from using it. | 35 * Marks that this WebappActivity is recently used to prevent other webapps
from using it. |
36 */ | 36 */ |
37 private void markActivityUsed() { | 37 private void markActivityUsed() { |
38 ActivityAssigner.instance(this).markActivityUsed(mActivityIndex, getWeba
ppInfo().id()); | 38 ActivityAssigner.instance(getWebappInfo().id()).markActivityUsed( |
| 39 mActivityIndex, getWebappInfo().id()); |
39 } | 40 } |
40 | 41 |
41 /** | 42 /** |
42 * Pulls out the index of the WebappActivity subclass that is being used. | 43 * Pulls out the index of the WebappActivity subclass that is being used. |
43 * e.g. WebappActivity0.getActivityIndex() will return 0. | 44 * e.g. WebappActivity0.getActivityIndex() will return 0. |
44 * @return The index corresponding to this WebappActivity. | 45 * @return The index corresponding to this WebappActivity. |
45 */ | 46 */ |
46 private int getActivityIndex() { | 47 private int getActivityIndex() { |
47 // Cull out the activity index from the class name. | 48 // Cull out the activity index from the class name. |
48 String baseClassName = WebappActivity.class.getSimpleName(); | 49 String baseClassName = WebappActivity.class.getSimpleName(); |
49 String className = this.getClass().getSimpleName(); | 50 String className = this.getClass().getSimpleName(); |
50 assert className.matches("^" + baseClassName + "[0-9]+$"); | 51 assert className.matches("^" + baseClassName + "[0-9]+$"); |
51 String indexString = className.substring(baseClassName.length()); | 52 String indexString = className.substring(baseClassName.length()); |
52 return Integer.parseInt(indexString); | 53 return Integer.parseInt(indexString); |
53 } | 54 } |
54 } | 55 } |
OLD | NEW |