Commit 403cebbd authored by Alan Cutter's avatar Alan Cutter Committed by Commit Bot

Disable PWA window popout menu option for incognito tabs

There's no UX on a PWA window to indicate incognito status, disable
the ability to get in this situation (also it DCHECKs).

Bug: 843869
Change-Id: I6b48258dfbe118ea67aae9b9a5375b198eaa4e75
Reviewed-on: https://chromium-review.googlesource.com/1062991
Commit-Queue: Alan Cutter <alancutter@chromium.org>
Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#559426}
parent bf408599
...@@ -1027,6 +1027,8 @@ void BrowserCommandController::UpdateCommandsForTabState() { ...@@ -1027,6 +1027,8 @@ void BrowserCommandController::UpdateCommandsForTabState() {
command_updater_.UpdateCommandEnabled(IDC_CREATE_HOSTED_APP, command_updater_.UpdateCommandEnabled(IDC_CREATE_HOSTED_APP,
CanCreateBookmarkApp(browser_)); CanCreateBookmarkApp(browser_));
command_updater_.UpdateCommandEnabled(IDC_OPEN_IN_PWA_WINDOW,
CanCreateBookmarkApp(browser_));
command_updater_.UpdateCommandEnabled( command_updater_.UpdateCommandEnabled(
IDC_TOGGLE_REQUEST_TABLET_SITE, IDC_TOGGLE_REQUEST_TABLET_SITE,
......
...@@ -570,7 +570,7 @@ IN_PROC_BROWSER_TEST_P(HostedAppTest, CreateShortcutDisabledInIncognito) { ...@@ -570,7 +570,7 @@ IN_PROC_BROWSER_TEST_P(HostedAppTest, CreateShortcutDisabledInIncognito) {
app_menu_model->Init(); app_menu_model->Init();
ui::MenuModel* model = app_menu_model.get(); ui::MenuModel* model = app_menu_model.get();
int index = -1; int index = -1;
EXPECT_TRUE(app_menu_model->GetModelAndIndexForCommandId( ASSERT_TRUE(app_menu_model->GetModelAndIndexForCommandId(
IDC_CREATE_HOSTED_APP, &model, &index)); IDC_CREATE_HOSTED_APP, &model, &index));
EXPECT_FALSE(model->IsEnabledAt(index)); EXPECT_FALSE(model->IsEnabledAt(index));
} }
...@@ -938,6 +938,26 @@ IN_PROC_BROWSER_TEST_P(HostedAppTest, MixedContentInBookmarkApp) { ...@@ -938,6 +938,26 @@ IN_PROC_BROWSER_TEST_P(HostedAppTest, MixedContentInBookmarkApp) {
using HostedAppPWAOnlyTest = HostedAppTest; using HostedAppPWAOnlyTest = HostedAppTest;
// Tests that the command for popping a tab out to a PWA window is disabled in
// incognito.
IN_PROC_BROWSER_TEST_P(HostedAppPWAOnlyTest, PopOutDisabledInIncognito) {
ASSERT_TRUE(https_server()->Start());
ASSERT_TRUE(embedded_test_server()->Start());
InstallSecurePWA();
Browser* incognito_browser =
OpenURLOffTheRecord(profile(), GetSecureAppURL());
auto app_menu_model =
std::make_unique<AppMenuModel>(nullptr, incognito_browser);
app_menu_model->Init();
ui::MenuModel* model = app_menu_model.get();
int index = -1;
ASSERT_TRUE(app_menu_model->GetModelAndIndexForCommandId(
IDC_OPEN_IN_PWA_WINDOW, &model, &index));
EXPECT_FALSE(model->IsEnabledAt(index));
}
// Tests that the command for OpenActiveTabInPwaWindow is available for secure // Tests that the command for OpenActiveTabInPwaWindow is available for secure
// pages in an app's scope. // pages in an app's scope.
IN_PROC_BROWSER_TEST_P(HostedAppPWAOnlyTest, IN_PROC_BROWSER_TEST_P(HostedAppPWAOnlyTest,
......
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