Commit b62e2b7e authored by Tina Wang's avatar Tina Wang Committed by Chromium LUCI CQ

[ios][enterprise] Support incognito mode start up

When the enterprise only allows the users to use incognito mode, Chrome
should be started up in incognito mode.

Bug: 1165405
Change-Id: Ic08059527becb7ce9210f693dea2679870678247
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2641181
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#845572}
parent 70c559de
...@@ -109,6 +109,7 @@ source_set("scene") { ...@@ -109,6 +109,7 @@ source_set("scene") {
"//ios/chrome/browser/main", "//ios/chrome/browser/main",
"//ios/chrome/browser/ntp:features", "//ios/chrome/browser/ntp:features",
"//ios/chrome/browser/policy", "//ios/chrome/browser/policy",
"//ios/chrome/browser/prefs:browser_prefs",
"//ios/chrome/browser/screenshot", "//ios/chrome/browser/screenshot",
"//ios/chrome/browser/signin", "//ios/chrome/browser/signin",
"//ios/chrome/browser/snapshots", "//ios/chrome/browser/snapshots",
......
...@@ -52,6 +52,7 @@ ...@@ -52,6 +52,7 @@
#import "ios/chrome/browser/main/browser_util.h" #import "ios/chrome/browser/main/browser_util.h"
#include "ios/chrome/browser/ntp/features.h" #include "ios/chrome/browser/ntp/features.h"
#import "ios/chrome/browser/policy/policy_watcher_browser_agent.h" #import "ios/chrome/browser/policy/policy_watcher_browser_agent.h"
#import "ios/chrome/browser/prefs/prefs_util.h"
#include "ios/chrome/browser/screenshot/screenshot_delegate.h" #include "ios/chrome/browser/screenshot/screenshot_delegate.h"
#import "ios/chrome/browser/signin/authentication_service.h" #import "ios/chrome/browser/signin/authentication_service.h"
#import "ios/chrome/browser/signin/authentication_service_factory.h" #import "ios/chrome/browser/signin/authentication_service_factory.h"
...@@ -687,16 +688,28 @@ const char kMultiWindowOpenInNewWindowHistogram[] = ...@@ -687,16 +688,28 @@ const char kMultiWindowOpenInNewWindowHistogram[] =
} }
} }
// Make sure the launch mode is correct and consistent with the mode used BOOL startInIncognito;
// when the application was terminated. It is possible for the incognito PrefService* prefService =
// UI to have been presented but with no tabs (e.g. the tab switcher was self.mainInterface.browser->GetBrowserState()->GetPrefs();
// active and user closed the last tab). In that case, switch to regular if (IsIncognitoModeForced(prefService)) {
// UI. Also, if the app crashed, always switch back to regular UI. // When only incognito mode is available.
const BOOL startInIncognito = startInIncognito = YES;
self.sceneState.incognitoContentVisible && } else if (IsIncognitoModeDisabled(prefService)) {
!self.sceneState.appState.postCrashLaunch && // When incognito mode is disabled.
!self.interfaceProvider.incognitoInterface.browser->GetWebStateList() startInIncognito = NO;
->empty(); [self clearIOSSpecificIncognitoData];
} else {
// Make sure the launch mode is correct and consistent with the mode used
// when the application was terminated. It is possible for the incognito
// UI to have been presented but with no tabs (e.g. the tab switcher was
// active and user closed the last tab). In that case, switch to regular
// UI. Also, if the app crashed, always switch back to regular UI.
startInIncognito =
self.sceneState.incognitoContentVisible &&
!self.sceneState.appState.postCrashLaunch &&
!self.interfaceProvider.incognitoInterface.browser->GetWebStateList()
->empty();
}
// If the application crashed, clear incognito state. // If the application crashed, clear incognito state.
if (self.sceneState.appState.postCrashLaunch) if (self.sceneState.appState.postCrashLaunch)
......
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