From 9c827850778a18a15598059c6bc8f02ee82f3ec7 Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Sun, 11 Apr 2021 15:48:07 -0400 Subject: [PATCH] chrome: Fix assertion when clicking the incognito profile button (see issue #2969) Profile::IsIncognitoProfile() currently returns false for CEF incognito profiles because they are not the primary OTR profile. At the same time, we don't necessarily want IsIncognitoProfile() to return true for CEF profiles because, among other things, that causes the BrowserView to apply the dark toolbar theme. Instead, this change updates ProfileMenu expectations to support the CEF incognito profiles without otherwise modifying the incognito behavior. Note that the IsIncognitoProfile() implementation has recently changed in https://crrev.com/7bf6eb2497 and the conclusions in this commit will likely need to be revisited in an upcoming Chromium update. --- patch/patch.cfg | 5 +++ .../patches/chrome_browser_profile_menu.patch | 45 +++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 patch/patches/chrome_browser_profile_menu.patch diff --git a/patch/patch.cfg b/patch/patch.cfg index ebfc5675d..8573d1254 100644 --- a/patch/patch.cfg +++ b/patch/patch.cfg @@ -243,6 +243,11 @@ patches = [ # https://bitbucket.org/chromiumembedded/cef/issues/2969 'name': 'chrome_browser_profiles', }, + { + # chrome: Fix assertion when clicking the incognito profile button. + # https://bitbucket.org/chromiumembedded/cef/issues/2969 + 'name': 'chrome_browser_profile_menu', + }, { # Show the CEF Save As dialog. # https://bitbucket.org/chromiumembedded/cef/issues/2613 diff --git a/patch/patches/chrome_browser_profile_menu.patch b/patch/patches/chrome_browser_profile_menu.patch new file mode 100644 index 000000000..8bb8ee2be --- /dev/null +++ b/patch/patches/chrome_browser_profile_menu.patch @@ -0,0 +1,45 @@ +diff --git chrome/browser/profiles/profile_window.cc chrome/browser/profiles/profile_window.cc +index 691ac8eea4fd..eda2d1c1f224 100644 +--- chrome/browser/profiles/profile_window.cc ++++ chrome/browser/profiles/profile_window.cc +@@ -335,7 +335,9 @@ void BubbleViewModeFromAvatarBubbleMode(BrowserWindow::AvatarBubbleMode mode, + *bubble_view_mode = BUBBLE_VIEW_MODE_PROFILE_CHOOSER; + return; + case BrowserWindow::AVATAR_BUBBLE_MODE_DEFAULT: +- *bubble_view_mode = profile->IsIncognitoProfile() ++ *bubble_view_mode = profile->IsIncognitoProfile() || ++ (profile->IsOffTheRecord() && ++ profile->GetOTRProfileID().IsUniqueForCEF()) + ? profiles::BUBBLE_VIEW_MODE_INCOGNITO + : profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER; + } +diff --git chrome/browser/ui/views/profiles/incognito_menu_view.cc chrome/browser/ui/views/profiles/incognito_menu_view.cc +index f8285d1b6ec1..1f526a44a0b6 100644 +--- chrome/browser/ui/views/profiles/incognito_menu_view.cc ++++ chrome/browser/ui/views/profiles/incognito_menu_view.cc +@@ -37,7 +37,9 @@ + IncognitoMenuView::IncognitoMenuView(views::Button* anchor_button, + Browser* browser) + : ProfileMenuViewBase(anchor_button, browser) { +- DCHECK(browser->profile()->IsIncognitoProfile()); ++ DCHECK(browser->profile()->IsIncognitoProfile() || ++ (browser->profile()->IsOffTheRecord() && ++ browser->profile()->GetOTRProfileID().IsUniqueForCEF())); + GetViewAccessibility().OverrideName(GetAccessibleWindowTitle()); + + chrome::RecordDialogCreation( +diff --git chrome/browser/ui/views/profiles/profile_menu_view_base.cc chrome/browser/ui/views/profiles/profile_menu_view_base.cc +index c35334dea810..e1e9b453462f 100644 +--- chrome/browser/ui/views/profiles/profile_menu_view_base.cc ++++ chrome/browser/ui/views/profiles/profile_menu_view_base.cc +@@ -494,7 +494,9 @@ void ProfileMenuViewBase::ShowBubble( + ProfileMenuViewBase* bubble; + + if (view_mode == profiles::BUBBLE_VIEW_MODE_INCOGNITO) { +- DCHECK(browser->profile()->IsIncognitoProfile()); ++ DCHECK(browser->profile()->IsIncognitoProfile() || ++ (browser->profile()->IsOffTheRecord() && ++ browser->profile()->GetOTRProfileID().IsUniqueForCEF())); + bubble = new IncognitoMenuView(anchor_button, browser); + } else { + DCHECK_EQ(profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER, view_mode);