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

Side by Side Diff: chrome/browser/autocomplete/autocomplete_edit_view_win.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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/autocomplete/autocomplete_edit_view_win.h" 5 #include "chrome/browser/autocomplete/autocomplete_edit_view_win.h"
6 6
7 #include <locale> 7 #include <locale>
8 8
9 #include "base/base_drag_source.h" 9 #include "base/base_drag_source.h"
10 #include "base/base_drop_target.h" 10 #include "base/base_drop_target.h"
(...skipping 1866 matching lines...) Expand 10 before | Expand all | Expand 10 after
1877 // Save the selection. 1877 // Save the selection.
1878 CHARRANGE saved_sel; 1878 CHARRANGE saved_sel;
1879 GetSelection(saved_sel); 1879 GetSelection(saved_sel);
1880 1880
1881 // See whether the contents are a URL with a non-empty host portion, which we 1881 // See whether the contents are a URL with a non-empty host portion, which we
1882 // should emphasize. To check for a URL, rather than using the type returned 1882 // should emphasize. To check for a URL, rather than using the type returned
1883 // by Parse(), ask the model, which will check the desired page transition for 1883 // by Parse(), ask the model, which will check the desired page transition for
1884 // this input. This can tell us whether an UNKNOWN input string is going to 1884 // this input. This can tell us whether an UNKNOWN input string is going to
1885 // be treated as a search or a navigation, and is the same method the Paste 1885 // be treated as a search or a navigation, and is the same method the Paste
1886 // And Go system uses. 1886 // And Go system uses.
1887 url_parse::Parsed parts; 1887 url_parse::Component scheme, host;
1888 AutocompleteInput::Parse(GetText(), model_->GetDesiredTLD(), &parts, NULL); 1888 AutocompleteInput::ParseForEmphasizeComponents(
1889 const bool emphasize = model_->CurrentTextIsURL() && (parts.host.len > 0); 1889 GetText(), model_->GetDesiredTLD(), &scheme, &host);
1890 const bool emphasize = model_->CurrentTextIsURL() && (host.len > 0);
1890 1891
1891 // Set the baseline emphasis. 1892 // Set the baseline emphasis.
1892 CHARFORMAT cf = {0}; 1893 CHARFORMAT cf = {0};
1893 cf.dwMask = CFM_COLOR; 1894 cf.dwMask = CFM_COLOR;
1894 cf.dwEffects = 0; 1895 cf.dwEffects = 0;
1895 cf.crTextColor = GetSysColor(emphasize ? COLOR_GRAYTEXT : COLOR_WINDOWTEXT); 1896 cf.crTextColor = GetSysColor(emphasize ? COLOR_GRAYTEXT : COLOR_WINDOWTEXT);
1896 SelectAll(false); 1897 SelectAll(false);
1897 SetSelectionCharFormat(cf); 1898 SetSelectionCharFormat(cf);
1898 1899
1899 if (emphasize) { 1900 if (emphasize) {
1900 // We've found a host name, give it more emphasis. 1901 // We've found a host name, give it more emphasis.
1901 cf.crTextColor = GetSysColor(COLOR_WINDOWTEXT); 1902 cf.crTextColor = GetSysColor(COLOR_WINDOWTEXT);
1902 SetSelection(parts.host.begin, parts.host.end()); 1903 SetSelection(host.begin, host.end());
1903 SetSelectionCharFormat(cf); 1904 SetSelectionCharFormat(cf);
1904 } 1905 }
1905 1906
1906 // Emphasize the scheme for security UI display purposes (if necessary). 1907 // Emphasize the scheme for security UI display purposes (if necessary).
1907 insecure_scheme_component_.reset(); 1908 insecure_scheme_component_.reset();
1908 if (!model_->user_input_in_progress() && parts.scheme.is_nonempty() && 1909 if (!model_->user_input_in_progress() && scheme.is_nonempty() &&
1909 (scheme_security_level_ != ToolbarModel::NORMAL)) { 1910 (scheme_security_level_ != ToolbarModel::NORMAL)) {
1910 if (scheme_security_level_ == ToolbarModel::SECURE) { 1911 if (scheme_security_level_ == ToolbarModel::SECURE) {
1911 cf.crTextColor = kSecureSchemeColor; 1912 cf.crTextColor = kSecureSchemeColor;
1912 } else { 1913 } else {
1913 insecure_scheme_component_.begin = parts.scheme.begin; 1914 insecure_scheme_component_.begin = scheme.begin;
1914 insecure_scheme_component_.len = parts.scheme.len; 1915 insecure_scheme_component_.len = scheme.len;
1915 cf.crTextColor = kInsecureSchemeColor; 1916 cf.crTextColor = kInsecureSchemeColor;
1916 } 1917 }
1917 SetSelection(parts.scheme.begin, parts.scheme.end()); 1918 SetSelection(scheme.begin, scheme.end());
1918 SetSelectionCharFormat(cf); 1919 SetSelectionCharFormat(cf);
1919 } 1920 }
1920 1921
1921 // Restore the selection. 1922 // Restore the selection.
1922 SetSelectionRange(saved_sel); 1923 SetSelectionRange(saved_sel);
1923 } 1924 }
1924 1925
1925 void AutocompleteEditViewWin::EraseTopOfSelection( 1926 void AutocompleteEditViewWin::EraseTopOfSelection(
1926 CDC* dc, const CRect& client_rect, const CRect& paint_clip_rect) { 1927 CDC* dc, const CRect& client_rect, const CRect& paint_clip_rect) {
1927 // Find the area we care about painting. We could calculate the rect 1928 // Find the area we care about painting. We could calculate the rect
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
2223 } 2224 }
2224 2225
2225 void AutocompleteEditViewWin::RepaintDropHighlight(int position) { 2226 void AutocompleteEditViewWin::RepaintDropHighlight(int position) {
2226 if ((position != -1) && (position <= GetTextLength())) { 2227 if ((position != -1) && (position <= GetTextLength())) {
2227 const POINT min_loc(PosFromChar(position)); 2228 const POINT min_loc(PosFromChar(position));
2228 const RECT highlight_bounds = {min_loc.x - 1, font_y_adjustment_, 2229 const RECT highlight_bounds = {min_loc.x - 1, font_y_adjustment_,
2229 min_loc.x + 2, font_ascent_ + font_descent_ + font_y_adjustment_}; 2230 min_loc.x + 2, font_ascent_ + font_descent_ + font_y_adjustment_};
2230 InvalidateRect(&highlight_bounds, false); 2231 InvalidateRect(&highlight_bounds, false);
2231 } 2232 }
2232 } 2233 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/autocomplete.cc ('k') | chrome/browser/autocomplete/autocomplete_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698