default-to-https-scheme.patch 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. # Default to https for (non-standard) URLs without scheme.
  2. #
  3. # This patch handles URLs like user:pass@example.com and trims scheme in suggestions if it is implicit.
  4. # URLs entered in md_bookmarks (chrome://bookmarks) will also get https:// prefix.
  5. #
  6. # Note that there is a small hack in AutocompleteInput::HasHTTPScheme: we check kHttpsScheme instead.
  7. # All other changes in omnibox were made to preserve old behavior.
  8. --- a/components/url_formatter/url_fixer.cc
  9. +++ b/components/url_formatter/url_fixer.cc
  10. @@ -438,9 +438,9 @@ std::string SegmentURLInternal(std::stri
  11. (*text)[semicolon] = ';';
  12. }
  13. if (!found_scheme) {
  14. - // Couldn't determine the scheme, so just default to http.
  15. + // Couldn't determine the scheme, so just default to https.
  16. parts->scheme.reset();
  17. - scheme = url::kHttpScheme;
  18. + scheme = url::kHttpsScheme;
  19. }
  20. }
  21. --- a/components/omnibox/browser/autocomplete_input.cc
  22. +++ b/components/omnibox/browser/autocomplete_input.cc
  23. @@ -237,7 +237,7 @@ metrics::OmniboxInputType AutocompleteIn
  24. // We don't know about this scheme. It might be that the user typed a
  25. // URL of the form "username:password@foo.com".
  26. const base::string16 http_scheme_prefix =
  27. - base::ASCIIToUTF16(std::string(url::kHttpScheme) +
  28. + base::ASCIIToUTF16(std::string(url::kHttpsScheme) +
  29. url::kStandardSchemeSeparator);
  30. url::Parsed http_parts;
  31. base::string16 http_scheme;
  32. @@ -245,7 +245,7 @@ metrics::OmniboxInputType AutocompleteIn
  33. metrics::OmniboxInputType http_type =
  34. Parse(http_scheme_prefix + text, desired_tld, scheme_classifier,
  35. &http_parts, &http_scheme, &http_canonicalized_url);
  36. - DCHECK_EQ(std::string(url::kHttpScheme),
  37. + DCHECK_EQ(std::string(url::kHttpsScheme),
  38. base::UTF16ToUTF8(http_scheme));
  39. if ((http_type == metrics::OmniboxInputType::URL) &&
  40. @@ -575,7 +575,7 @@ bool AutocompleteInput::HasHTTPScheme(co
  41. } else if (url::FindAndCompareScheme(utf8_input, kViewSourceScheme, &scheme)) {
  42. utf8_input.erase(0, scheme.end() + 1);
  43. }
  44. - return url::FindAndCompareScheme(utf8_input, url::kHttpScheme, nullptr);
  45. + return url::FindAndCompareScheme(utf8_input, url::kHttpsScheme, nullptr);
  46. }
  47. void AutocompleteInput::UpdateText(const base::string16& text,
  48. --- a/components/omnibox/browser/autocomplete_provider.cc
  49. +++ b/components/omnibox/browser/autocomplete_provider.cc
  50. @@ -233,11 +233,11 @@ size_t AutocompleteProvider::TrimHttpPre
  51. if (!AutocompleteInput::HasHTTPScheme(*url))
  52. return 0;
  53. size_t scheme_pos =
  54. - url->find(base::ASCIIToUTF16(url::kHttpScheme) + base::char16(':'));
  55. + url->find(base::ASCIIToUTF16(url::kHttpsScheme) + base::char16(':'));
  56. DCHECK_NE(base::string16::npos, scheme_pos);
  57. // Erase scheme plus up to two slashes.
  58. - size_t prefix_end = scheme_pos + strlen(url::kHttpScheme) + 1;
  59. + size_t prefix_end = scheme_pos + strlen(url::kHttpsScheme) + 1;
  60. const size_t after_slashes = std::min(url->length(), prefix_end + 2);
  61. while ((prefix_end < after_slashes) && ((*url)[prefix_end] == '/'))
  62. ++prefix_end;
  63. --- a/chrome/browser/resources/bookmarks/edit_dialog.js
  64. +++ b/chrome/browser/resources/bookmarks/edit_dialog.js
  65. @@ -95,7 +95,7 @@ Polymer({
  66. /**
  67. * Validates the value of the URL field, returning true if it is a valid URL.
  68. - * May modify the value by prepending 'http://' in order to make it valid.
  69. + * May modify the value by prepending 'https://' in order to make it valid.
  70. * @return {boolean}
  71. * @private
  72. */
  73. @@ -107,7 +107,7 @@ Polymer({
  74. return true;
  75. }
  76. - this.urlValue_ = 'http://' + originalValue;
  77. + this.urlValue_ = 'https://' + originalValue;
  78. if (urlInput.validate()) {
  79. return true;