Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(335)

Unified Diff: chrome/browser/autocomplete/autocomplete.cc

Issue 62094: Emaphasize "https" instead of "view-source" when user accesses secure/insecur... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/autocomplete/autocomplete.cc
===================================================================
--- chrome/browser/autocomplete/autocomplete.cc (revision 13588)
+++ chrome/browser/autocomplete/autocomplete.cc (working copy)
@@ -236,6 +236,47 @@
return desired_tld.empty() ? UNKNOWN : REQUESTED_URL;
}
+// static
+void AutocompleteInput::ParseForEmphasizeComponents(
+ const std::wstring& text,
+ const std::wstring& desired_tld,
+ url_parse::Component* scheme,
+ url_parse::Component* host) {
+ url_parse::Parsed parts;
+ std::wstring scheme_str;
+ Parse(text, desired_tld, &parts, &scheme_str);
+
+ *scheme = parts.scheme;
+ *host = parts.host;
+
+ int after_scheme_and_colon = parts.scheme.end() + 1;
+ // For the view-source scheme, we should emphasize the scheme and host of
+ // the URL qualified by the view-source prefix.
+ if (LowerCaseEqualsASCII(scheme_str, chrome::kViewSourceScheme) &&
+ (static_cast<int>(text.length()) > after_scheme_and_colon)) {
+ // Obtain the URL prefixed by view-source and parse it.
+ std::wstring real_url(text.substr(after_scheme_and_colon));
+ url_parse::Parsed real_parts;
+ AutocompleteInput::Parse(real_url, desired_tld, &real_parts, NULL);
+ if (real_parts.scheme.is_nonempty() || real_parts.host.is_nonempty()) {
+ if (real_parts.scheme.is_nonempty()) {
+ *scheme = url_parse::Component(
+ after_scheme_and_colon + real_parts.scheme.begin,
+ real_parts.scheme.len);
+ } else {
+ scheme->reset();
+ }
+ if (real_parts.host.is_nonempty()) {
+ *host = url_parse::Component(
+ after_scheme_and_colon + real_parts.host.begin,
+ real_parts.host.len);
+ } else {
+ host->reset();
+ }
+ }
+ }
+}
+
bool AutocompleteInput::Equals(const AutocompleteInput& other) const {
return (text_ == other.text_) &&
(type_ == other.type_) &&
« no previous file with comments | « chrome/browser/autocomplete/autocomplete.h ('k') | chrome/browser/autocomplete/autocomplete_edit_view_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698