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.tab; | 5 package org.chromium.chrome.browser.tab; |
6 | 6 |
7 import android.annotation.TargetApi; | 7 import android.annotation.TargetApi; |
8 import android.app.Activity; | 8 import android.app.Activity; |
9 import android.app.ActivityManager; | 9 import android.app.ActivityManager; |
10 import android.content.Context; | 10 import android.content.Context; |
11 import android.content.Intent; | 11 import android.content.Intent; |
12 import android.graphics.Rect; | 12 import android.graphics.Rect; |
13 import android.graphics.RectF; | 13 import android.graphics.RectF; |
14 import android.media.AudioManager; | 14 import android.media.AudioManager; |
15 import android.os.Build; | 15 import android.os.Build; |
16 import android.os.Handler; | 16 import android.os.Handler; |
17 import android.util.Pair; | 17 import android.util.Pair; |
18 import android.util.SparseArray; | |
18 import android.view.KeyEvent; | 19 import android.view.KeyEvent; |
19 import android.view.View; | 20 import android.view.View; |
20 | 21 |
21 import org.chromium.base.Log; | 22 import org.chromium.base.Log; |
22 import org.chromium.base.ObserverList.RewindableIterator; | 23 import org.chromium.base.ObserverList.RewindableIterator; |
23 import org.chromium.base.annotations.CalledByNative; | 24 import org.chromium.base.annotations.CalledByNative; |
24 import org.chromium.blink_public.platform.WebDisplayMode; | 25 import org.chromium.blink_public.platform.WebDisplayMode; |
25 import org.chromium.chrome.R; | 26 import org.chromium.chrome.R; |
26 import org.chromium.chrome.browser.ChromeApplication; | 27 import org.chromium.chrome.browser.ChromeApplication; |
27 import org.chromium.chrome.browser.RepostFormWarningDialog; | 28 import org.chromium.chrome.browser.RepostFormWarningDialog; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
67 | 68 |
68 protected final Tab mTab; | 69 protected final Tab mTab; |
69 | 70 |
70 private FindResultListener mFindResultListener; | 71 private FindResultListener mFindResultListener; |
71 | 72 |
72 private FindMatchRectsListener mFindMatchRectsListener = null; | 73 private FindMatchRectsListener mFindMatchRectsListener = null; |
73 | 74 |
74 private int mDisplayMode = WebDisplayMode.Browser; | 75 private int mDisplayMode = WebDisplayMode.Browser; |
75 | 76 |
76 protected Handler mHandler; | 77 protected Handler mHandler; |
78 // Static array for NotifyStopped() method under a static context for screen capture. | |
79 private static SparseArray<WebContents> sWebContentsMap = new SparseArray<We bContents>(); | |
gone
2016/08/10 19:04:02
1) private static final
2) Use javadoc syntax:
braveyao
2016/08/12 23:37:44
Done. Removed.
| |
80 | |
77 private final Runnable mCloseContentsRunnable = new Runnable() { | 81 private final Runnable mCloseContentsRunnable = new Runnable() { |
78 @Override | 82 @Override |
79 public void run() { | 83 public void run() { |
80 boolean isSelected = mTab.getTabModelSelector().getCurrentTab() == m Tab; | 84 boolean isSelected = mTab.getTabModelSelector().getCurrentTab() == m Tab; |
81 mTab.getTabModelSelector().closeTab(mTab); | 85 mTab.getTabModelSelector().closeTab(mTab); |
82 | 86 |
83 // If the parent Tab belongs to another Activity, fire the Intent to bring it back. | 87 // If the parent Tab belongs to another Activity, fire the Intent to bring it back. |
84 if (isSelected && mTab.getParentIntent() != null | 88 if (isSelected && mTab.getParentIntent() != null |
85 && mTab.getActivity().getIntent() != mTab.getParentIntent()) { | 89 && mTab.getActivity().getIntent() != mTab.getParentIntent()) { |
86 boolean mayLaunch = FeatureUtilities.isDocumentMode(mTab.getAppl icationContext()) | 90 boolean mayLaunch = FeatureUtilities.isDocumentMode(mTab.getAppl icationContext()) |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
219 | 223 |
220 RewindableIterator<TabObserver> observers = mTab.getTabObservers(); | 224 RewindableIterator<TabObserver> observers = mTab.getTabObservers(); |
221 while (observers.hasNext()) { | 225 while (observers.hasNext()) { |
222 observers.next().onToggleFullscreenMode(mTab, enableFullscreen); | 226 observers.next().onToggleFullscreenMode(mTab, enableFullscreen); |
223 } | 227 } |
224 } | 228 } |
225 | 229 |
226 @Override | 230 @Override |
227 public void navigationStateChanged(int flags) { | 231 public void navigationStateChanged(int flags) { |
228 if ((flags & InvalidateTypes.TAB) != 0) { | 232 if ((flags & InvalidateTypes.TAB) != 0) { |
233 int mediaType = MediaCaptureNotificationService.getMediaType( | |
234 isCapturingAudio(), isCapturingVideo(), isCapturingScreen()) ; | |
235 // Update webcontents map for notifying stop action to native for sc reen capture. | |
236 if (isCapturingScreen()) { | |
237 sWebContentsMap.put(mTab.getId(), mTab.getWebContents()); | |
gone
2016/08/10 19:04:02
1) Tabs can swap their WebContents, but you don't
braveyao
2016/08/12 23:37:44
Done.
Use the newly added TabWindowManager#getTabB
| |
238 } else { | |
239 sWebContentsMap.delete(mTab.getId()); | |
240 } | |
241 | |
229 MediaCaptureNotificationService.updateMediaNotificationForTab( | 242 MediaCaptureNotificationService.updateMediaNotificationForTab( |
230 mTab.getApplicationContext(), mTab.getId(), isCapturingAudio (), | 243 mTab.getApplicationContext(), mTab.getId(), mediaType, mTab. getUrl()); |
231 isCapturingVideo(), mTab.getUrl()); | |
232 } | 244 } |
233 if ((flags & InvalidateTypes.TITLE) != 0) { | 245 if ((flags & InvalidateTypes.TITLE) != 0) { |
234 // Update cached title then notify observers. | 246 // Update cached title then notify observers. |
235 mTab.updateTitle(); | 247 mTab.updateTitle(); |
236 } | 248 } |
237 if ((flags & InvalidateTypes.URL) != 0) { | 249 if ((flags & InvalidateTypes.URL) != 0) { |
238 RewindableIterator<TabObserver> observers = mTab.getTabObservers(); | 250 RewindableIterator<TabObserver> observers = mTab.getTabObservers(); |
239 while (observers.hasNext()) { | 251 while (observers.hasNext()) { |
240 observers.next().onUrlUpdated(mTab); | 252 observers.next().onUrlUpdated(mTab); |
241 } | 253 } |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
468 return !mTab.isClosing() && nativeIsCapturingAudio(mTab.getWebContents() ); | 480 return !mTab.isClosing() && nativeIsCapturingAudio(mTab.getWebContents() ); |
469 } | 481 } |
470 | 482 |
471 /** | 483 /** |
472 * @return Whether video is being captured. | 484 * @return Whether video is being captured. |
473 */ | 485 */ |
474 private boolean isCapturingVideo() { | 486 private boolean isCapturingVideo() { |
475 return !mTab.isClosing() && nativeIsCapturingVideo(mTab.getWebContents() ); | 487 return !mTab.isClosing() && nativeIsCapturingVideo(mTab.getWebContents() ); |
476 } | 488 } |
477 | 489 |
490 /** | |
491 * @return Whether screen is being captured. | |
492 */ | |
493 private boolean isCapturingScreen() { | |
494 return !mTab.isClosing() && nativeIsCapturingScreen(mTab.getWebContents( )); | |
495 } | |
496 | |
497 /** | |
498 * When STOP button in the media capture notification is clicked, pass the e vent to native | |
499 * to stop the media capture. | |
500 **/ | |
501 public static void notifyStopped(int tabId) { | |
502 if (sWebContentsMap.indexOfKey(tabId) >= 0) nativeNotifyStopped(sWebCont entsMap.get(tabId)); | |
503 } | |
504 | |
478 private static native void nativeOnRendererUnresponsive(WebContents webConte nts); | 505 private static native void nativeOnRendererUnresponsive(WebContents webConte nts); |
479 private static native void nativeOnRendererResponsive(WebContents webContent s); | 506 private static native void nativeOnRendererResponsive(WebContents webContent s); |
480 private static native boolean nativeIsCapturingAudio(WebContents webContents ); | 507 private static native boolean nativeIsCapturingAudio(WebContents webContents ); |
481 private static native boolean nativeIsCapturingVideo(WebContents webContents ); | 508 private static native boolean nativeIsCapturingVideo(WebContents webContents ); |
509 private static native boolean nativeIsCapturingScreen(WebContents webContent s); | |
510 private static native void nativeNotifyStopped(WebContents webContents); | |
482 } | 511 } |
OLD | NEW |