Commit e49689cd authored by Matt Giuca's avatar Matt Giuca Committed by Commit Bot

Hosted/Bookmark apps now show the location bar for http connections.

HostedAppTest now use https for all tests other than http-specific ones
(otherwise, all tests would show a location bar, and we wouldn't be
properly testing any of the other behaviour).

Bug: 811158
Change-Id: I0fe220055fb6574c3950f65971e06feadaeabcd9
Reviewed-on: https://chromium-review.googlesource.com/913191Reviewed-by: default avatarBen Wells <benwells@chromium.org>
Reviewed-by: default avatarGiovanni Ortuño Urquidi <ortuno@chromium.org>
Commit-Queue: Matt Giuca <mgiuca@chromium.org>
Cr-Commit-Position: refs/heads/master@{#537588}
parent 085dec01
...@@ -33,10 +33,12 @@ namespace extensions { ...@@ -33,10 +33,12 @@ namespace extensions {
namespace { namespace {
bool IsSameOriginOrMoreSecure(const GURL& app_url, const GURL& page_url) { // Returns true if |page_url| is both secure (https) and on the same origin as
// |app_url|. Note that even if |app_url| is http, this still returns true as
// long as |page_url| is https.
bool IsSameOriginAndSecure(const GURL& app_url, const GURL& page_url) {
const std::string www("www."); const std::string www("www.");
return (app_url.scheme_piece() == page_url.scheme_piece() || return page_url.scheme_piece() == url::kHttpsScheme &&
page_url.scheme_piece() == url::kHttpsScheme) &&
(app_url.host_piece() == page_url.host_piece() || (app_url.host_piece() == page_url.host_piece() ||
www + app_url.host() == page_url.host_piece()) && www + app_url.host() == page_url.host_piece()) &&
app_url.port() == page_url.port(); app_url.port() == page_url.port();
...@@ -133,10 +135,9 @@ bool HostedAppBrowserController::ShouldShowLocationBar() const { ...@@ -133,10 +135,9 @@ bool HostedAppBrowserController::ShouldShowLocationBar() const {
} }
GURL launch_url = AppLaunchInfo::GetLaunchWebURL(extension); GURL launch_url = AppLaunchInfo::GetLaunchWebURL(extension);
return !(IsSameOriginOrMoreSecure(launch_url, return !IsSameOriginAndSecure(launch_url, web_contents->GetVisibleURL()) ||
web_contents->GetVisibleURL()) && !IsSameOriginAndSecure(launch_url,
IsSameOriginOrMoreSecure(launch_url, web_contents->GetLastCommittedURL());
web_contents->GetLastCommittedURL()));
} }
void HostedAppBrowserController::UpdateLocationBarVisibility( void HostedAppBrowserController::UpdateLocationBarVisibility(
......
...@@ -248,20 +248,20 @@ IN_PROC_BROWSER_TEST_P(HostedAppTest, CtrlClickLink) { ...@@ -248,20 +248,20 @@ IN_PROC_BROWSER_TEST_P(HostedAppTest, CtrlClickLink) {
// Check that the location bar is shown correctly. // Check that the location bar is shown correctly.
IN_PROC_BROWSER_TEST_P(HostedAppTest, ShouldShowLocationBar) { IN_PROC_BROWSER_TEST_P(HostedAppTest, ShouldShowLocationBar) {
SetupApp("app"); SetupApp("https_app");
// Navigate to the app's launch page; the location bar should be hidden. // Navigate to the app's launch page; the location bar should be hidden.
NavigateAndCheckForLocationBar( NavigateAndCheckForLocationBar(app_browser_,
app_browser_, "http://www.example.com/empty.html", false); "https://www.example.com/empty.html", false);
// Navigate to another page on the same origin; the location bar should still // Navigate to another page on the same origin; the location bar should still
// hidden. // hidden.
NavigateAndCheckForLocationBar( NavigateAndCheckForLocationBar(app_browser_, "https://www.example.com/blah",
app_browser_, "http://www.example.com/blah", false); false);
// Navigate to different origin; the location bar should now be visible. // Navigate to different origin; the location bar should now be visible.
NavigateAndCheckForLocationBar( NavigateAndCheckForLocationBar(app_browser_, "https://www.foo.com/blah",
app_browser_, "http://www.foo.com/blah", true); true);
} }
// Check that the location bar is shown correctly for HTTP apps when they // Check that the location bar is shown correctly for HTTP apps when they
...@@ -269,12 +269,13 @@ IN_PROC_BROWSER_TEST_P(HostedAppTest, ShouldShowLocationBar) { ...@@ -269,12 +269,13 @@ IN_PROC_BROWSER_TEST_P(HostedAppTest, ShouldShowLocationBar) {
IN_PROC_BROWSER_TEST_P(HostedAppTest, ShouldShowLocationBarForHTTPApp) { IN_PROC_BROWSER_TEST_P(HostedAppTest, ShouldShowLocationBarForHTTPApp) {
SetupApp("app"); SetupApp("app");
// Navigate to the app's launch page; the location bar should be hidden. // Navigate to the app's launch page; the location bar should be visible, even
NavigateAndCheckForLocationBar( // though it exactly matches the site, because it is not secure.
app_browser_, "http://www.example.com/empty.html", false); NavigateAndCheckForLocationBar(app_browser_,
"http://www.example.com/empty.html", true);
// Navigate to the https version of the site; the location bar should // Navigate to the https version of the site; the location bar should
// be hidden. // be hidden, as it is a more secure version of the site.
NavigateAndCheckForLocationBar( NavigateAndCheckForLocationBar(
app_browser_, "https://www.example.com/blah", false); app_browser_, "https://www.example.com/blah", false);
} }
...@@ -289,8 +290,7 @@ IN_PROC_BROWSER_TEST_P(HostedAppTest, ShouldShowLocationBarForHTTPSApp) { ...@@ -289,8 +290,7 @@ IN_PROC_BROWSER_TEST_P(HostedAppTest, ShouldShowLocationBarForHTTPSApp) {
app_browser_, "https://www.example.com/empty.html", false); app_browser_, "https://www.example.com/empty.html", false);
// Navigate to the http version of the site; the location bar should // Navigate to the http version of the site; the location bar should
// be visible for the https version as it is now on a less secure version // be visible for the https version as it is not secure.
// of its host.
NavigateAndCheckForLocationBar( NavigateAndCheckForLocationBar(
app_browser_, "http://www.example.com/blah", true); app_browser_, "http://www.example.com/blah", true);
} }
...@@ -298,20 +298,20 @@ IN_PROC_BROWSER_TEST_P(HostedAppTest, ShouldShowLocationBarForHTTPSApp) { ...@@ -298,20 +298,20 @@ IN_PROC_BROWSER_TEST_P(HostedAppTest, ShouldShowLocationBarForHTTPSApp) {
// Check that the location bar is shown correctly for apps that specify start // Check that the location bar is shown correctly for apps that specify start
// URLs without the 'www.' prefix. // URLs without the 'www.' prefix.
IN_PROC_BROWSER_TEST_P(HostedAppTest, ShouldShowLocationBarForAppWithoutWWW) { IN_PROC_BROWSER_TEST_P(HostedAppTest, ShouldShowLocationBarForAppWithoutWWW) {
SetupApp("app_no_www"); SetupApp("https_app_no_www");
// Navigate to the app's launch page; the location bar should be hidden. // Navigate to the app's launch page; the location bar should be hidden.
NavigateAndCheckForLocationBar( NavigateAndCheckForLocationBar(app_browser_, "https://example.com/empty.html",
app_browser_, "http://example.com/empty.html", false); false);
// Navigate to the app's launch page with the 'www.' prefis; the location bar // Navigate to the app's launch page with the 'www.' prefis; the location bar
// should be hidden. // should be hidden.
NavigateAndCheckForLocationBar( NavigateAndCheckForLocationBar(app_browser_,
app_browser_, "http://www.example.com/empty.html", false); "https://www.example.com/empty.html", false);
// Navigate to different origin; the location bar should now be visible. // Navigate to different origin; the location bar should now be visible.
NavigateAndCheckForLocationBar( NavigateAndCheckForLocationBar(app_browser_, "https://www.foo.com/blah",
app_browser_, "http://www.foo.com/blah", true); true);
} }
// Check that a subframe on a regular web page can navigate to a URL that // Check that a subframe on a regular web page can navigate to a URL that
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
"manifest_version": 2, "manifest_version": 2,
"app": { "app": {
"launch": { "launch": {
"web_url": "http://example.com/" "web_url": "https://example.com/"
} }
} }
} }
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