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

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

Issue 2604063002: Log intents received differently if they are internal or external. (Closed)
Patch Set: Keep old metrics Created 3 years, 11 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
« no previous file with comments | « no previous file | tools/metrics/actions/actions.xml » ('j') | tools/metrics/actions/actions.xml » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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; 5 package org.chromium.chrome.browser;
6 6
7 import android.annotation.SuppressLint; 7 import android.annotation.SuppressLint;
8 import android.annotation.TargetApi; 8 import android.annotation.TargetApi;
9 import android.app.Activity; 9 import android.app.Activity;
10 import android.app.ActivityManager; 10 import android.app.ActivityManager;
(...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 private class InternalIntentDelegate implements IntentHandler.IntentHandlerD elegate { 757 private class InternalIntentDelegate implements IntentHandler.IntentHandlerD elegate {
758 /** 758 /**
759 * Processes a url view intent. 759 * Processes a url view intent.
760 * 760 *
761 * @param url The url from the intent. 761 * @param url The url from the intent.
762 */ 762 */
763 @Override 763 @Override
764 public void processUrlViewIntent(String url, String referer, String head ers, 764 public void processUrlViewIntent(String url, String referer, String head ers,
765 TabOpenType tabOpenType, String externalAppId, int tabIdToBringT oFront, 765 TabOpenType tabOpenType, String externalAppId, int tabIdToBringT oFront,
766 boolean hasUserGesture, Intent intent) { 766 boolean hasUserGesture, Intent intent) {
767 if (IntentHandler.wasIntentSenderChrome(intent, ChromeTabbedActivity .this)
768 || TextUtils.equals(externalAppId, getPackageName())) {
769 RecordUserAction.record("MobileTabbedModeViewIntentFromChrome");
770 } else {
771 RecordUserAction.record("MobileTabbedModeViewIntentFromApp");
772 }
773
767 TabModel tabModel = getCurrentTabModel(); 774 TabModel tabModel = getCurrentTabModel();
768 boolean fromLauncherShortcut = IntentUtils.safeGetBooleanExtra( 775 boolean fromLauncherShortcut = IntentUtils.safeGetBooleanExtra(
769 intent, IntentHandler.EXTRA_INVOKED_FROM_SHORTCUT, false); 776 intent, IntentHandler.EXTRA_INVOKED_FROM_SHORTCUT, false);
770 switch (tabOpenType) { 777 switch (tabOpenType) {
771 case REUSE_URL_MATCHING_TAB_ELSE_NEW_TAB: 778 case REUSE_URL_MATCHING_TAB_ELSE_NEW_TAB:
772 // Used by the bookmarks application. 779 // Used by the bookmarks application.
773 if (tabModel.getCount() > 0 && mUIInitialized 780 if (tabModel.getCount() > 0 && mUIInitialized
774 && mLayoutManager.overviewVisible()) { 781 && mLayoutManager.overviewVisible()) {
775 mLayoutManager.hideOverview(true); 782 mLayoutManager.hideOverview(true);
776 } 783 }
777 mTabModelSelectorImpl.tryToRestoreTabStateForUrl(url); 784 mTabModelSelectorImpl.tryToRestoreTabStateForUrl(url);
778 int tabToBeClobberedIndex = TabModelUtils.getTabIndexByUrl(t abModel, url); 785 int tabToBeClobberedIndex = TabModelUtils.getTabIndexByUrl(t abModel, url);
779 Tab tabToBeClobbered = tabModel.getTabAt(tabToBeClobberedInd ex); 786 Tab tabToBeClobbered = tabModel.getTabAt(tabToBeClobberedInd ex);
780 if (tabToBeClobbered != null) { 787 if (tabToBeClobbered != null) {
781 TabModelUtils.setIndex(tabModel, tabToBeClobberedIndex); 788 TabModelUtils.setIndex(tabModel, tabToBeClobberedIndex);
782 tabToBeClobbered.reload(); 789 tabToBeClobbered.reload();
783 RecordUserAction.record("MobileTabClobbered"); 790 RecordUserAction.record("MobileTabClobbered");
784 } else { 791 } else {
785 launchIntent(url, referer, headers, externalAppId, true, intent); 792 launchIntent(url, referer, headers, externalAppId, true, intent);
786 } 793 }
787 RecordUserAction.record("MobileReceivedExternalIntent"); 794 logMobileReceivedExternalIntent(externalAppId, intent);
788 int shortcutSource = intent.getIntExtra( 795 int shortcutSource = intent.getIntExtra(
789 ShortcutHelper.EXTRA_SOURCE, ShortcutSource.UNKNOWN) ; 796 ShortcutHelper.EXTRA_SOURCE, ShortcutSource.UNKNOWN) ;
790 LaunchMetrics.recordHomeScreenLaunchIntoTab(url, shortcutSou rce); 797 LaunchMetrics.recordHomeScreenLaunchIntoTab(url, shortcutSou rce);
791 break; 798 break;
792 case BRING_TAB_TO_FRONT: 799 case BRING_TAB_TO_FRONT:
793 mTabModelSelectorImpl.tryToRestoreTabStateForId(tabIdToBring ToFront); 800 mTabModelSelectorImpl.tryToRestoreTabStateForId(tabIdToBring ToFront);
794 801
795 int tabIndex = TabModelUtils.getTabIndexById(tabModel, tabId ToBringToFront); 802 int tabIndex = TabModelUtils.getTabIndexById(tabModel, tabId ToBringToFront);
796 if (tabIndex == TabModel.INVALID_TAB_INDEX) { 803 if (tabIndex == TabModel.INVALID_TAB_INDEX) {
797 TabModel otherModel = 804 TabModel otherModel =
798 getTabModelSelector().getModel(!tabModel.isIncog nito()); 805 getTabModelSelector().getModel(!tabModel.isIncog nito());
799 tabIndex = TabModelUtils.getTabIndexById(otherModel, tab IdToBringToFront); 806 tabIndex = TabModelUtils.getTabIndexById(otherModel, tab IdToBringToFront);
800 if (tabIndex != TabModel.INVALID_TAB_INDEX) { 807 if (tabIndex != TabModel.INVALID_TAB_INDEX) {
801 getTabModelSelector().selectModel(otherModel.isIncog nito()); 808 getTabModelSelector().selectModel(otherModel.isIncog nito());
802 TabModelUtils.setIndex(otherModel, tabIndex); 809 TabModelUtils.setIndex(otherModel, tabIndex);
803 } else { 810 } else {
804 Log.e(TAG, "Failed to bring tab to front because it doesn't exist."); 811 Log.e(TAG, "Failed to bring tab to front because it doesn't exist.");
805 return; 812 return;
806 } 813 }
807 } else { 814 } else {
808 TabModelUtils.setIndex(tabModel, tabIndex); 815 TabModelUtils.setIndex(tabModel, tabIndex);
809 } 816 }
810 RecordUserAction.record("MobileReceivedExternalIntent"); 817 logMobileReceivedExternalIntent(externalAppId, intent);
811 break; 818 break;
812 case CLOBBER_CURRENT_TAB: 819 case CLOBBER_CURRENT_TAB:
813 // The browser triggered the intent. This happens when click ing links which 820 // The browser triggered the intent. This happens when click ing links which
814 // can be handled by other applications (e.g. www.youtube.co m links). 821 // can be handled by other applications (e.g. www.youtube.co m links).
815 Tab currentTab = getActivityTab(); 822 Tab currentTab = getActivityTab();
816 if (currentTab != null) { 823 if (currentTab != null) {
817 currentTab.getTabRedirectHandler().updateIntent(intent); 824 currentTab.getTabRedirectHandler().updateIntent(intent);
818 int transitionType = PageTransition.LINK | PageTransitio n.FROM_API; 825 int transitionType = PageTransition.LINK | PageTransitio n.FROM_API;
819 LoadUrlParams loadUrlParams = new LoadUrlParams(url); 826 LoadUrlParams loadUrlParams = new LoadUrlParams(url);
820 loadUrlParams.setIntentReceivedTimestamp(mIntentHandling TimeMs); 827 loadUrlParams.setIntentReceivedTimestamp(mIntentHandling TimeMs);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
883 */ 890 */
884 private void openNewTab(String url, String referer, String headers, 891 private void openNewTab(String url, String referer, String headers,
885 String externalAppId, Intent intent, boolean forceNewTab) { 892 String externalAppId, Intent intent, boolean forceNewTab) {
886 boolean isAllowedToReturnToExternalApp = IntentUtils.safeGetBooleanE xtra(intent, 893 boolean isAllowedToReturnToExternalApp = IntentUtils.safeGetBooleanE xtra(intent,
887 ChromeLauncherActivity.EXTRA_IS_ALLOWED_TO_RETURN_TO_PARENT, true); 894 ChromeLauncherActivity.EXTRA_IS_ALLOWED_TO_RETURN_TO_PARENT, true);
888 895
889 // Create a new tab. 896 // Create a new tab.
890 Tab newTab = 897 Tab newTab =
891 launchIntent(url, referer, headers, externalAppId, forceNewT ab, intent); 898 launchIntent(url, referer, headers, externalAppId, forceNewT ab, intent);
892 newTab.setIsAllowedToReturnToExternalApp(isAllowedToReturnToExternal App); 899 newTab.setIsAllowedToReturnToExternalApp(isAllowedToReturnToExternal App);
900 logMobileReceivedExternalIntent(externalAppId, intent);
901 }
902
903 // TODO(tedchoc): Remove once we have verified that MobileTabbedModeView IntentFromChrome
904 // and MobileTabbedModeViewIntentFromApp are suitable/mor e correct
905 // replacments for these.
906 private void logMobileReceivedExternalIntent(String externalAppId, Inten t intent) {
893 RecordUserAction.record("MobileReceivedExternalIntent"); 907 RecordUserAction.record("MobileReceivedExternalIntent");
908 if (IntentHandler.wasIntentSenderChrome(intent, ChromeTabbedActivity .this)
909 || TextUtils.equals(externalAppId, getPackageName())) {
910 RecordUserAction.record("MobileReceivedExternalIntent.Chrome");
911 } else {
912 RecordUserAction.record("MobileReceivedExternalIntent.App");
913 }
894 } 914 }
895 } 915 }
896 916
897 @Override 917 @Override
898 public void preInflationStartup() { 918 public void preInflationStartup() {
899 super.preInflationStartup(); 919 super.preInflationStartup();
900 920
901 // Decide whether to record startup UMA histograms. This is done early in the main 921 // Decide whether to record startup UMA histograms. This is done early in the main
902 // Activity.onCreate() to avoid recording navigation delays when they re quire user input to 922 // Activity.onCreate() to avoid recording navigation delays when they re quire user input to
903 // proceed. For example, FRE (First Run Experience) happens before the a ctivity is created, 923 // proceed. For example, FRE (First Run Experience) happens before the a ctivity is created,
(...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after
1703 1723
1704 ActivityManager manager = (ActivityManager) getSystemService(Context.ACT IVITY_SERVICE); 1724 ActivityManager manager = (ActivityManager) getSystemService(Context.ACT IVITY_SERVICE);
1705 for (AppTask task : manager.getAppTasks()) { 1725 for (AppTask task : manager.getAppTasks()) {
1706 RecentTaskInfo info = DocumentUtils.getTaskInfoFromTask(task); 1726 RecentTaskInfo info = DocumentUtils.getTaskInfoFromTask(task);
1707 if (info == null) continue; 1727 if (info == null) continue;
1708 if (info.id == sMergedInstanceTaskId) return true; 1728 if (info.id == sMergedInstanceTaskId) return true;
1709 } 1729 }
1710 return false; 1730 return false;
1711 } 1731 }
1712 } 1732 }
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/actions/actions.xml » ('j') | tools/metrics/actions/actions.xml » ('J')

Powered by Google App Engine
This is Rietveld 408576698