Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/media/remote/MediaRouteControllerDialogFactory.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/media/remote/MediaRouteControllerDialogFactory.java b/chrome/android/java/src/org/chromium/chrome/browser/media/remote/MediaRouteControllerDialogFactory.java |
| index 0f48bfa587f76358e1e38abaadc2fcff44bc6960..8b638b259dddc9a16914980ca3e5137f8bd35609 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/media/remote/MediaRouteControllerDialogFactory.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/media/remote/MediaRouteControllerDialogFactory.java |
| @@ -4,20 +4,33 @@ |
| package org.chromium.chrome.browser.media.remote; |
| +import android.annotation.SuppressLint; |
| import android.app.Activity; |
| import android.app.Dialog; |
| +import android.content.DialogInterface; |
| import android.os.Bundle; |
| +import android.os.Handler; |
| import android.support.v7.app.MediaRouteControllerDialog; |
| import android.support.v7.app.MediaRouteControllerDialogFragment; |
| import android.support.v7.app.MediaRouteDialogFactory; |
| import android.view.View; |
| import android.widget.FrameLayout; |
| +import org.chromium.base.Log; |
| +import org.chromium.chrome.browser.media.remote.MediaRouteController.MediaStateListener; |
| + |
| /** |
| * The Chrome implementation of the dialog factory so custom behavior can |
| * be injected for the disconnect button. |
| */ |
| public class MediaRouteControllerDialogFactory extends MediaRouteDialogFactory { |
| + private static final String TAG = "MRCtrlDlg"; |
| + |
| + private final MediaStateListener mPlayer; |
| + |
| + MediaRouteControllerDialogFactory(MediaStateListener player) { |
| + mPlayer = player; |
| + } |
| private static class SystemVisibilitySaver { |
| private int mSystemVisibility; |
| @@ -52,9 +65,27 @@ public class MediaRouteControllerDialogFactory extends MediaRouteDialogFactory { |
| * see https://crbug.com/618993. |
| */ |
| public static final class Fragment extends MediaRouteControllerDialogFragment { |
| + final Handler mHandler = new Handler(); |
| final SystemVisibilitySaver mVisibilitySaver = new SystemVisibilitySaver(); |
| + final MediaStateListener mPlayer; |
| - public Fragment() {} |
| + // The class has to be a public static class with a zero-argument constructor. |
| + // Since we can't pass any callbacks to the fragment easily, just close the dialog. |
| + // See https://crbug.com/618993. |
| + public Fragment() { |
| + mHandler.post(new Runnable() { |
| + @Override |
| + public void run() { |
| + Fragment.this.dismiss(); |
| + } |
| + }); |
| + mPlayer = null; |
| + } |
| + |
| + @SuppressLint("ValidFragment") |
| + Fragment(MediaStateListener player) { |
| + mPlayer = player; |
| + } |
| @Override |
| public Dialog onCreateDialog(Bundle saved) { |
| @@ -67,10 +98,24 @@ public class MediaRouteControllerDialogFactory extends MediaRouteDialogFactory { |
| super.onStop(); |
| mVisibilitySaver.restoreSystemVisibility(getActivity()); |
| } |
| + |
| + @Override |
| + public void onCancel(DialogInterface dialog) { |
| + Log.d(TAG, "onCancel " + mPlayer); |
|
mlamouri (slow - plz ping)
2016/11/02 14:59:10
Any reason to keep this Log but not below in onDis
whywhat
2016/11/02 21:05:00
Nope.
|
| + super.onCancel(dialog); |
| + if (mPlayer != null) mPlayer.onRouteDialogCancelled(); |
| + } |
| + |
| + @Override |
| + public void onDismiss(DialogInterface dialog) { |
| + super.onDismiss(dialog); |
| + |
| + if (mPlayer != null) mPlayer.onRouteDialogCancelled(); |
|
mlamouri (slow - plz ping)
2016/11/02 14:59:10
style nit: not super important but the style is in
whywhat
2016/11/02 21:05:00
Not sure how, the blank line is missing?
I don't n
|
| + } |
| } |
| @Override |
| public MediaRouteControllerDialogFragment onCreateControllerDialogFragment() { |
| - return new MediaRouteControllerDialogFragment(); |
| + return new Fragment(mPlayer); |
| } |
| } |