Commit 3d657e12 authored by Mihai Sardarescu's avatar Mihai Sardarescu Committed by Commit Bot

Return empty startup tabs for incognito profile.

StartupTabProvider may be called when Chrome starts in an incognito profile,
which leads to a crash at start-up. This CL addresses this and adds a unit
test to make sure it does not regress in the future.

Bug: 769241
Change-Id: Idea489bc05e31d7ac693cb935b1481979099bd09
Reviewed-on: https://chromium-review.googlesource.com/689535Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Mihai Sardarescu <msarda@chromium.org>
Cr-Commit-Position: refs/heads/master@{#505395}
parent 1b8c2543
...@@ -71,8 +71,10 @@ StartupTabs StartupTabProviderImpl::GetOnboardingTabs(Profile* profile) const { ...@@ -71,8 +71,10 @@ StartupTabs StartupTabProviderImpl::GetOnboardingTabs(Profile* profile) const {
prefs && prefs->GetBoolean(prefs::kHasSeenWelcomePage); prefs && prefs->GetBoolean(prefs::kHasSeenWelcomePage);
standard_params.is_signin_allowed = profile->IsSyncAllowed(); standard_params.is_signin_allowed = profile->IsSyncAllowed();
SigninManager* signin_manager = SigninManagerFactory::GetForProfile(profile); SigninManager* signin_manager = SigninManagerFactory::GetForProfile(profile);
standard_params.is_signed_in = signin_manager->IsAuthenticated(); standard_params.is_signed_in =
standard_params.is_signin_in_progress = signin_manager->AuthInProgress(); signin_manager && signin_manager->IsAuthenticated();
standard_params.is_signin_in_progress =
signin_manager && signin_manager->AuthInProgress();
standard_params.is_supervised_user = profile->IsSupervised(); standard_params.is_supervised_user = profile->IsSupervised();
#if defined(OS_WIN) #if defined(OS_WIN)
......
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "chrome/common/url_constants.h" #include "chrome/common/url_constants.h"
#include "chrome/test/base/testing_profile.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h" #include "url/gurl.h"
...@@ -443,3 +445,10 @@ TEST(StartupTabProviderTest, GetNewTabPageTabsForState_Negative) { ...@@ -443,3 +445,10 @@ TEST(StartupTabProviderTest, GetNewTabPageTabsForState_Negative) {
ASSERT_TRUE(output.empty()); ASSERT_TRUE(output.empty());
} }
TEST(StartupTabProviderTest, IncognitoProfile) {
content::TestBrowserThreadBundle thread_bundle;
TestingProfile profile;
Profile* incognito = profile.GetOffTheRecordProfile();
EXPECT_TRUE(StartupTabProviderImpl().GetOnboardingTabs(incognito).empty());
}
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