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

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

Issue 2779083003: Add additional metrics for main intent behaviors. (Closed)
Patch Set: Address isherman@ comments Created 3 years, 8 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 | chrome/android/java/src/org/chromium/chrome/browser/metrics/MainIntentBehaviorMetrics.java » ('j') | no next file with comments »
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 733 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 return false; 744 return false;
745 } 745 }
746 746
747 if (mLayoutManager != null && mLayoutManager.overviewVisible() && !isTab let()) { 747 if (mLayoutManager != null && mLayoutManager.overviewVisible() && !isTab let()) {
748 mLayoutManager.hideOverview(false); 748 mLayoutManager.hideOverview(false);
749 } 749 }
750 750
751 // In cases where the tab model is initialized, attempt to reuse an exis ting NTP if 751 // In cases where the tab model is initialized, attempt to reuse an exis ting NTP if
752 // available before attempting to create a new one. 752 // available before attempting to create a new one.
753 TabModel normalTabModel = getTabModelSelector().getModel(false); 753 TabModel normalTabModel = getTabModelSelector().getModel(false);
754 Tab ntpToRefocus = null;
754 for (int i = 0; i < normalTabModel.getCount(); i++) { 755 for (int i = 0; i < normalTabModel.getCount(); i++) {
755 Tab tab = normalTabModel.getTabAt(i); 756 Tab tab = normalTabModel.getTabAt(i);
756 757
757 if (NewTabPage.isNTPUrl(tab.getUrl()) && !tab.canGoBack() && !tab.ca nGoForward()) { 758 if (NewTabPage.isNTPUrl(tab.getUrl()) && !tab.canGoBack() && !tab.ca nGoForward()) {
759 // If the currently selected tab is an NTP, then take no action.
758 if (getActivityTab().equals(tab)) return true; 760 if (getActivityTab().equals(tab)) return true;
759 761 ntpToRefocus = tab;
760 normalTabModel.moveTab(tab.getId(), normalTabModel.getCount()); 762 break;
761 normalTabModel.setIndex(
762 TabModelUtils.getTabIndexById(normalTabModel, tab.getId( )),
763 TabSelectionType.FROM_USER);
764 return true;
765 } 763 }
766 } 764 }
767 765
768 getTabCreator(false).launchUrl(UrlConstants.NTP_URL, TabLaunchType.FROM_ EXTERNAL_APP); 766 if (ntpToRefocus != null) {
767 normalTabModel.moveTab(ntpToRefocus.getId(), normalTabModel.getCount ());
768 normalTabModel.setIndex(
769 TabModelUtils.getTabIndexById(normalTabModel, ntpToRefocus.g etId()),
770 TabSelectionType.FROM_USER);
771 } else {
772 getTabCreator(false).launchUrl(UrlConstants.NTP_URL, TabLaunchType.F ROM_EXTERNAL_APP);
773 }
774 RecordUserAction.record("MobileStartup.MainIntent.NTPCreatedDueToInactiv ity");
769 return true; 775 return true;
770 } 776 }
771 777
772 @Override 778 @Override
773 public void initializeState() { 779 public void initializeState() {
774 // This method goes through 3 steps: 780 // This method goes through 3 steps:
775 // 1. Load the saved tab state (but don't start restoring the tabs yet). 781 // 1. Load the saved tab state (but don't start restoring the tabs yet).
776 // 2. Process the Intent that this activity received and if that should result in any 782 // 2. Process the Intent that this activity received and if that should result in any
777 // new tabs, create them. This is done after step 1 so that the new tab gets 783 // new tabs, create them. This is done after step 1 so that the new tab gets
778 // created after previous tab state was restored. 784 // created after previous tab state was restored.
(...skipping 1163 matching lines...) Expand 10 before | Expand all | Expand 10 after
1942 1948
1943 ActivityManager manager = (ActivityManager) getSystemService(Context.ACT IVITY_SERVICE); 1949 ActivityManager manager = (ActivityManager) getSystemService(Context.ACT IVITY_SERVICE);
1944 for (AppTask task : manager.getAppTasks()) { 1950 for (AppTask task : manager.getAppTasks()) {
1945 RecentTaskInfo info = DocumentUtils.getTaskInfoFromTask(task); 1951 RecentTaskInfo info = DocumentUtils.getTaskInfoFromTask(task);
1946 if (info == null) continue; 1952 if (info == null) continue;
1947 if (info.id == sMergedInstanceTaskId) return true; 1953 if (info.id == sMergedInstanceTaskId) return true;
1948 } 1954 }
1949 return false; 1955 return false;
1950 } 1956 }
1951 } 1957 }
OLDNEW
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/metrics/MainIntentBehaviorMetrics.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698