1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 package org.chromium.chrome.browser;
6 
7 import org.chromium.base.metrics.RecordUserAction;
8 
9 /**
10  * A subclass of ChromeTabbedActivity, used in Android N multi-window mode.
11  *
12  * This activity can appear side-by-side with ChromeTabbedActivity in multi-window mode. It has a
13  * separate set of tabs, as determined by logic in TabWindowManager.
14  *
15  * Since ChromeTabbedActivity has launchMode="singleTask" in the manifest, there can't be two
16  * instances of ChromeTabbedActivity; hence this activity is needed. Moreover, having separately-
17  * named activities makes it possible to bring either existing activity to the foreground on the
18  * desired side of the screen when firing an intent.
19  */
20 public class ChromeTabbedActivity2 extends ChromeTabbedActivity {
21     @Override
onDeferredStartupForMultiWindowMode()22     protected void onDeferredStartupForMultiWindowMode() {
23         RecordUserAction.record("Android.MultiWindowMode.MultiInstance.Enter");
24     }
25 
26     @Override
recordMultiWindowModeChangedUserAction(boolean isInMultiWindowMode)27     protected void recordMultiWindowModeChangedUserAction(boolean isInMultiWindowMode) {
28         // Record separate user actions for entering/exiting multi-window mode to avoid recording
29         // the same action twice when two instances are running.
30         if (isInMultiWindowMode) {
31             RecordUserAction.record("Android.MultiWindowMode.Enter-SecondInstance");
32         } else {
33             RecordUserAction.record("Android.MultiWindowMode.Exit-SecondInstance");
34         }
35     }
36 }
37