Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(236)

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/metrics/UmaSessionStats.java

Issue 2235533002: Revert "Changed NavigationController access to through tab in Java code" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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.metrics; 5 package org.chromium.chrome.browser.metrics;
6 6
7 import android.content.ComponentCallbacks; 7 import android.content.ComponentCallbacks;
8 import android.content.Context; 8 import android.content.Context;
9 import android.content.res.Configuration; 9 import android.content.res.Configuration;
10 import android.text.TextUtils; 10 import android.text.TextUtils;
11 11
12 import org.chromium.base.ContextUtils; 12 import org.chromium.base.ContextUtils;
13 import org.chromium.chrome.browser.preferences.PrefServiceBridge; 13 import org.chromium.chrome.browser.preferences.PrefServiceBridge;
14 import org.chromium.chrome.browser.preferences.privacy.CrashReportingPermissionM anager; 14 import org.chromium.chrome.browser.preferences.privacy.CrashReportingPermissionM anager;
15 import org.chromium.chrome.browser.preferences.privacy.PrivacyPreferencesManager ; 15 import org.chromium.chrome.browser.preferences.privacy.PrivacyPreferencesManager ;
16 import org.chromium.chrome.browser.tab.Tab; 16 import org.chromium.chrome.browser.tab.Tab;
17 import org.chromium.chrome.browser.tabmodel.TabModel; 17 import org.chromium.chrome.browser.tabmodel.TabModel;
18 import org.chromium.chrome.browser.tabmodel.TabModelSelector; 18 import org.chromium.chrome.browser.tabmodel.TabModelSelector;
19 import org.chromium.chrome.browser.tabmodel.TabModelSelectorTabObserver; 19 import org.chromium.chrome.browser.tabmodel.TabModelSelectorTabObserver;
20 import org.chromium.components.variations.VariationsAssociatedData; 20 import org.chromium.components.variations.VariationsAssociatedData;
21 import org.chromium.content_public.browser.WebContents;
21 import org.chromium.net.NetworkChangeNotifier; 22 import org.chromium.net.NetworkChangeNotifier;
22 23
23 /** 24 /**
24 * Mainly sets up session stats for chrome. A session is defined as the duration when the 25 * Mainly sets up session stats for chrome. A session is defined as the duration when the
25 * application is in the foreground. Also used to communicate information betwe en Chrome 26 * application is in the foreground. Also used to communicate information betwe en Chrome
26 * and the framework's MetricService. 27 * and the framework's MetricService.
27 */ 28 */
28 public class UmaSessionStats implements NetworkChangeNotifier.ConnectionTypeObse rver { 29 public class UmaSessionStats implements NetworkChangeNotifier.ConnectionTypeObse rver {
29 public static final String LAST_USED_TIME_PREF = "umasessionstats.lastusedti me"; 30 public static final String LAST_USED_TIME_PREF = "umasessionstats.lastusedti me";
30 31
(...skipping 14 matching lines...) Expand all
45 private final CrashReportingPermissionManager mReportingPermissionManager; 46 private final CrashReportingPermissionManager mReportingPermissionManager;
46 47
47 public UmaSessionStats(Context context) { 48 public UmaSessionStats(Context context) {
48 mContext = context; 49 mContext = context;
49 mIsMultiWindowCapable = context.getPackageManager().hasSystemFeature( 50 mIsMultiWindowCapable = context.getPackageManager().hasSystemFeature(
50 SAMSUNG_MULTWINDOW_PACKAGE); 51 SAMSUNG_MULTWINDOW_PACKAGE);
51 mReportingPermissionManager = PrivacyPreferencesManager.getInstance(); 52 mReportingPermissionManager = PrivacyPreferencesManager.getInstance();
52 } 53 }
53 54
54 private void recordPageLoadStats(Tab tab) { 55 private void recordPageLoadStats(Tab tab) {
55 boolean isDesktopUserAgent = tab.getNavigationHandler() != null 56 WebContents webContents = tab.getWebContents();
56 && tab.getNavigationHandler().getUseDesktopUserAgent(); 57 boolean isDesktopUserAgent = webContents != null
58 && webContents.getNavigationController().getUseDesktopUserAgent( );
57 nativeRecordPageLoaded(isDesktopUserAgent); 59 nativeRecordPageLoaded(isDesktopUserAgent);
58 if (mKeyboardConnected) { 60 if (mKeyboardConnected) {
59 nativeRecordPageLoadedWithKeyboard(); 61 nativeRecordPageLoadedWithKeyboard();
60 } 62 }
61 63
62 // If the session has ended (i.e. chrome is in the background), escape e arly. Ideally we 64 // If the session has ended (i.e. chrome is in the background), escape e arly. Ideally we
63 // could track this number as part of either the previous or next sessio n but this isn't 65 // could track this number as part of either the previous or next sessio n but this isn't
64 // possible since the TabSelector is needed to figure out the current nu mber of open tabs. 66 // possible since the TabSelector is needed to figure out the current nu mber of open tabs.
65 if (mTabModelSelector == null) return; 67 if (mTabModelSelector == null) return;
66 68
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 private static native void nativeRegisterExternalExperiment( 219 private static native void nativeRegisterExternalExperiment(
218 String studyName, int[] experimentIds); 220 String studyName, int[] experimentIds);
219 private static native void nativeRegisterSyntheticFieldTrial( 221 private static native void nativeRegisterSyntheticFieldTrial(
220 String trialName, String groupName); 222 String trialName, String groupName);
221 private static native void nativeRecordMultiWindowSession(int areaPercent, i nt instanceCount); 223 private static native void nativeRecordMultiWindowSession(int areaPercent, i nt instanceCount);
222 private static native void nativeRecordTabCountPerLoad(int numTabsOpen); 224 private static native void nativeRecordTabCountPerLoad(int numTabsOpen);
223 private static native void nativeRecordPageLoaded(boolean isDesktopUserAgent ); 225 private static native void nativeRecordPageLoaded(boolean isDesktopUserAgent );
224 private static native void nativeRecordPageLoadedWithKeyboard(); 226 private static native void nativeRecordPageLoadedWithKeyboard();
225 227
226 } 228 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698