Commit 78ae0493 authored by Olya Kalitova's avatar Olya Kalitova Committed by Commit Bot

Auto-add scheme to the new tab URL

Auto-adds https scheme to the new tab URL if scheme is not provided.
For example, when NewTabPageLocation policy specifies URL without scheme
-- https:// gets added by default.

Bug: 1097727
Test: manually on DUT using YAPS

Change-Id: I5c1185a08033c6d8605f1fac5e89b50151d5547b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2416293
Commit-Queue: Olya Kalitova <okalitova@chromium.org>
Reviewed-by: default avatarJulian Pastarmov <pastarmovj@chromium.org>
Cr-Commit-Position: refs/heads/master@{#808821}
parent 861c2f7b
...@@ -366,6 +366,8 @@ ...@@ -366,6 +366,8 @@
#include "ui/resources/grit/ui_resources.h" #include "ui/resources/grit/ui_resources.h"
#include "url/gurl.h" #include "url/gurl.h"
#include "url/origin.h" #include "url/origin.h"
#include "url/third_party/mozilla/url_parse.h"
#include "url/url_constants.h"
#if defined(OS_WIN) #if defined(OS_WIN)
#include "base/strings/string_tokenizer.h" #include "base/strings/string_tokenizer.h"
...@@ -750,6 +752,12 @@ bool HandleNewTabPageLocationOverride( ...@@ -750,6 +752,12 @@ bool HandleNewTabPageLocationOverride(
profile->GetPrefs()->GetString(prefs::kNewTabPageLocationOverride); profile->GetPrefs()->GetString(prefs::kNewTabPageLocationOverride);
if (ntp_location.empty()) if (ntp_location.empty())
return false; return false;
url::Component scheme;
if (!url::ExtractScheme(ntp_location.data(),
static_cast<int>(ntp_location.length()), &scheme)) {
ntp_location = base::StrCat(
{url::kHttpsScheme, url::kStandardSchemeSeparator, ntp_location});
}
*url = GURL(ntp_location); *url = GURL(ntp_location);
return true; return true;
......
...@@ -1247,7 +1247,7 @@ ...@@ -1247,7 +1247,7 @@
'id': 360, 'id': 360,
'caption': '''Configure the New Tab page URL''', 'caption': '''Configure the New Tab page URL''',
'tags': [], 'tags': [],
'desc': '''Setting the policy sets the default New Tab page URL. The New Tab page opens with new tabs and windows. This policy doesn't decide which pages open on start up. Those are controlled by the <ph name="RESTORE_ON_STARTUP_POLICY_NAME">RestoreOnStartup</ph> policies. This policy does affect the homepage, if that's set to open the New Tab page, as well as the startup page if it's set to open the New Tab page. 'desc': '''Setting the policy sets the default New Tab page URL. The New Tab page opens with new tabs and windows. This policy doesn't decide which pages open on start up. Those are controlled by the <ph name="RESTORE_ON_STARTUP_POLICY_NAME">RestoreOnStartup</ph> policies. This policy does affect the homepage, if that's set to open the New Tab page, as well as the startup page if it's set to open the New Tab page. It is a best practice to provide fully canonicalized URL, if the URL is not fully canonicalized <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph> will default to https://.
Leaving the policy unset or empty puts the default New Tab page in use. Leaving the policy unset or empty puts the default New Tab page in use.
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