Commit 1e956a35 authored by Alan Cutter's avatar Alan Cutter Committed by Commit Bot

Disable creating page shortcuts in incognito mode

This change disables the menu item for creating page/PWA shortcuts while
in incognito mode. This makes desktop consistent with Android's behaviour.

The test added by this CL uncovered a feature list DCHECK hit when
calling GetPwaForSecureActiveTab(). This CL cleans up that minor bug
as well.

Bug: 829716
Change-Id: I5818a280724e65c8af5e0a0c6a1d24a0809c77bb
Reviewed-on: https://chromium-review.googlesource.com/1032273Reviewed-by: default avatarElly Fong-Jones <ellyjones@chromium.org>
Reviewed-by: default avatarIstiaque Ahmed <lazyboy@chromium.org>
Commit-Queue: Alan Cutter <alancutter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#554696}
parent 2431f4ba
......@@ -199,7 +199,7 @@ void TabHelper::CreateHostedAppFromWebContents() {
}
bool TabHelper::CanCreateBookmarkApp() const {
return !profile_->IsGuestSession() &&
return !profile_->IsGuestSession() && !profile_->IsOffTheRecord() &&
!profile_->IsSystemProfile() &&
IsValidBookmarkAppUrl(web_contents()->GetURL());
}
......
......@@ -496,6 +496,23 @@ IN_PROC_BROWSER_TEST_P(HostedAppTest, WebContentsPrefsOpenInChrome) {
browser()->tab_strip_model()->GetActiveWebContents());
}
// Tests that creating bookmark apps is disabled in incognito.
IN_PROC_BROWSER_TEST_P(HostedAppTest, CreateShortcutDisabledInIncognito) {
ASSERT_TRUE(https_server()->Start());
ASSERT_TRUE(embedded_test_server()->Start());
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;
EXPECT_TRUE(app_menu_model->GetModelAndIndexForCommandId(
IDC_CREATE_HOSTED_APP, &model, &index));
EXPECT_FALSE(model->IsEnabledAt(index));
}
// Check that the location bar is shown correctly.
IN_PROC_BROWSER_TEST_P(HostedAppTest, ShouldShowLocationBar) {
ASSERT_TRUE(https_server()->Start());
......
......@@ -772,7 +772,9 @@ void AppMenuModel::Build() {
if (extensions::util::IsNewBookmarkAppsEnabled() &&
banners::AppBannerManager::IsExperimentalAppBannersEnabled()) {
const extensions::Extension* pwa =
extensions::util::GetPwaForSecureActiveTab(browser_);
base::FeatureList::IsEnabled(features::kDesktopPWAWindowing)
? extensions::util::GetPwaForSecureActiveTab(browser_)
: nullptr;
if (pwa) {
AddItem(
IDC_OPEN_IN_PWA_WINDOW,
......
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