diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-04 03:30:34 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-04 03:30:34 +0000 |
commit | 49bcfd24022de81f8492f261cd6781803f902026 (patch) | |
tree | 57dd8de0dcc62a395be73205343491fb509ba5f1 /chrome | |
parent | 87ae793de65887136e54170263a8a7fa88102ff0 (diff) | |
download | chromium_src-49bcfd24022de81f8492f261cd6781803f902026.zip chromium_src-49bcfd24022de81f8492f261cd6781803f902026.tar.gz chromium_src-49bcfd24022de81f8492f261cd6781803f902026.tar.bz2 |
GTK/Mac: show security warning on correct part of url.
Where "security warning" means "diagonal red line".
This change just copies the relevant code from Windows; my suspicion is that when the windows code was updated, mac and linux had already copied the old, incorrect code, but the bug didn't become apparent until the security UI was implemented on those platforms.
BUG=26280
TEST=manual
Review URL: http://codereview.chromium.org/668016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40595 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc | 19 | ||||
-rw-r--r-- | chrome/browser/autocomplete/autocomplete_edit_view_mac.mm | 18 |
2 files changed, 19 insertions, 18 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc index a805539..ae241e0 100644 --- a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc +++ b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc @@ -1307,10 +1307,11 @@ void AutocompleteEditViewGtk::EmphasizeURLComponents() { // this input. This can tell us whether an UNKNOWN input string is going to // be treated as a search or a navigation, and is the same method the Paste // And Go system uses. - url_parse::Parsed parts; - std::wstring text = GetText(); - AutocompleteInput::Parse(text, model_->GetDesiredTLD(), &parts, NULL); - bool emphasize = model_->CurrentTextIsURL() && (parts.host.len > 0); + url_parse::Component scheme, host; + std::wstring text(GetText()); + AutocompleteInput::ParseForEmphasizeComponents( + text, model_->GetDesiredTLD(), &scheme, &host); + const bool emphasize = model_->CurrentTextIsURL() && (host.len > 0); // Set the baseline emphasis. GtkTextIter start, end; @@ -1322,10 +1323,10 @@ void AutocompleteEditViewGtk::EmphasizeURLComponents() { // We've found a host name, give it more emphasis. gtk_text_buffer_get_iter_at_line_index(text_buffer_, &start, 0, GetUTF8Offset(text, - parts.host.begin)); + host.begin)); gtk_text_buffer_get_iter_at_line_index(text_buffer_, &end, 0, GetUTF8Offset(text, - parts.host.end())); + host.end())); gtk_text_buffer_apply_tag(text_buffer_, normal_text_tag_, &start, &end); } else { @@ -1334,10 +1335,10 @@ void AutocompleteEditViewGtk::EmphasizeURLComponents() { strikethrough_ = CharRange(); // Emphasize the scheme for security UI display purposes (if necessary). - if (!model_->user_input_in_progress() && parts.scheme.is_nonempty() && + if (!model_->user_input_in_progress() && scheme.is_nonempty() && (scheme_security_level_ != ToolbarModel::NORMAL)) { - CharRange scheme_range = CharRange(GetUTF8Offset(text, parts.scheme.begin), - GetUTF8Offset(text, parts.scheme.end())); + CharRange scheme_range = CharRange(GetUTF8Offset(text, scheme.begin), + GetUTF8Offset(text, scheme.end())); ItersFromCharRange(scheme_range, &start, &end); if (scheme_security_level_ == ToolbarModel::SECURE) { diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm b/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm index e3881e0..a78a6b7 100644 --- a/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm +++ b/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -394,16 +394,16 @@ void AutocompleteEditViewMac::SetText(const std::wstring& display_text) { [as addAttribute:NSParagraphStyleAttributeName value:paragraph_style range:NSMakeRange(0, [as length])]; - url_parse::Parsed parts; - AutocompleteInput::Parse(display_text, model_->GetDesiredTLD(), - &parts, NULL); - const bool emphasize = model_->CurrentTextIsURL() && (parts.host.len > 0); + url_parse::Component scheme, host; + AutocompleteInput::ParseForEmphasizeComponents( + display_text, model_->GetDesiredTLD(), &scheme, &host); + const bool emphasize = model_->CurrentTextIsURL() && (host.len > 0); if (emphasize) { [as addAttribute:NSForegroundColorAttributeName value:BaseTextColor() range:NSMakeRange(0, [as length])]; [as addAttribute:NSForegroundColorAttributeName value:HostTextColor() - range:ComponentToNSRange(parts.host)]; + range:ComponentToNSRange(host)]; } // TODO(shess): GTK has this as a member var, figure out why. @@ -424,7 +424,7 @@ void AutocompleteEditViewMac::SetText(const std::wstring& display_text) { } // Emphasize the scheme for security UI display purposes (if necessary). - if (!model_->user_input_in_progress() && parts.scheme.is_nonempty() && + if (!model_->user_input_in_progress() && scheme.is_nonempty() && (scheme_security_level != ToolbarModel::NORMAL)) { NSColor* color; if (scheme_security_level == ToolbarModel::SECURE) { @@ -434,10 +434,10 @@ void AutocompleteEditViewMac::SetText(const std::wstring& display_text) { // Add a strikethrough through the scheme. [as addAttribute:NSStrikethroughStyleAttributeName value:[NSNumber numberWithInt:NSUnderlineStyleSingle] - range:ComponentToNSRange(parts.scheme)]; + range:ComponentToNSRange(scheme)]; } [as addAttribute:NSForegroundColorAttributeName value:color - range:ComponentToNSRange(parts.scheme)]; + range:ComponentToNSRange(scheme)]; } [field_ setAttributedStringValue:as]; |