Index: chrome/android/java/src/org/chromium/chrome/browser/datausage/DataUseTabUIManager.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/datausage/DataUseTabUIManager.java b/chrome/android/java/src/org/chromium/chrome/browser/datausage/DataUseTabUIManager.java |
index c353b1fbfe7cc347506f2d2258713b2197a2bd40..4b89a0bf2e0153e6567e23134475d82fbb4d38be 100644 |
--- a/chrome/android/java/src/org/chromium/chrome/browser/datausage/DataUseTabUIManager.java |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/datausage/DataUseTabUIManager.java |
@@ -60,6 +60,33 @@ public class DataUseTabUIManager { |
} |
/** |
+ * Notifies that the user clicked "Continue" when the dialog box warning about exiting data use |
+ * was shown. |
+ * |
+ * @param tab The tab on which the dialog box was shown. |
+ */ |
+ public static void userClickedContinueOnDialogBox(Tab tab) { |
+ nativeUserClickedContinueOnDialogBox( |
+ SessionTabHelper.sessionIdForTab(tab.getWebContents()), tab.getProfile()); |
+ } |
+ |
+ /** |
+ * Returns true if data use tracking is currently active on {@link tab} but will stop if the |
+ * navigation continues. |
+ * |
+ * @param tab The tab that is being queried for data use tracking. |
+ * @param pageTransitionType transition type of the navigation |
+ * @param packageName package name of the app package that started this navigation. |
+ * @return true If {@link tab} is currently tracked but would stop if the navigation were to |
+ * continue. |
+ */ |
+ public static boolean wouldDataUseTrackingEnd( |
megjablon
2015/12/18 20:17:53
Don't we still want to remove the event even if th
tbansal1
2015/12/18 21:35:37
I am not sure if I understood the comment. But, th
megjablon
2015/12/18 22:08:10
What I don't understand is why we need both wouldD
tbansal1
2015/12/18 22:33:09
wouldDataUseTrackingEnd is called before the navig
megjablon
2015/12/28 20:32:06
Why can't we just use wouldDataUseTrackingEnd in p
tbansal1
2015/12/28 23:55:52
Timeline for some tab with id t:
1) Some navigatio
megjablon
2015/12/29 00:05:21
Makes sense. I wasn't thinking about the fact that
tbansal1
2015/12/29 00:09:35
We would still need different functions even if th
megjablon
2015/12/29 00:38:24
Ok cool, SGTM!
|
+ Tab tab, String url, int pageTransitionType, String packageName) { |
+ return nativeWouldDataUseTrackingEnd(SessionTabHelper.sessionIdForTab(tab.getWebContents()), |
+ url, pageTransitionType, packageName, tab.getProfile()); |
+ } |
+ |
+ /** |
* Returns true if data use tracking has ended within a Tab. When data use tracking has |
* ended, returns true only once to signify the ended event. |
* |
@@ -99,7 +126,8 @@ public class DataUseTabUIManager { |
public static boolean shouldOverrideUrlLoading(Activity activity, |
final Tab tab, final String url, final int pageTransitionType, |
final String referrerUrl) { |
- if (!getOptedOutOfDataUseDialog(activity) && checkDataUseTrackingEnded(tab)) { |
+ if (!getOptedOutOfDataUseDialog(activity) |
+ && wouldDataUseTrackingEnd(tab, url, pageTransitionType, "")) { |
startDataUseDialog(activity, tab, url, pageTransitionType, referrerUrl); |
return true; |
} |
@@ -147,6 +175,7 @@ public class DataUseTabUIManager { |
} |
tab.loadUrl(loadUrlParams); |
recordDataUseUIAction(DataUseUIActions.DIALOG_CONTINUE_CLICKED); |
+ userClickedContinueOnDialogBox(tab); |
} |
}) |
.setNegativeButton(R.string.cancel, new OnClickListener() { |
@@ -199,6 +228,9 @@ public class DataUseTabUIManager { |
private static native boolean nativeCheckDataUseTrackingStarted(int tabId, Profile profile); |
private static native boolean nativeCheckDataUseTrackingEnded(int tabId, Profile profile); |
+ private static native void nativeUserClickedContinueOnDialogBox(int tabId, Profile profile); |
+ private static native boolean nativeWouldDataUseTrackingEnd( |
+ int tabId, String url, int pageTransitionType, String packageName, Profile jprofile); |
private static native void nativeOnCustomTabInitialNavigation(int tabID, String packageName, |
String url, Profile profile); |
} |