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.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; |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 29 import org.chromium.chrome.browser.document.DocumentWebContentsDelegate; | 29 import org.chromium.chrome.browser.document.DocumentWebContentsDelegate; |
| 30 import org.chromium.chrome.browser.findinpage.FindMatchRectsDetails; | 30 import org.chromium.chrome.browser.findinpage.FindMatchRectsDetails; |
| 31 import org.chromium.chrome.browser.findinpage.FindNotificationDetails; | 31 import org.chromium.chrome.browser.findinpage.FindNotificationDetails; |
| 32 import org.chromium.chrome.browser.media.MediaCaptureNotificationService; | 32 import org.chromium.chrome.browser.media.MediaCaptureNotificationService; |
| 33 import org.chromium.chrome.browser.policy.PolicyAuditor; | 33 import org.chromium.chrome.browser.policy.PolicyAuditor; |
| 34 import org.chromium.chrome.browser.policy.PolicyAuditor.AuditEvent; | 34 import org.chromium.chrome.browser.policy.PolicyAuditor.AuditEvent; |
| 35 import org.chromium.chrome.browser.tabmodel.TabCreatorManager.TabCreator; | 35 import org.chromium.chrome.browser.tabmodel.TabCreatorManager.TabCreator; |
| 36 import org.chromium.chrome.browser.tabmodel.TabModel; | 36 import org.chromium.chrome.browser.tabmodel.TabModel; |
| 37 import org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType; | 37 import org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType; |
| 38 import org.chromium.chrome.browser.tabmodel.TabModelUtils; | 38 import org.chromium.chrome.browser.tabmodel.TabModelUtils; |
| 39 import org.chromium.chrome.browser.tabmodel.TabWindowManager; | |
| 39 import org.chromium.chrome.browser.util.FeatureUtilities; | 40 import org.chromium.chrome.browser.util.FeatureUtilities; |
| 40 import org.chromium.components.web_contents_delegate_android.WebContentsDelegate Android; | 41 import org.chromium.components.web_contents_delegate_android.WebContentsDelegate Android; |
| 41 import org.chromium.content_public.browser.InvalidateTypes; | 42 import org.chromium.content_public.browser.InvalidateTypes; |
| 42 import org.chromium.content_public.browser.WebContents; | 43 import org.chromium.content_public.browser.WebContents; |
| 43 import org.chromium.content_public.common.ResourceRequestBody; | 44 import org.chromium.content_public.common.ResourceRequestBody; |
| 44 import org.chromium.ui.WindowOpenDisposition; | 45 import org.chromium.ui.WindowOpenDisposition; |
| 45 | 46 |
| 46 /** | 47 /** |
| 47 * A basic {@link TabWebContentsDelegateAndroid} that forwards some calls to the registered | 48 * A basic {@link TabWebContentsDelegateAndroid} that forwards some calls to the registered |
| 48 * {@link TabObserver}s. | 49 * {@link TabObserver}s. |
| (...skipping 18 matching lines...) Expand all 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 | |
| 77 private final Runnable mCloseContentsRunnable = new Runnable() { | 79 private final Runnable mCloseContentsRunnable = new Runnable() { |
| 78 @Override | 80 @Override |
| 79 public void run() { | 81 public void run() { |
| 80 boolean isSelected = mTab.getTabModelSelector().getCurrentTab() == m Tab; | 82 boolean isSelected = mTab.getTabModelSelector().getCurrentTab() == m Tab; |
| 81 mTab.getTabModelSelector().closeTab(mTab); | 83 mTab.getTabModelSelector().closeTab(mTab); |
| 82 | 84 |
| 83 // If the parent Tab belongs to another Activity, fire the Intent to bring it back. | 85 // If the parent Tab belongs to another Activity, fire the Intent to bring it back. |
| 84 if (isSelected && mTab.getParentIntent() != null | 86 if (isSelected && mTab.getParentIntent() != null |
| 85 && mTab.getActivity().getIntent() != mTab.getParentIntent()) { | 87 && mTab.getActivity().getIntent() != mTab.getParentIntent()) { |
| 86 boolean mayLaunch = FeatureUtilities.isDocumentMode(mTab.getAppl icationContext()) | 88 boolean mayLaunch = FeatureUtilities.isDocumentMode(mTab.getAppl icationContext()) |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 219 | 221 |
| 220 RewindableIterator<TabObserver> observers = mTab.getTabObservers(); | 222 RewindableIterator<TabObserver> observers = mTab.getTabObservers(); |
| 221 while (observers.hasNext()) { | 223 while (observers.hasNext()) { |
| 222 observers.next().onToggleFullscreenMode(mTab, enableFullscreen); | 224 observers.next().onToggleFullscreenMode(mTab, enableFullscreen); |
| 223 } | 225 } |
| 224 } | 226 } |
| 225 | 227 |
| 226 @Override | 228 @Override |
| 227 public void navigationStateChanged(int flags) { | 229 public void navigationStateChanged(int flags) { |
| 228 if ((flags & InvalidateTypes.TAB) != 0) { | 230 if ((flags & InvalidateTypes.TAB) != 0) { |
| 231 int mediaType = MediaCaptureNotificationService.getMediaType( | |
| 232 isCapturingAudio(), isCapturingVideo(), isCapturingScreen()) ; | |
| 229 MediaCaptureNotificationService.updateMediaNotificationForTab( | 233 MediaCaptureNotificationService.updateMediaNotificationForTab( |
| 230 mTab.getApplicationContext(), mTab.getId(), isCapturingAudio (), | 234 mTab.getApplicationContext(), mTab.getId(), mediaType, mTab. getUrl()); |
| 231 isCapturingVideo(), mTab.getUrl()); | |
| 232 } | 235 } |
| 233 if ((flags & InvalidateTypes.TITLE) != 0) { | 236 if ((flags & InvalidateTypes.TITLE) != 0) { |
| 234 // Update cached title then notify observers. | 237 // Update cached title then notify observers. |
| 235 mTab.updateTitle(); | 238 mTab.updateTitle(); |
| 236 } | 239 } |
| 237 if ((flags & InvalidateTypes.URL) != 0) { | 240 if ((flags & InvalidateTypes.URL) != 0) { |
| 238 RewindableIterator<TabObserver> observers = mTab.getTabObservers(); | 241 RewindableIterator<TabObserver> observers = mTab.getTabObservers(); |
| 239 while (observers.hasNext()) { | 242 while (observers.hasNext()) { |
| 240 observers.next().onUrlUpdated(mTab); | 243 observers.next().onUrlUpdated(mTab); |
| 241 } | 244 } |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 468 return !mTab.isClosing() && nativeIsCapturingAudio(mTab.getWebContents() ); | 471 return !mTab.isClosing() && nativeIsCapturingAudio(mTab.getWebContents() ); |
| 469 } | 472 } |
| 470 | 473 |
| 471 /** | 474 /** |
| 472 * @return Whether video is being captured. | 475 * @return Whether video is being captured. |
| 473 */ | 476 */ |
| 474 private boolean isCapturingVideo() { | 477 private boolean isCapturingVideo() { |
| 475 return !mTab.isClosing() && nativeIsCapturingVideo(mTab.getWebContents() ); | 478 return !mTab.isClosing() && nativeIsCapturingVideo(mTab.getWebContents() ); |
| 476 } | 479 } |
| 477 | 480 |
| 481 /** | |
| 482 * @return Whether screen is being captured. | |
| 483 */ | |
| 484 private boolean isCapturingScreen() { | |
| 485 return !mTab.isClosing() && nativeIsCapturingScreen(mTab.getWebContents( )); | |
| 486 } | |
| 487 | |
| 488 /** | |
| 489 * When STOP button in the media capture notification is clicked, pass the e vent to native | |
| 490 * to stop the media capture. | |
| 491 */ | |
|
braveyao
2016/08/12 23:37:44
Done
| |
| 492 public static void notifyStopped(int tabId) { | |
| 493 final Tab tab = TabWindowManager.getInstance().getTabById(tabId); | |
| 494 if (tab != null) nativeNotifyStopped(tab.getWebContents()); | |
| 495 } | |
| 496 | |
| 478 private static native void nativeOnRendererUnresponsive(WebContents webConte nts); | 497 private static native void nativeOnRendererUnresponsive(WebContents webConte nts); |
| 479 private static native void nativeOnRendererResponsive(WebContents webContent s); | 498 private static native void nativeOnRendererResponsive(WebContents webContent s); |
| 480 private static native boolean nativeIsCapturingAudio(WebContents webContents ); | 499 private static native boolean nativeIsCapturingAudio(WebContents webContents ); |
| 481 private static native boolean nativeIsCapturingVideo(WebContents webContents ); | 500 private static native boolean nativeIsCapturingVideo(WebContents webContents ); |
| 501 private static native boolean nativeIsCapturingScreen(WebContents webContent s); | |
| 502 private static native void nativeNotifyStopped(WebContents webContents); | |
| 482 } | 503 } |
| OLD | NEW |