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.components.web_contents_delegate_android.WebContentsDelegate
Android; | 40 import org.chromium.components.web_contents_delegate_android.WebContentsDelegate
Android; |
40 import org.chromium.content_public.browser.InvalidateTypes; | 41 import org.chromium.content_public.browser.InvalidateTypes; |
41 import org.chromium.content_public.browser.WebContents; | 42 import org.chromium.content_public.browser.WebContents; |
42 import org.chromium.content_public.common.ResourceRequestBody; | 43 import org.chromium.content_public.common.ResourceRequestBody; |
43 import org.chromium.ui.WindowOpenDisposition; | 44 import org.chromium.ui.WindowOpenDisposition; |
44 | 45 |
45 /** | 46 /** |
46 * A basic {@link TabWebContentsDelegateAndroid} that forwards some calls to the
registered | 47 * A basic {@link TabWebContentsDelegateAndroid} that forwards some calls to the
registered |
47 * {@link TabObserver}s. | 48 * {@link TabObserver}s. |
48 */ | 49 */ |
(...skipping 17 matching lines...) Expand all Loading... |
66 | 67 |
67 protected final Tab mTab; | 68 protected final Tab mTab; |
68 | 69 |
69 private FindResultListener mFindResultListener; | 70 private FindResultListener mFindResultListener; |
70 | 71 |
71 private FindMatchRectsListener mFindMatchRectsListener = null; | 72 private FindMatchRectsListener mFindMatchRectsListener = null; |
72 | 73 |
73 private int mDisplayMode = WebDisplayMode.Browser; | 74 private int mDisplayMode = WebDisplayMode.Browser; |
74 | 75 |
75 protected Handler mHandler; | 76 protected Handler mHandler; |
| 77 |
76 private final Runnable mCloseContentsRunnable = new Runnable() { | 78 private final Runnable mCloseContentsRunnable = new Runnable() { |
77 @Override | 79 @Override |
78 public void run() { | 80 public void run() { |
79 boolean isSelected = mTab.getTabModelSelector().getCurrentTab() == m
Tab; | 81 boolean isSelected = mTab.getTabModelSelector().getCurrentTab() == m
Tab; |
80 mTab.getTabModelSelector().closeTab(mTab); | 82 mTab.getTabModelSelector().closeTab(mTab); |
81 | 83 |
82 // If the parent Tab belongs to another Activity, fire the Intent to
bring it back. | 84 // If the parent Tab belongs to another Activity, fire the Intent to
bring it back. |
83 if (isSelected && mTab.getParentIntent() != null | 85 if (isSelected && mTab.getParentIntent() != null |
84 && mTab.getActivity().getIntent() != mTab.getParentIntent())
{ | 86 && mTab.getActivity().getIntent() != mTab.getParentIntent())
{ |
85 mTab.getActivity().startActivity(mTab.getParentIntent()); | 87 mTab.getActivity().startActivity(mTab.getParentIntent()); |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 | 216 |
215 RewindableIterator<TabObserver> observers = mTab.getTabObservers(); | 217 RewindableIterator<TabObserver> observers = mTab.getTabObservers(); |
216 while (observers.hasNext()) { | 218 while (observers.hasNext()) { |
217 observers.next().onToggleFullscreenMode(mTab, enableFullscreen); | 219 observers.next().onToggleFullscreenMode(mTab, enableFullscreen); |
218 } | 220 } |
219 } | 221 } |
220 | 222 |
221 @Override | 223 @Override |
222 public void navigationStateChanged(int flags) { | 224 public void navigationStateChanged(int flags) { |
223 if ((flags & InvalidateTypes.TAB) != 0) { | 225 if ((flags & InvalidateTypes.TAB) != 0) { |
| 226 int mediaType = MediaCaptureNotificationService.getMediaType( |
| 227 isCapturingAudio(), isCapturingVideo(), isCapturingScreen())
; |
224 MediaCaptureNotificationService.updateMediaNotificationForTab( | 228 MediaCaptureNotificationService.updateMediaNotificationForTab( |
225 mTab.getApplicationContext(), mTab.getId(), isCapturingAudio
(), | 229 mTab.getApplicationContext(), mTab.getId(), mediaType, mTab.
getUrl()); |
226 isCapturingVideo(), mTab.getUrl()); | |
227 } | 230 } |
228 if ((flags & InvalidateTypes.TITLE) != 0) { | 231 if ((flags & InvalidateTypes.TITLE) != 0) { |
229 // Update cached title then notify observers. | 232 // Update cached title then notify observers. |
230 mTab.updateTitle(); | 233 mTab.updateTitle(); |
231 } | 234 } |
232 if ((flags & InvalidateTypes.URL) != 0) { | 235 if ((flags & InvalidateTypes.URL) != 0) { |
233 RewindableIterator<TabObserver> observers = mTab.getTabObservers(); | 236 RewindableIterator<TabObserver> observers = mTab.getTabObservers(); |
234 while (observers.hasNext()) { | 237 while (observers.hasNext()) { |
235 observers.next().onUrlUpdated(mTab); | 238 observers.next().onUrlUpdated(mTab); |
236 } | 239 } |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 return !mTab.isClosing() && nativeIsCapturingAudio(mTab.getWebContents()
); | 466 return !mTab.isClosing() && nativeIsCapturingAudio(mTab.getWebContents()
); |
464 } | 467 } |
465 | 468 |
466 /** | 469 /** |
467 * @return Whether video is being captured. | 470 * @return Whether video is being captured. |
468 */ | 471 */ |
469 private boolean isCapturingVideo() { | 472 private boolean isCapturingVideo() { |
470 return !mTab.isClosing() && nativeIsCapturingVideo(mTab.getWebContents()
); | 473 return !mTab.isClosing() && nativeIsCapturingVideo(mTab.getWebContents()
); |
471 } | 474 } |
472 | 475 |
| 476 /** |
| 477 * @return Whether screen is being captured. |
| 478 */ |
| 479 private boolean isCapturingScreen() { |
| 480 return !mTab.isClosing() && nativeIsCapturingScreen(mTab.getWebContents(
)); |
| 481 } |
| 482 |
| 483 /** |
| 484 * When STOP button in the media capture notification is clicked, pass the e
vent to native |
| 485 * to stop the media capture. |
| 486 */ |
| 487 public static void notifyStopped(int tabId) { |
| 488 final Tab tab = TabWindowManager.getInstance().getTabById(tabId); |
| 489 if (tab != null) nativeNotifyStopped(tab.getWebContents()); |
| 490 } |
| 491 |
473 private static native void nativeOnRendererUnresponsive(WebContents webConte
nts); | 492 private static native void nativeOnRendererUnresponsive(WebContents webConte
nts); |
474 private static native void nativeOnRendererResponsive(WebContents webContent
s); | 493 private static native void nativeOnRendererResponsive(WebContents webContent
s); |
475 private static native boolean nativeIsCapturingAudio(WebContents webContents
); | 494 private static native boolean nativeIsCapturingAudio(WebContents webContents
); |
476 private static native boolean nativeIsCapturingVideo(WebContents webContents
); | 495 private static native boolean nativeIsCapturingVideo(WebContents webContents
); |
| 496 private static native boolean nativeIsCapturingScreen(WebContents webContent
s); |
| 497 private static native void nativeNotifyStopped(WebContents webContents); |
477 } | 498 } |
OLD | NEW |