Commit 470af332 authored by Gauthier Ambard's avatar Gauthier Ambard Committed by Commit Bot

[iOS] Log when existing URL is being opened

The idea is to log when the user is opening a URL (from another app)
which is already opened in the app.
Having this metrics will allow us to know if it is impactful to handle
this special case.

Bug: 1014964
Change-Id: I94c7b7810eb66c81ec310057d1b4b991dad55ab7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1869412Reviewed-by: default avatarNik Bhagat <nikunjb@chromium.org>
Reviewed-by: default avatarStepan Khapugin <stkhapugin@chromium.org>
Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#710130}
parent 0c94f975
......@@ -55,4 +55,8 @@
return NO;
}
- (BOOL)URLIsOpenedInRegularMode:(const GURL&)URL {
return NO;
}
@end
......@@ -11,6 +11,7 @@
#include "ui/base/page_transition_types.h"
@class AppState;
class GURL;
@class TabModel;
@protocol StartupInformation;
struct UrlLoadParams;
......@@ -52,6 +53,9 @@ enum class ApplicationModeForTabOpening { NORMAL, INCOGNITO, CURRENT };
- (BOOL)shouldCompletePaymentRequestOnCurrentTab:
(id<StartupInformation>)startupInformation;
// Whether the |URL| is already opened, in regular mode.
- (BOOL)URLIsOpenedInRegularMode:(const GURL&)URL;
@end
#endif // IOS_CHROME_APP_APPLICATION_DELEGATE_TAB_OPENING_H_
......@@ -89,6 +89,11 @@ const char* const kUMAMobileSessionStartFromAppsHistogram =
if (callerApp == CALLER_APP_GOOGLE_CHROME)
targetMode = ApplicationModeForTabOpening::CURRENT;
if (![params launchInIncognito] &&
[tabOpener URLIsOpenedInRegularMode:urlLoadParams.web_params.url]) {
// Record metric.
}
[tabOpener
dismissModalsAndOpenSelectedTabInMode:targetMode
withUrlLoadParams:urlLoadParams
......
......@@ -177,6 +177,10 @@ NSString* const kShortcutQRScanner = @"OpenQRScanner";
? ApplicationModeForTabOpening::INCOGNITO
: ApplicationModeForTabOpening::NORMAL;
UrlLoadParams params = UrlLoadParams::InNewTab(webpageGURL);
if (![[startupInformation startupParameters] launchInIncognito] &&
[tabOpener URLIsOpenedInRegularMode:webpageGURL]) {
// Record metric.
}
[tabOpener dismissModalsAndOpenSelectedTabInMode:targetMode
withUrlLoadParams:params
dismissOmnibox:YES
......@@ -313,6 +317,11 @@ NSString* const kShortcutQRScanner = @"OpenQRScanner";
params.web_params.url = result;
}
if (![[startupInformation startupParameters] launchInIncognito] &&
[tabOpener URLIsOpenedInRegularMode:params.web_params.url]) {
// Record metric.
}
[tabOpener dismissModalsAndOpenSelectedTabInMode:targetMode
withUrlLoadParams:params
dismissOmnibox:[[startupInformation
......
......@@ -2186,6 +2186,12 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
return YES;
}
- (BOOL)URLIsOpenedInRegularMode:(const GURL&)URL {
WebStateList* webStateList = self.mainTabModel.webStateList;
return webStateList && webStateList->GetIndexOfWebStateWithURL(URL) !=
WebStateList::kInvalidIndex;
}
#pragma mark - SettingsNavigationControllerDelegate
- (void)closeSettings {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment