Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(112)

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/tabmodel/TabWindowManager.java

Issue 2123863004: ScreenCapture for Android phase1, part II (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments and rebase Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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.tabmodel; 5 package org.chromium.chrome.browser.tabmodel;
6 6
7 import android.app.Activity; 7 import android.app.Activity;
8 import android.util.SparseArray; 8 import android.util.SparseArray;
9 9
10 import org.chromium.base.ActivityState; 10 import org.chromium.base.ActivityState;
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 Tab tab = asyncTabParams.valueAt(i).getTabToReparent(); 150 Tab tab = asyncTabParams.valueAt(i).getTabToReparent();
151 if (tab != null && tab.isIncognito()) count++; 151 if (tab != null && tab.isIncognito()) count++;
152 } 152 }
153 return count; 153 return count;
154 } 154 }
155 155
156 /** 156 /**
157 * @param tabId The ID of the tab in question. 157 * @param tabId The ID of the tab in question.
158 * @return Whether the given tab exists in any currently loaded selector. 158 * @return Whether the given tab exists in any currently loaded selector.
159 */ 159 */
160 public boolean tabExistsInAnySelector(int tabId) { 160 public boolean tabExistsInAnySelector(int tabId) {
Ted C 2016/08/16 00:19:19 can you change this to be: return getTabById(tabI
braveyao 2016/08/16 23:05:49 Done. And there is no easy way to test this line:
161 for (int i = 0; i < mSelectors.size(); i++) { 161 for (int i = 0; i < mSelectors.size(); i++) {
162 TabModelSelector selector = mSelectors.get(i); 162 TabModelSelector selector = mSelectors.get(i);
163 if (selector != null) { 163 if (selector != null) {
164 if (TabModelUtils.getTabById(selector.getModel(false), tabId) != null 164 if (TabModelUtils.getTabById(selector.getModel(false), tabId) != null
165 || TabModelUtils.getTabById(selector.getModel(true), tab Id) != null) { 165 || TabModelUtils.getTabById(selector.getModel(true), tab Id) != null) {
166 return true; 166 return true;
167 } 167 }
168 } 168 }
169 } 169 }
170 170
171 // Account for tabs that were recently reparented and haven't been attac hed to new 171 // Account for tabs that were recently reparented and haven't been attac hed to new
172 // activities yet. 172 // activities yet.
173 return AsyncTabParamsManager.hasParamsForTabId(tabId); 173 return AsyncTabParamsManager.hasParamsForTabId(tabId);
174 } 174 }
175 175
176 /**
177 * @param tabId The ID of the tab in question.
178 * @return Specified {@link Tab} or {@code null} if the {@link Tab} is not f ound.
179 */
180 public Tab getTabById(int tabId) {
181 for (int i = 0; i < mSelectors.size(); i++) {
182 TabModelSelector selector = mSelectors.get(i);
183 if (selector != null) {
184 final Tab tab = selector.getTabById(tabId);
185 if (tab != null) return tab;
186 }
187 }
188
189 if (AsyncTabParamsManager.hasParamsForTabId(tabId)) {
190 return AsyncTabParamsManager.getAsyncTabParams().get(tabId).getTabTo Reparent();
191 }
192
193 return null;
194 }
195
176 @Override 196 @Override
177 public void onActivityStateChange(Activity activity, int newState) { 197 public void onActivityStateChange(Activity activity, int newState) {
178 if (newState == ActivityState.DESTROYED && mAssignments.containsKey(acti vity)) { 198 if (newState == ActivityState.DESTROYED && mAssignments.containsKey(acti vity)) {
179 int index = mSelectors.indexOf(mAssignments.remove(activity)); 199 int index = mSelectors.indexOf(mAssignments.remove(activity));
180 if (index >= 0) mSelectors.set(index, null); 200 if (index >= 0) mSelectors.set(index, null);
181 // TODO(dtrainor): Move TabModelSelector#destroy() calls here. 201 // TODO(dtrainor): Move TabModelSelector#destroy() calls here.
182 } 202 }
183 } 203 }
184 204
185 /** 205 /**
(...skipping 14 matching lines...) Expand all
200 220
201 private static class DefaultTabModelSelectorFactory implements TabModelSelec torFactory { 221 private static class DefaultTabModelSelectorFactory implements TabModelSelec torFactory {
202 @Override 222 @Override
203 public TabModelSelector buildSelector(ChromeActivity activity, WindowAnd roid windowAndroid, 223 public TabModelSelector buildSelector(ChromeActivity activity, WindowAnd roid windowAndroid,
204 int selectorIndex) { 224 int selectorIndex) {
205 assert activity == windowAndroid.getActivity().get(); 225 assert activity == windowAndroid.getActivity().get();
206 return new TabModelSelectorImpl(activity, selectorIndex, windowAndro id); 226 return new TabModelSelectorImpl(activity, selectorIndex, windowAndro id);
207 } 227 }
208 } 228 }
209 } 229 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698