Java Code Examples for org.chromium.chrome.browser.ntp.NewTabPageUma#recordAction()

The following examples show how to use org.chromium.chrome.browser.ntp.NewTabPageUma#recordAction() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BookmarkUtils.java    From delion with Apache License 2.0 6 votes vote down vote up
/**
 * Opens a bookmark and reports UMA.
 * @param model Bookmarks model to manage the bookmark.
 * @param activity Activity requesting to open the bookmark.
 * @param bookmarkId ID of the bookmark to be opened.
 * @param launchLocation Location from which the bookmark is being opened.
 * @return Whether the bookmark was successfully opened.
 */
public static boolean openBookmark(BookmarkModel model, Activity activity,
        BookmarkId bookmarkId, int launchLocation) {
    if (model.getBookmarkById(bookmarkId) == null) return false;

    String url = model.getBookmarkById(bookmarkId).getUrl();

    NewTabPageUma.recordAction(NewTabPageUma.ACTION_OPENED_BOOKMARK);
    RecordHistogram.recordEnumeratedHistogram(
            "Stars.LaunchLocation", launchLocation, BookmarkLaunchLocation.COUNT);

    if (DeviceFormFactor.isTablet(activity)) {
        // For tablets, the bookmark manager is open in a tab in the ChromeActivity. Use
        // the ComponentName of the ChromeActivity passed into this method.
        openUrl(activity, url, activity.getComponentName());
    } else {
        // For phones, the bookmark manager is a separate activity. When the activity is
        // launched, an intent extra is set specifying the parent component.
        ComponentName parentComponent = IntentUtils.safeGetParcelableExtra(
                activity.getIntent(), IntentHandler.EXTRA_PARENT_COMPONENT);
        openUrl(activity, url, parentComponent);
    }

    return true;
}
 
Example 2
Source File: BookmarkUtils.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * Opens a bookmark and reports UMA.
 * @param model Bookmarks model to manage the bookmark.
 * @param activity Activity requesting to open the bookmark.
 * @param bookmarkId ID of the bookmark to be opened.
 * @param launchLocation Location from which the bookmark is being opened.
 * @return Whether the bookmark was successfully opened.
 */
public static boolean openBookmark(BookmarkModel model, Activity activity,
        BookmarkId bookmarkId, int launchLocation) {
    if (model.getBookmarkById(bookmarkId) == null) return false;

    String url = model.getBookmarkById(bookmarkId).getUrl();

    NewTabPageUma.recordAction(NewTabPageUma.ACTION_OPENED_BOOKMARK);
    RecordHistogram.recordEnumeratedHistogram(
            "Stars.LaunchLocation", launchLocation, BookmarkLaunchLocation.COUNT);

    if (DeviceFormFactor.isTablet(activity)) {
        // For tablets, the bookmark manager is open in a tab in the ChromeActivity. Use
        // the ComponentName of the ChromeActivity passed into this method.
        openUrl(activity, url, activity.getComponentName());
    } else {
        // For phones, the bookmark manager is a separate activity. When the activity is
        // launched, an intent extra is set specifying the parent component.
        ComponentName parentComponent = IntentUtils.safeGetParcelableExtra(
                activity.getIntent(), IntentHandler.EXTRA_PARENT_COMPONENT);
        openUrl(activity, url, parentComponent);
    }

    return true;
}
 
Example 3
Source File: SuggestionsEventReporterBridge.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@Override
public void onMoreButtonClicked(ActionItem actionItem) {
    @CategoryInt
    int category = actionItem.getCategory();
    nativeOnMoreButtonClicked(category, actionItem.getPerSectionRank());
    switch (category) {
        case KnownCategories.BOOKMARKS:
            NewTabPageUma.recordAction(NewTabPageUma.ACTION_OPENED_BOOKMARKS_MANAGER);
            break;
        // MORE button in both categories leads to the recent tabs manager
        case KnownCategories.FOREIGN_TABS:
        case KnownCategories.RECENT_TABS:
            NewTabPageUma.recordAction(NewTabPageUma.ACTION_OPENED_RECENT_TABS_MANAGER);
            break;
        case KnownCategories.DOWNLOADS:
            NewTabPageUma.recordAction(NewTabPageUma.ACTION_OPENED_DOWNLOADS_MANAGER);
            break;
        default:
            // No action associated
            break;
    }
}
 
Example 4
Source File: SnippetArticle.java    From delion with Apache License 2.0 5 votes vote down vote up
/** Tracks click on this NTP snippet in UMA. */
public void trackClick() {
    RecordUserAction.record("MobileNTP.Snippets.Click");
    RecordHistogram.recordSparseSlowlyHistogram("NewTabPage.Snippets.CardClicked", mPosition);
    NewTabPageUma.recordSnippetAction(NewTabPageUma.SNIPPETS_ACTION_CLICKED);
    NewTabPageUma.recordAction(NewTabPageUma.ACTION_OPENED_SNIPPET);
    recordAgeAndScore("NewTabPage.Snippets.CardClicked");
}
 
Example 5
Source File: TileGroupDelegateImpl.java    From 365browser with Apache License 2.0 5 votes vote down vote up
private void recordOpenedTile(Tile tile) {
    NewTabPageUma.recordAction(NewTabPageUma.ACTION_OPENED_MOST_VISITED_TILE);
    RecordUserAction.record("MobileNTPMostVisited");
    NewTabPageUma.recordExplicitUserNavigation(
            tile.getUrl(), NewTabPageUma.RAPPOR_ACTION_VISITED_SUGGESTED_TILE);
    mMostVisitedSites.recordOpenedMostVisitedItem(
            tile.getIndex(), tile.getType(), tile.getSource());
}
 
Example 6
Source File: SuggestionsNavigationDelegateImpl.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void navigateToHelpPage() {
    NewTabPageUma.recordAction(NewTabPageUma.ACTION_CLICKED_LEARN_MORE);
    // TODO(dgn): Use the standard Help UI rather than a random link to online help?
    openUrl(WindowOpenDisposition.CURRENT_TAB,
            new LoadUrlParams(NEW_TAB_URL_HELP, PageTransition.AUTO_BOOKMARK));
}
 
Example 7
Source File: ChromeTabbedActivity.java    From 365browser with Apache License 2.0 4 votes vote down vote up
@Override
public boolean onMenuOrKeyboardAction(final int id, boolean fromMenu) {
    final Tab currentTab = getActivityTab();
    boolean currentTabIsNtp = currentTab != null && NewTabPage.isNTPUrl(currentTab.getUrl());
    if (id == R.id.move_to_other_window_menu_id) {
        if (currentTab != null) moveTabToOtherWindow(currentTab);
    } else if (id == R.id.new_tab_menu_id) {
        getTabModelSelector().getModel(false).commitAllTabClosures();
        RecordUserAction.record("MobileMenuNewTab");
        RecordUserAction.record("MobileNewTabOpened");
        reportNewTabShortcutUsed(false);
        getTabCreator(false).launchNTP();

        mLocaleManager.showSearchEnginePromoIfNeeded(this, null);
    } else if (id == R.id.new_incognito_tab_menu_id) {
        if (PrefServiceBridge.getInstance().isIncognitoModeEnabled()) {
            getTabModelSelector().getModel(false).commitAllTabClosures();
            // This action must be recorded before opening the incognito tab since UMA actions
            // are dropped when an incognito tab is open.
            RecordUserAction.record("MobileMenuNewIncognitoTab");
            RecordUserAction.record("MobileNewTabOpened");
            reportNewTabShortcutUsed(true);
            getTabCreator(true).launchNTP();
        }
    } else if (id == R.id.all_bookmarks_menu_id) {
        if (currentTab != null) {
            getCompositorViewHolder().hideKeyboard(new Runnable() {
                @Override
                public void run() {
                    StartupMetrics.getInstance().recordOpenedBookmarks();
                    BookmarkUtils.showBookmarkManager(ChromeTabbedActivity.this);
                }
            });
            if (currentTabIsNtp) {
                NewTabPageUma.recordAction(NewTabPageUma.ACTION_OPENED_BOOKMARKS_MANAGER);
            }
            RecordUserAction.record("MobileMenuAllBookmarks");
        }
    } else if (id == R.id.recent_tabs_menu_id) {
        if (currentTab != null) {
            currentTab.loadUrl(new LoadUrlParams(
                    UrlConstants.RECENT_TABS_URL,
                    PageTransition.AUTO_BOOKMARK));
            if (currentTabIsNtp) {
                NewTabPageUma.recordAction(NewTabPageUma.ACTION_OPENED_RECENT_TABS_MANAGER);
            }
            RecordUserAction.record("MobileMenuRecentTabs");
        }
    } else if (id == R.id.close_all_tabs_menu_id) {
        // Close both incognito and normal tabs
        getTabModelSelector().closeAllTabs();
        RecordUserAction.record("MobileMenuCloseAllTabs");
    } else if (id == R.id.close_all_incognito_tabs_menu_id) {
        // Close only incognito tabs
        getTabModelSelector().getModel(true).closeAllTabs();
        // TODO(nileshagrawal) Record unique action for this. See bug http://b/5542946.
        RecordUserAction.record("MobileMenuCloseAllTabs");
    } else if (id == R.id.find_in_page_id) {
        mFindToolbarManager.showToolbar();
        if (getContextualSearchManager() != null) {
            getContextualSearchManager().hideContextualSearch(StateChangeReason.UNKNOWN);
        }
        if (fromMenu) {
            RecordUserAction.record("MobileMenuFindInPage");
        } else {
            RecordUserAction.record("MobileShortcutFindInPage");
        }
    } else if (id == R.id.focus_url_bar) {
        boolean isUrlBarVisible = !mLayoutManager.overviewVisible()
                && (!isTablet() || getCurrentTabModel().getCount() != 0);
        if (isUrlBarVisible) {
            getToolbarManager().setUrlBarFocus(true);
        }
    } else if (id == R.id.downloads_menu_id) {
        DownloadUtils.showDownloadManager(this, currentTab);
        if (currentTabIsNtp) {
            NewTabPageUma.recordAction(NewTabPageUma.ACTION_OPENED_DOWNLOADS_MANAGER);
        }
        RecordUserAction.record("MobileMenuDownloadManager");
    } else if (id == R.id.open_recently_closed_tab) {
        TabModel currentModel = mTabModelSelectorImpl.getCurrentModel();
        if (!currentModel.isIncognito()) currentModel.openMostRecentlyClosedTab();
        RecordUserAction.record("MobileTabClosedUndoShortCut");
    } else if (id == R.id.enter_vr_id) {
        VrShellDelegate.enterVrIfNecessary();
    } else {
        return super.onMenuOrKeyboardAction(id, fromMenu);
    }
    return true;
}