Commit 704c4bf0 authored by Sergey Poromov's avatar Sergey Poromov Committed by Commit Bot

Reland "Allow mixed-security content in promoted PWA windows"

This reverts commit b51be283.

Reason for revert: Breaks builds.

Original change's description:
> Revert "Allow mixed-security content in promoted PWA windows"
> 
> This reverts commit ef364481.
> 
> Reason for revert: [sheriff]:
> Consistent failures on linux-chromeos-chrome
> https://ci.chromium.org/p/chrome/builders/ci/linux-chromeos-chrome
> First failed run:
> https://ci.chromium.org/p/chrome/builders/ci/linux-chromeos-chrome/3315
> 
> Original change's description:
> > Allow mixed-security content in promoted PWA windows
> > 
> > Prior to this CL, mixed-security content was blocked entirely in
> > standalone PWA windows with scopes. This CL allows those PWAs to display
> > mixed-security content, but when this happens, the window will show the
> > CustomTabBarView with the URL and a "Not Secure" indicator to indicate
> > the presence of mixed content.
> > 
> > Screenshot:
> > https://bugs.chromium.org/p/chromium/issues/attachment?aid=432401&signed_aid=JeW6cXlVCQ3bSebdZ-FoJg==&inline=1
> > 
> > This removes a behavioural difference between promoted PWAs and "create
> > shortcut" apps without manifest scopes.
> > 
> > 
> > Bug: 910016
> > Change-Id: Ic9b3bbdba14218bb1ad8fd4f2ca8cf47cd4e3a37
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2041380
> > Commit-Queue: Alan Cutter <alancutter@chromium.org>
> > Reviewed-by: Evan Stade <estade@chromium.org>
> > Reviewed-by: Dominick Ng <dominickn@chromium.org>
> > Reviewed-by: Peter Boström <pbos@chromium.org>
> > Reviewed-by: Glen Robertson <glenrob@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#742515}
> 
> TBR=alancutter@chromium.org,estade@chromium.org,pbos@chromium.org,dominickn@chromium.org,glenrob@chromium.org
> 
> Change-Id: Ibb71d71f13f3fea753b5cb80a4a98c733a093c12
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: 910016
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2063015
> Reviewed-by: Sergey Poromov <poromov@chromium.org>
> Commit-Queue: Sergey Poromov <poromov@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#742557}

TBR=alancutter@chromium.org,estade@chromium.org,pbos@chromium.org,poromov@chromium.org,dominickn@chromium.org,glenrob@chromium.org

Change-Id: Ifef5a3c6a34563999506f4c5946273533ad0063d
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 910016
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2063016Reviewed-by: default avatarSergey Poromov <poromov@chromium.org>
Commit-Queue: Sergey Poromov <poromov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#742561}
parent e3d76652
...@@ -3148,14 +3148,6 @@ void ChromeContentBrowserClient::OverrideWebkitPrefs( ...@@ -3148,14 +3148,6 @@ void ChromeContentBrowserClient::OverrideWebkitPrefs(
} }
#endif #endif
#if BUILDFLAG(ENABLE_EXTENSIONS)
Browser* browser = chrome::FindBrowserWithWebContents(contents);
if (browser && browser->app_controller() &&
browser->app_controller()->CreatedForInstalledPwa()) {
web_prefs->strict_mixed_content_checking = true;
}
#endif
web_prefs->immersive_mode_enabled = vr::VrTabHelper::IsInVr(contents); web_prefs->immersive_mode_enabled = vr::VrTabHelper::IsInVr(contents);
} }
......
...@@ -463,7 +463,7 @@ bool BrowserCommandController::ExecuteCommandWithDisposition( ...@@ -463,7 +463,7 @@ bool BrowserCommandController::ExecuteCommandWithDisposition(
break; break;
case IDC_OPEN_IN_PWA_WINDOW: case IDC_OPEN_IN_PWA_WINDOW:
base::RecordAction(base::UserMetricsAction("OpenActiveTabInPwaWindow")); base::RecordAction(base::UserMetricsAction("OpenActiveTabInPwaWindow"));
web_app::ReparentWebAppForSecureActiveTab(browser_); web_app::ReparentWebAppForActiveTab(browser_);
break; break;
case IDC_MOVE_TAB_TO_NEW_WINDOW: case IDC_MOVE_TAB_TO_NEW_WINDOW:
MoveActiveTabToNewWindow(browser_); MoveActiveTabToNewWindow(browser_);
......
...@@ -59,18 +59,10 @@ bool IsSameHostAndPort(const GURL& app_url, const GURL& page_url) { ...@@ -59,18 +59,10 @@ bool IsSameHostAndPort(const GURL& app_url, const GURL& page_url) {
HostedAppBrowserController::HostedAppBrowserController(Browser* browser) HostedAppBrowserController::HostedAppBrowserController(Browser* browser)
: AppBrowserController( : AppBrowserController(
browser, browser,
web_app::GetAppIdFromApplicationName(browser->app_name())), web_app::GetAppIdFromApplicationName(browser->app_name())) {}
// If a bookmark app has a URL handler, then it is a PWA.
// TODO(https://crbug.com/774918): Replace once there is a more explicit
// indicator of a Bookmark App for an installable website.
created_for_installed_pwa_(UrlHandlers::GetUrlHandlers(GetExtension())) {}
HostedAppBrowserController::~HostedAppBrowserController() = default; HostedAppBrowserController::~HostedAppBrowserController() = default;
bool HostedAppBrowserController::CreatedForInstalledPwa() const {
return created_for_installed_pwa_;
}
bool HostedAppBrowserController::HasMinimalUiButtons() const { bool HostedAppBrowserController::HasMinimalUiButtons() const {
const Extension* extension = GetExtension(); const Extension* extension = GetExtension();
if (!extension || !extension->from_bookmark()) if (!extension || !extension->from_bookmark())
......
...@@ -35,7 +35,6 @@ class HostedAppBrowserController : public web_app::AppBrowserController, ...@@ -35,7 +35,6 @@ class HostedAppBrowserController : public web_app::AppBrowserController,
~HostedAppBrowserController() override; ~HostedAppBrowserController() override;
// web_app::AppBrowserController: // web_app::AppBrowserController:
bool CreatedForInstalledPwa() const override;
bool HasMinimalUiButtons() const override; bool HasMinimalUiButtons() const override;
gfx::ImageSkia GetWindowAppIcon() const override; gfx::ImageSkia GetWindowAppIcon() const override;
gfx::ImageSkia GetWindowIcon() const override; gfx::ImageSkia GetWindowIcon() const override;
...@@ -66,8 +65,6 @@ class HostedAppBrowserController : public web_app::AppBrowserController, ...@@ -66,8 +65,6 @@ class HostedAppBrowserController : public web_app::AppBrowserController,
std::unique_ptr<ExtensionUninstallDialog> uninstall_dialog_; std::unique_ptr<ExtensionUninstallDialog> uninstall_dialog_;
const bool created_for_installed_pwa_;
DISALLOW_COPY_AND_ASSIGN(HostedAppBrowserController); DISALLOW_COPY_AND_ASSIGN(HostedAppBrowserController);
}; };
......
...@@ -629,12 +629,6 @@ IN_PROC_BROWSER_TEST_P(HostedAppTestWithAutoupgradesDisabled, ...@@ -629,12 +629,6 @@ IN_PROC_BROWSER_TEST_P(HostedAppTestWithAutoupgradesDisabled,
web_app::CheckMixedContentLoaded(app_browser_); web_app::CheckMixedContentLoaded(app_browser_);
} }
IN_PROC_BROWSER_TEST_P(HostedAppTest, CreatedForInstalledPwaForNonPwas) {
SetupApp("https_app");
EXPECT_FALSE(app_browser_->app_controller()->CreatedForInstalledPwa());
}
// Common app manifest for HostedAppProcessModelTests. // Common app manifest for HostedAppProcessModelTests.
constexpr const char kHostedAppProcessModelManifest[] = constexpr const char kHostedAppProcessModelManifest[] =
R"( { "name": "Hosted App Process Model Test", R"( { "name": "Hosted App Process Model Test",
......
...@@ -782,7 +782,7 @@ void AppMenuModel::Build() { ...@@ -782,7 +782,7 @@ void AppMenuModel::Build() {
GetInstallPWAAppMenuItemName(browser_)) { GetInstallPWAAppMenuItemName(browser_)) {
AddItem(IDC_INSTALL_PWA, *name); AddItem(IDC_INSTALL_PWA, *name);
} else if (base::Optional<web_app::AppId> app_id = } else if (base::Optional<web_app::AppId> app_id =
web_app::GetPwaForSecureActiveTab(browser_)) { web_app::GetWebAppForActiveTab(browser_)) {
auto* provider = web_app::WebAppProvider::Get(browser_->profile()); auto* provider = web_app::WebAppProvider::Get(browser_->profile());
const base::string16 short_name = const base::string16 short_name =
base::UTF8ToUTF16(provider->registrar().GetAppShortName(*app_id)); base::UTF8ToUTF16(provider->registrar().GetAppShortName(*app_id));
......
...@@ -219,6 +219,13 @@ const char* CustomTabBarView::GetClassName() const { ...@@ -219,6 +219,13 @@ const char* CustomTabBarView::GetClassName() const {
return kViewClassName; return kViewClassName;
} }
void CustomTabBarView::SetVisible(bool visible) {
if (!GetVisible() && visible) {
UpdateContents();
}
View::SetVisible(visible);
}
gfx::Size CustomTabBarView::CalculatePreferredSize() const { gfx::Size CustomTabBarView::CalculatePreferredSize() const {
// ToolbarView::GetMinimumSize() uses the preferred size of its children, so // ToolbarView::GetMinimumSize() uses the preferred size of its children, so
// tell it the minimum size this control will fit into (its layout will // tell it the minimum size this control will fit into (its layout will
...@@ -290,16 +297,21 @@ void CustomTabBarView::OnThemeChanged() { ...@@ -290,16 +297,21 @@ void CustomTabBarView::OnThemeChanged() {
void CustomTabBarView::TabChangedAt(content::WebContents* contents, void CustomTabBarView::TabChangedAt(content::WebContents* contents,
int index, int index,
TabChangeType change_type) { TabChangeType change_type) {
if (!contents) if (delegate_->GetWebContents() == contents)
return; UpdateContents();
}
void CustomTabBarView::UpdateContents() {
// If the toolbar should not be shown don't update the UI, as the toolbar may // If the toolbar should not be shown don't update the UI, as the toolbar may
// be animating out and it looks messy. // be animating out and it looks messy.
Browser* browser = chrome::FindBrowserWithWebContents(contents); web_app::AppBrowserController* const app_controller =
web_app::AppBrowserController* app_controller = browser->app_controller(); browser_->app_controller();
if (app_controller && !app_controller->ShouldShowCustomTabBar()) { if (app_controller && !app_controller->ShouldShowCustomTabBar())
return;
content::WebContents* contents = delegate_->GetWebContents();
if (!contents)
return; return;
}
content::NavigationEntry* entry = contents->GetController().GetVisibleEntry(); content::NavigationEntry* entry = contents->GetController().GetVisibleEntry();
base::string16 title, location; base::string16 title, location;
......
...@@ -50,6 +50,7 @@ class CustomTabBarView : public views::AccessiblePaneView, ...@@ -50,6 +50,7 @@ class CustomTabBarView : public views::AccessiblePaneView,
// views::AccessiblePaneView: // views::AccessiblePaneView:
gfx::Rect GetAnchorBoundsInScreen() const override; gfx::Rect GetAnchorBoundsInScreen() const override;
const char* GetClassName() const override; const char* GetClassName() const override;
void SetVisible(bool visible) override;
gfx::Size CalculatePreferredSize() const override; gfx::Size CalculatePreferredSize() const override;
void OnPaintBackground(gfx::Canvas* canvas) override; void OnPaintBackground(gfx::Canvas* canvas) override;
void ChildPreferredSizeChanged(views::View* child) override; void ChildPreferredSizeChanged(views::View* child) override;
...@@ -119,6 +120,9 @@ class CustomTabBarView : public views::AccessiblePaneView, ...@@ -119,6 +120,9 @@ class CustomTabBarView : public views::AccessiblePaneView,
// Convenience method to return the theme color from |app_controller_|. // Convenience method to return the theme color from |app_controller_|.
base::Optional<SkColor> GetThemeColor() const; base::Optional<SkColor> GetThemeColor() const;
// Populates child elements with page details from the current WebContents.
void UpdateContents();
SkColor title_bar_color_; SkColor title_bar_color_;
SkColor background_color_; SkColor background_color_;
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "base/test/scoped_feature_list.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "chrome/browser/renderer_context_menu/render_view_context_menu_test_util.h" #include "chrome/browser/renderer_context_menu/render_view_context_menu_test_util.h"
#include "chrome/browser/ui/browser_commands.h" #include "chrome/browser/ui/browser_commands.h"
...@@ -25,6 +26,7 @@ ...@@ -25,6 +26,7 @@
#include "content/public/test/content_mock_cert_verifier.h" #include "content/public/test/content_mock_cert_verifier.h"
#include "content/public/test/test_navigation_observer.h" #include "content/public/test/test_navigation_observer.h"
#include "net/dns/mock_host_resolver.h" #include "net/dns/mock_host_resolver.h"
#include "third_party/blink/public/common/features.h"
#include "ui/base/clipboard/clipboard.h" #include "ui/base/clipboard/clipboard.h"
#include "ui/views/controls/button/image_button.h" #include "ui/views/controls/button/image_button.h"
...@@ -189,6 +191,12 @@ class CustomTabBarViewBrowserTest ...@@ -189,6 +191,12 @@ class CustomTabBarViewBrowserTest
cert_verifier_.SetUpCommandLine(command_line); cert_verifier_.SetUpCommandLine(command_line);
} }
void SetUp() override {
feature_list_.InitAndDisableFeature(
blink::features::kMixedContentAutoupgrade);
web_app::WebAppControllerBrowserTest::SetUp();
}
void SetUpOnMainThread() override { void SetUpOnMainThread() override {
https_server_.AddDefaultHandlers(GetChromeTestDataDir()); https_server_.AddDefaultHandlers(GetChromeTestDataDir());
...@@ -244,6 +252,8 @@ class CustomTabBarViewBrowserTest ...@@ -244,6 +252,8 @@ class CustomTabBarViewBrowserTest
DCHECK(app_controller_); DCHECK(app_controller_);
} }
base::test::ScopedFeatureList feature_list_;
net::EmbeddedTestServer https_server_; net::EmbeddedTestServer https_server_;
// Similar to net::MockCertVerifier, but also updates the CertVerifier // Similar to net::MockCertVerifier, but also updates the CertVerifier
// used by the NetworkService. // used by the NetworkService.
...@@ -320,6 +330,35 @@ IN_PROC_BROWSER_TEST_P(CustomTabBarViewBrowserTest, IsUsedForDesktopPWA) { ...@@ -320,6 +330,35 @@ IN_PROC_BROWSER_TEST_P(CustomTabBarViewBrowserTest, IsUsedForDesktopPWA) {
EXPECT_TRUE(app_view->toolbar()->custom_tab_bar()); EXPECT_TRUE(app_view->toolbar()->custom_tab_bar());
} }
// Check the CustomTabBarView appears when a PWA window attempts to load
// insecure content.
IN_PROC_BROWSER_TEST_P(CustomTabBarViewBrowserTest, ShowsWithMixedContent) {
ASSERT_TRUE(https_server()->Start());
ASSERT_TRUE(embedded_test_server()->Start());
const GURL& url = https_server()->GetURL("app.com", "/ssl/google.html");
InstallPWA(url);
ASSERT_TRUE(app_browser_);
CustomTabBarView* bar = BrowserView::GetBrowserViewForBrowser(app_browser_)
->toolbar()
->custom_tab_bar();
EXPECT_FALSE(bar->GetVisible());
EXPECT_TRUE(ExecJs(app_browser_->tab_strip_model()->GetActiveWebContents(),
R"(
let img = document.createElement('img');
img.src = 'http://not-secure.com';
document.body.appendChild(img);
)"));
EXPECT_TRUE(bar->GetVisible());
EXPECT_EQ(bar->title_for_testing(), base::ASCIIToUTF16("Google"));
EXPECT_EQ(bar->location_for_testing() + base::ASCIIToUTF16("/"),
base::ASCIIToUTF16(
https_server()->GetURL("app.com", "/ssl").GetOrigin().spec()));
EXPECT_FALSE(bar->close_button_for_testing()->GetVisible());
}
// The custom tab bar should update with the title and location of the current // The custom tab bar should update with the title and location of the current
// page. // page.
IN_PROC_BROWSER_TEST_P(CustomTabBarViewBrowserTest, TitleAndLocationUpdate) { IN_PROC_BROWSER_TEST_P(CustomTabBarViewBrowserTest, TitleAndLocationUpdate) {
......
...@@ -117,10 +117,6 @@ AppBrowserController::~AppBrowserController() { ...@@ -117,10 +117,6 @@ AppBrowserController::~AppBrowserController() {
browser()->tab_strip_model()->RemoveObserver(this); browser()->tab_strip_model()->RemoveObserver(this);
} }
bool AppBrowserController::CreatedForInstalledPwa() const {
return false;
}
bool AppBrowserController::ShouldShowCustomTabBar() const { bool AppBrowserController::ShouldShowCustomTabBar() const {
if (!IsInstalled()) if (!IsInstalled())
return false; return false;
......
...@@ -57,9 +57,6 @@ class AppBrowserController : public TabStripModelObserver, ...@@ -57,9 +57,6 @@ class AppBrowserController : public TabStripModelObserver,
// Returns whether this controller was created for an installed PWA. // Returns whether this controller was created for an installed PWA.
virtual bool IsHostedApp() const; virtual bool IsHostedApp() const;
// Returns true if the associated Hosted App is for a PWA.
virtual bool CreatedForInstalledPwa() const;
// Whether the custom tab bar should be visible. // Whether the custom tab bar should be visible.
virtual bool ShouldShowCustomTabBar() const; virtual bool ShouldShowCustomTabBar() const;
......
...@@ -94,7 +94,7 @@ class PWAMixedContentBrowserTestWithAutoupgradesDisabled ...@@ -94,7 +94,7 @@ class PWAMixedContentBrowserTestWithAutoupgradesDisabled
base::test::ScopedFeatureList feature_list; base::test::ScopedFeatureList feature_list;
}; };
// Tests that mixed content is not loaded inside PWA windows. // Tests that mixed content is loaded inside PWA windows.
IN_PROC_BROWSER_TEST_P(PWAMixedContentBrowserTest, MixedContentInPWA) { IN_PROC_BROWSER_TEST_P(PWAMixedContentBrowserTest, MixedContentInPWA) {
ASSERT_TRUE(https_server()->Start()); ASSERT_TRUE(https_server()->Start());
ASSERT_TRUE(embedded_test_server()->Start()); ASSERT_TRUE(embedded_test_server()->Start());
...@@ -103,7 +103,7 @@ IN_PROC_BROWSER_TEST_P(PWAMixedContentBrowserTest, MixedContentInPWA) { ...@@ -103,7 +103,7 @@ IN_PROC_BROWSER_TEST_P(PWAMixedContentBrowserTest, MixedContentInPWA) {
const AppId app_id = InstallPWA(app_url); const AppId app_id = InstallPWA(app_url);
Browser* const app_browser = LaunchWebAppBrowserAndWait(app_id); Browser* const app_browser = LaunchWebAppBrowserAndWait(app_id);
CHECK(app_browser); CHECK(app_browser);
CheckMixedContentFailedToLoad(app_browser); web_app::CheckMixedContentFailedToLoad(app_browser);
} }
// Tests that creating a shortcut app but not installing a PWA is available for // Tests that creating a shortcut app but not installing a PWA is available for
...@@ -130,8 +130,8 @@ IN_PROC_BROWSER_TEST_P(PWAMixedContentBrowserTestWithAutoupgradesDisabled, ...@@ -130,8 +130,8 @@ IN_PROC_BROWSER_TEST_P(PWAMixedContentBrowserTestWithAutoupgradesDisabled,
const AppId app_id = InstallPWA(app_url); const AppId app_id = InstallPWA(app_url);
Browser* const app_browser = LaunchWebAppBrowserAndWait(app_id); Browser* const app_browser = LaunchWebAppBrowserAndWait(app_id);
// Mixed content is not allowed in PWAs. // Mixed content should be able to load in web app windows.
CheckMixedContentFailedToLoad(app_browser); CheckMixedContentLoaded(app_browser);
chrome::OpenInChrome(app_browser); chrome::OpenInChrome(app_browser);
ASSERT_EQ(browser(), chrome::FindLastActive()); ASSERT_EQ(browser(), chrome::FindLastActive());
...@@ -141,7 +141,7 @@ IN_PROC_BROWSER_TEST_P(PWAMixedContentBrowserTestWithAutoupgradesDisabled, ...@@ -141,7 +141,7 @@ IN_PROC_BROWSER_TEST_P(PWAMixedContentBrowserTestWithAutoupgradesDisabled,
->GetLastCommittedURL()); ->GetLastCommittedURL());
// The WebContents is just reparented, so mixed content is still not loaded. // The WebContents is just reparented, so mixed content is still not loaded.
CheckMixedContentFailedToLoad(browser()); CheckMixedContentLoaded(browser());
EXPECT_EQ(GetAppMenuCommandState(IDC_OPEN_IN_PWA_WINDOW, browser()), EXPECT_EQ(GetAppMenuCommandState(IDC_OPEN_IN_PWA_WINDOW, browser()),
kEnabled); kEnabled);
...@@ -150,13 +150,11 @@ IN_PROC_BROWSER_TEST_P(PWAMixedContentBrowserTestWithAutoupgradesDisabled, ...@@ -150,13 +150,11 @@ IN_PROC_BROWSER_TEST_P(PWAMixedContentBrowserTestWithAutoupgradesDisabled,
chrome::Reload(browser(), WindowOpenDisposition::CURRENT_TAB); chrome::Reload(browser(), WindowOpenDisposition::CURRENT_TAB);
url_observer.Wait(); url_observer.Wait();
// After reloading, mixed content should successfully load because the // After reloading, mixed content should successfully load.
// WebContents is no longer in a PWA window.
CheckMixedContentLoaded(browser()); CheckMixedContentLoaded(browser());
EXPECT_EQ(GetAppMenuCommandState(IDC_OPEN_IN_PWA_WINDOW, browser()), EXPECT_EQ(GetAppMenuCommandState(IDC_OPEN_IN_PWA_WINDOW, browser()),
kNotPresent); kEnabled);
EXPECT_EQ(ReparentWebAppForSecureActiveTab(browser()), nullptr); EXPECT_NE(ReparentWebAppForActiveTab(browser()), nullptr);
} }
// Tests that when calling ReparentWebContentsIntoAppBrowser, mixed // Tests that when calling ReparentWebContentsIntoAppBrowser, mixed
...@@ -177,7 +175,7 @@ IN_PROC_BROWSER_TEST_P(PWAMixedContentBrowserTestWithAutoupgradesDisabled, ...@@ -177,7 +175,7 @@ IN_PROC_BROWSER_TEST_P(PWAMixedContentBrowserTestWithAutoupgradesDisabled,
// A regular tab should be able to load mixed content. // A regular tab should be able to load mixed content.
CheckMixedContentLoaded(browser()); CheckMixedContentLoaded(browser());
EXPECT_EQ(GetAppMenuCommandState(IDC_OPEN_IN_PWA_WINDOW, browser()), EXPECT_EQ(GetAppMenuCommandState(IDC_OPEN_IN_PWA_WINDOW, browser()),
kNotPresent); kEnabled);
Browser* app_browser = Browser* app_browser =
ReparentWebContentsIntoAppBrowser(tab_contents, app_id); ReparentWebContentsIntoAppBrowser(tab_contents, app_id);
...@@ -188,9 +186,7 @@ IN_PROC_BROWSER_TEST_P(PWAMixedContentBrowserTestWithAutoupgradesDisabled, ...@@ -188,9 +186,7 @@ IN_PROC_BROWSER_TEST_P(PWAMixedContentBrowserTestWithAutoupgradesDisabled,
->GetLastCommittedURL()); ->GetLastCommittedURL());
// After reparenting, the WebContents should still have its mixed content // After reparenting, the WebContents should still have its mixed content
// loaded. Note that in practice, this should never happen for PWAs. Users // loaded.
// won't be able to reparent WebContents if there is mixed content loaded
// in them.
CheckMixedContentLoaded(app_browser); CheckMixedContentLoaded(app_browser);
ui_test_utils::UrlLoadObserver url_observer( ui_test_utils::UrlLoadObserver url_observer(
...@@ -198,9 +194,8 @@ IN_PROC_BROWSER_TEST_P(PWAMixedContentBrowserTestWithAutoupgradesDisabled, ...@@ -198,9 +194,8 @@ IN_PROC_BROWSER_TEST_P(PWAMixedContentBrowserTestWithAutoupgradesDisabled,
chrome::Reload(app_browser, WindowOpenDisposition::CURRENT_TAB); chrome::Reload(app_browser, WindowOpenDisposition::CURRENT_TAB);
url_observer.Wait(); url_observer.Wait();
// After reloading, mixed content should fail to load, because the WebContents // Mixed content should be able to load in web app windows.
// is now in a PWA window. CheckMixedContentLoaded(app_browser);
CheckMixedContentFailedToLoad(app_browser);
} }
// Tests that mixed content is not loaded inside iframes in PWA windows. // Tests that mixed content is not loaded inside iframes in PWA windows.
...@@ -235,10 +230,10 @@ IN_PROC_BROWSER_TEST_P( ...@@ -235,10 +230,10 @@ IN_PROC_BROWSER_TEST_P(
content::RenderFrameHost* main_frame = content::RenderFrameHost* main_frame =
app_browser->tab_strip_model()->GetActiveWebContents()->GetMainFrame(); app_browser->tab_strip_model()->GetActiveWebContents()->GetMainFrame();
content::RenderFrameHost* iframe = content::ChildFrameAt(main_frame, 0); content::RenderFrameHost* iframe = content::ChildFrameAt(main_frame, 0);
EXPECT_FALSE(TryToLoadImage( EXPECT_TRUE(TryToLoadImage(
iframe, embedded_test_server()->GetURL("foo.com", kImagePath))); iframe, embedded_test_server()->GetURL("foo.com", kImagePath)));
CheckMixedContentFailedToLoad(app_browser); CheckMixedContentLoaded(app_browser);
} }
// Tests that iframes can't dynamically load mixed content in a regular browser // Tests that iframes can't dynamically load mixed content in a regular browser
......
...@@ -30,10 +30,6 @@ WebAppBrowserController::WebAppBrowserController(Browser* browser) ...@@ -30,10 +30,6 @@ WebAppBrowserController::WebAppBrowserController(Browser* browser)
WebAppBrowserController::~WebAppBrowserController() = default; WebAppBrowserController::~WebAppBrowserController() = default;
bool WebAppBrowserController::CreatedForInstalledPwa() const {
return !registrar().IsShortcutApp(GetAppId());
}
bool WebAppBrowserController::HasMinimalUiButtons() const { bool WebAppBrowserController::HasMinimalUiButtons() const {
return registrar().GetAppEffectiveDisplayMode(GetAppId()) == return registrar().GetAppEffectiveDisplayMode(GetAppId()) ==
DisplayMode::kMinimalUi; DisplayMode::kMinimalUi;
......
...@@ -41,7 +41,6 @@ class WebAppBrowserController : public AppBrowserController, ...@@ -41,7 +41,6 @@ class WebAppBrowserController : public AppBrowserController,
~WebAppBrowserController() override; ~WebAppBrowserController() override;
// AppBrowserController: // AppBrowserController:
bool CreatedForInstalledPwa() const override;
bool HasMinimalUiButtons() const override; bool HasMinimalUiButtons() const override;
gfx::ImageSkia GetWindowAppIcon() const override; gfx::ImageSkia GetWindowAppIcon() const override;
gfx::ImageSkia GetWindowIcon() const override; gfx::ImageSkia GetWindowIcon() const override;
......
...@@ -96,16 +96,6 @@ class WebAppBrowserTest : public WebAppControllerBrowserTest { ...@@ -96,16 +96,6 @@ class WebAppBrowserTest : public WebAppControllerBrowserTest {
using WebAppTabRestoreBrowserTest = WebAppBrowserTest; using WebAppTabRestoreBrowserTest = WebAppBrowserTest;
IN_PROC_BROWSER_TEST_P(WebAppBrowserTest, CreatedForInstalledPwaForPwa) {
auto web_app_info = std::make_unique<WebApplicationInfo>();
web_app_info->app_url = GURL(kExampleURL);
web_app_info->scope = GURL(kExampleURL);
AppId app_id = InstallWebApp(std::move(web_app_info));
Browser* app_browser = LaunchWebAppBrowser(app_id);
EXPECT_TRUE(app_browser->app_controller()->CreatedForInstalledPwa());
}
IN_PROC_BROWSER_TEST_P(WebAppBrowserTest, ThemeColor) { IN_PROC_BROWSER_TEST_P(WebAppBrowserTest, ThemeColor) {
{ {
const SkColor theme_color = SkColorSetA(SK_ColorBLUE, 0xF0); const SkColor theme_color = SkColorSetA(SK_ColorBLUE, 0xF0);
...@@ -606,7 +596,7 @@ IN_PROC_BROWSER_TEST_P(WebAppBrowserTest, ReparentWebAppForSecureActiveTab) { ...@@ -606,7 +596,7 @@ IN_PROC_BROWSER_TEST_P(WebAppBrowserTest, ReparentWebAppForSecureActiveTab) {
EXPECT_EQ(GetAppMenuCommandState(IDC_OPEN_IN_PWA_WINDOW, browser()), EXPECT_EQ(GetAppMenuCommandState(IDC_OPEN_IN_PWA_WINDOW, browser()),
kEnabled); kEnabled);
Browser* const app_browser = ReparentWebAppForSecureActiveTab(browser()); Browser* const app_browser = ReparentWebAppForActiveTab(browser());
ASSERT_EQ(app_browser->app_controller()->GetAppId(), app_id); ASSERT_EQ(app_browser->app_controller()->GetAppId(), app_id);
} }
...@@ -619,7 +609,7 @@ IN_PROC_BROWSER_TEST_P(WebAppBrowserTest, ReparentLastBrowserTab) { ...@@ -619,7 +609,7 @@ IN_PROC_BROWSER_TEST_P(WebAppBrowserTest, ReparentLastBrowserTab) {
const AppId app_id = InstallPWA(app_url); const AppId app_id = InstallPWA(app_url);
NavigateToURLAndWait(browser(), app_url); NavigateToURLAndWait(browser(), app_url);
Browser* const app_browser = ReparentWebAppForSecureActiveTab(browser()); Browser* const app_browser = ReparentWebAppForActiveTab(browser());
ASSERT_EQ(app_browser->app_controller()->GetAppId(), app_id); ASSERT_EQ(app_browser->app_controller()->GetAppId(), app_id);
ASSERT_TRUE(IsBrowserOpen(browser())); ASSERT_TRUE(IsBrowserOpen(browser()));
......
...@@ -58,26 +58,16 @@ Browser* ReparentWebContentsWithBrowserCreateParams( ...@@ -58,26 +58,16 @@ Browser* ReparentWebContentsWithBrowserCreateParams(
namespace web_app { namespace web_app {
base::Optional<AppId> GetPwaForSecureActiveTab(Browser* browser) { base::Optional<AppId> GetWebAppForActiveTab(Browser* browser) {
switch (browser->location_bar_model()->GetSecurityLevel()) {
case security_state::SECURITY_LEVEL_COUNT:
NOTREACHED();
FALLTHROUGH;
case security_state::NONE:
case security_state::WARNING:
case security_state::DANGEROUS:
return base::nullopt;
case security_state::EV_SECURE:
case security_state::SECURE:
case security_state::SECURE_WITH_POLICY_INSTALLED_CERT:
break;
}
content::WebContents* web_contents =
browser->tab_strip_model()->GetActiveWebContents();
WebAppProvider* provider = WebAppProvider::Get(browser->profile()); WebAppProvider* provider = WebAppProvider::Get(browser->profile());
if (!provider) if (!provider)
return base::nullopt; return base::nullopt;
content::WebContents* web_contents =
browser->tab_strip_model()->GetActiveWebContents();
if (!web_contents)
return base::nullopt;
return provider->registrar().FindAppWithUrlInScope( return provider->registrar().FindAppWithUrlInScope(
web_contents->GetMainFrame()->GetLastCommittedURL()); web_contents->GetMainFrame()->GetLastCommittedURL());
} }
...@@ -102,8 +92,8 @@ void PrunePreScopeNavigationHistory(const GURL& scope, ...@@ -102,8 +92,8 @@ void PrunePreScopeNavigationHistory(const GURL& scope,
} }
} }
Browser* ReparentWebAppForSecureActiveTab(Browser* browser) { Browser* ReparentWebAppForActiveTab(Browser* browser) {
base::Optional<AppId> app_id = GetPwaForSecureActiveTab(browser); base::Optional<AppId> app_id = GetWebAppForActiveTab(browser);
if (!app_id) if (!app_id)
return nullptr; return nullptr;
return ReparentWebContentsIntoAppBrowser( return ReparentWebContentsIntoAppBrowser(
......
...@@ -19,16 +19,15 @@ class WebContents; ...@@ -19,16 +19,15 @@ class WebContents;
namespace web_app { namespace web_app {
base::Optional<AppId> GetPwaForSecureActiveTab(Browser* browser); base::Optional<AppId> GetWebAppForActiveTab(Browser* browser);
// Clears navigation history prior to user entering app scope. // Clears navigation history prior to user entering app scope.
void PrunePreScopeNavigationHistory(const GURL& scope, void PrunePreScopeNavigationHistory(const GURL& scope,
content::WebContents* contents); content::WebContents* contents);
// Reparents the active tab into a new app browser for the web app that has the // Reparents the active tab into a new app browser for the web app that has the
// tab's URL in its scope. Does nothing if the tab is not secure or there is no // tab's URL in its scope. Does nothing if there is no web app in scope.
// applicable web app. Browser* ReparentWebAppForActiveTab(Browser* browser);
Browser* ReparentWebAppForSecureActiveTab(Browser* browser);
// Reparents |contents| into a new app browser for |app_id|. // Reparents |contents| into a new app browser for |app_id|.
Browser* ReparentWebContentsIntoAppBrowser(content::WebContents* contents, Browser* ReparentWebContentsIntoAppBrowser(content::WebContents* contents,
......
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