summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autocomplete
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-24 19:00:55 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-24 19:00:55 +0000
commit345f8e4b5d9e1531e461cce3fd578372779c956a (patch)
tree69c46a93356a4ff180154fda0c050754231eafa1 /chrome/browser/autocomplete
parent8a9092a112ccbccd7c20c5c2f40e5e085c59febf (diff)
downloadchromium_src-345f8e4b5d9e1531e461cce3fd578372779c956a.zip
chromium_src-345f8e4b5d9e1531e461cce3fd578372779c956a.tar.gz
chromium_src-345f8e4b5d9e1531e461cce3fd578372779c956a.tar.bz2
Omnibox M5 work, part 1: Security changes
* Remove yellow background * Move lock icon from right side to left side (only on Win) * Change iconography * Change scheme colors * Add label for "Untrusted website" * Remove tooltip on label This also simplifies the LocationBarView code on Windows now that LocationBarImageView is unnecessary, and reorders a few things to try and be in more consistent/physical order. BUG=27570 TEST=Visit various https sites and see that the security icon is on the left, the scheme is colored, and there is no yellow background. Review URL: http://codereview.chromium.org/1056002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42502 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autocomplete')
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc64
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_gtk.h7
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_mac.mm45
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_win.cc50
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_win.h2
5 files changed, 71 insertions, 97 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc
index 61741e9f..1c7d4bd 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc
@@ -43,10 +43,11 @@
namespace {
const char kTextBaseColor[] = "#808080";
-const char kSecureSchemeColor[] = "#009614";
-const char kInsecureSchemeColor[] = "#c80000";
+const char kEVSecureSchemeColor[] = "#079500";
+const char kSecureSchemeColor[] = "#000e95";
+const char kSecurityErrorSchemeColor[] = "#a20000";
-const double kStrikethroughStrokeRed = 210.0 / 256.0;
+const double kStrikethroughStrokeRed = 162.0 / 256.0;
const double kStrikethroughStrokeWidth = 2.0;
size_t GetUTF8Offset(const std::wstring& wide_text, size_t wide_text_offset) {
@@ -118,8 +119,9 @@ AutocompleteEditViewGtk::AutocompleteEditViewGtk(
tag_table_(NULL),
text_buffer_(NULL),
faded_text_tag_(NULL),
+ ev_secure_scheme_tag_(NULL),
secure_scheme_tag_(NULL),
- insecure_scheme_tag_(NULL),
+ security_error_scheme_tag_(NULL),
model_(new AutocompleteEditModel(this, controller, profile)),
popup_view_(AutocompletePopupView::CreatePopupView(gfx::Font(), this,
model_.get(),
@@ -129,7 +131,7 @@ AutocompleteEditViewGtk::AutocompleteEditViewGtk(
toolbar_model_(toolbar_model),
command_updater_(command_updater),
popup_window_mode_(popup_window_mode),
- scheme_security_level_(ToolbarModel::NORMAL),
+ security_level_(ToolbarModel::NONE),
mark_set_handler_id_(0),
#if defined(OS_CHROMEOS)
button_1_pressed_(false),
@@ -210,10 +212,12 @@ void AutocompleteEditViewGtk::Init() {
faded_text_tag_ = gtk_text_buffer_create_tag(text_buffer_,
NULL, "foreground", kTextBaseColor, NULL);
+ ev_secure_scheme_tag_ = gtk_text_buffer_create_tag(text_buffer_,
+ NULL, "foreground", kEVSecureSchemeColor, NULL);
secure_scheme_tag_ = gtk_text_buffer_create_tag(text_buffer_,
NULL, "foreground", kSecureSchemeColor, NULL);
- insecure_scheme_tag_ = gtk_text_buffer_create_tag(text_buffer_,
- NULL, "foreground", kInsecureSchemeColor, NULL);
+ security_error_scheme_tag_ = gtk_text_buffer_create_tag(text_buffer_,
+ NULL, "foreground", kSecurityErrorSchemeColor, NULL);
normal_text_tag_ = gtk_text_buffer_create_tag(text_buffer_,
NULL, "foreground", "#000000", NULL);
@@ -281,7 +285,7 @@ void AutocompleteEditViewGtk::Init() {
SetBaseColor();
#endif
- ViewIDUtil::SetID(widget(), VIEW_ID_AUTOCOMPLETE);
+ ViewIDUtil::SetID(GetNativeView(), VIEW_ID_AUTOCOMPLETE);
}
void AutocompleteEditViewGtk::SetFocus() {
@@ -331,15 +335,9 @@ void AutocompleteEditViewGtk::Update(const TabContents* contents) {
model_->UpdatePermanentText(toolbar_model_->GetText());
ToolbarModel::SecurityLevel security_level =
- toolbar_model_->GetSchemeSecurityLevel();
- bool changed_security_level = (security_level != scheme_security_level_);
- scheme_security_level_ = security_level;
-
- // TODO(deanm): This doesn't exactly match Windows. There there is a member
- // background_color_. I think we can get away with just the level though.
- if (changed_security_level) {
- SetBaseColor();
- }
+ toolbar_model_->GetSecurityLevel();
+ bool changed_security_level = (security_level != security_level_);
+ security_level_ = security_level;
if (contents) {
selected_text_.clear();
@@ -579,10 +577,7 @@ void AutocompleteEditViewGtk::SetBaseColor() {
bool use_gtk = theme_provider_->UseGtkTheme();
#endif
- // If we're on a secure connection, ignore what the theme wants us to do
- // and use a yellow background.
- bool is_secure = (scheme_security_level_ == ToolbarModel::SECURE);
- if (use_gtk && !is_secure) {
+ if (use_gtk) {
gtk_widget_modify_base(text_view_, GTK_STATE_NORMAL, NULL);
// Grab the text colors out of the style and set our tags to use them.
@@ -593,20 +588,20 @@ void AutocompleteEditViewGtk::SetBaseColor() {
GdkColor average_color = gtk_util::AverageColors(
style->text[GTK_STATE_NORMAL], style->base[GTK_STATE_NORMAL]);
- g_object_set(faded_text_tag_, "foreground-gdk",
- &average_color, NULL);
+ g_object_set(faded_text_tag_, "foreground-gdk", &average_color, NULL);
g_object_set(normal_text_tag_, "foreground-gdk",
&style->text[GTK_STATE_NORMAL], NULL);
} else {
+ const GdkColor* background_color_ptr;
#if defined(TOOLKIT_VIEWS)
const GdkColor background_color = gfx::SkColorToGdkColor(
- LocationBarView::GetColor(is_secure, LocationBarView::BACKGROUND));
- gtk_widget_modify_base(text_view_, GTK_STATE_NORMAL,
- &background_color);
+ LocationBarView::GetColor(ToolbarModel::NONE,
+ LocationBarView::BACKGROUND));
+ background_color_ptr = &background_color;
#else
- gtk_widget_modify_base(text_view_, GTK_STATE_NORMAL,
- &LocationBarViewGtk::kBackgroundColorByLevel[scheme_security_level_]);
+ background_color_ptr = &LocationBarViewGtk::kBackgroundColor;
#endif
+ gtk_widget_modify_base(text_view_, GTK_STATE_NORMAL, background_color_ptr);
g_object_set(faded_text_tag_, "foreground", kTextBaseColor, NULL);
g_object_set(normal_text_tag_, "foreground", "#000000", NULL);
@@ -1342,22 +1337,23 @@ void AutocompleteEditViewGtk::EmphasizeURLComponents() {
strikethrough_ = CharRange();
// Emphasize the scheme for security UI display purposes (if necessary).
if (!model_->user_input_in_progress() && scheme.is_nonempty() &&
- (scheme_security_level_ != ToolbarModel::NORMAL)) {
+ (security_level_ != ToolbarModel::NONE)) {
CharRange scheme_range = CharRange(GetUTF8Offset(text, scheme.begin),
GetUTF8Offset(text, scheme.end()));
ItersFromCharRange(scheme_range, &start, &end);
- if (scheme_security_level_ == ToolbarModel::SECURE) {
- gtk_text_buffer_apply_tag(text_buffer_, secure_scheme_tag_,
- &start, &end);
- } else {
+ if (security_level_ == ToolbarModel::SECURITY_ERROR) {
strikethrough_ = scheme_range;
// When we draw the strikethrough, we don't want to include the ':' at the
// end of the scheme.
strikethrough_.cp_max--;
- gtk_text_buffer_apply_tag(text_buffer_, insecure_scheme_tag_,
+ gtk_text_buffer_apply_tag(text_buffer_, security_error_scheme_tag_,
&start, &end);
+ } else {
+ gtk_text_buffer_apply_tag(text_buffer_,
+ (security_level_ == ToolbarModel::EV_SECURE) ?
+ ev_secure_scheme_tag_ : secure_scheme_tag_, &start, &end);
}
}
}
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.h b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.h
index c1d7d11..3632e0b 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.h
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.h
@@ -58,8 +58,6 @@ class AutocompleteEditViewGtk : public AutocompleteEditView,
// Initialize, create the underlying widgets, etc.
void Init();
- GtkWidget* widget() { return alignment_.get(); }
-
// Returns the width, in pixels, needed to display the current text. The
// returned value includes margins and borders.
int TextWidth();
@@ -379,8 +377,9 @@ class AutocompleteEditViewGtk : public AutocompleteEditView,
GtkTextTagTable* tag_table_;
GtkTextBuffer* text_buffer_;
GtkTextTag* faded_text_tag_;
+ GtkTextTag* ev_secure_scheme_tag_;
GtkTextTag* secure_scheme_tag_;
- GtkTextTag* insecure_scheme_tag_;
+ GtkTextTag* security_error_scheme_tag_;
GtkTextTag* normal_text_tag_;
scoped_ptr<AutocompleteEditModel> model_;
@@ -396,7 +395,7 @@ class AutocompleteEditViewGtk : public AutocompleteEditView,
// different presentation (smaller font size). This is used for popups.
bool popup_window_mode_;
- ToolbarModel::SecurityLevel scheme_security_level_;
+ ToolbarModel::SecurityLevel security_level_;
// Selection at the point where the user started using the
// arrows to move around in the popup.
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm b/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm
index 1ebc1f7..55b6f3f 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm
@@ -61,15 +61,6 @@ const NSColor* ColorWithRGBBytes(int rr, int gg, int bb) {
blue:static_cast<float>(bb)/255.0
alpha:1.0];
}
-const NSColor* SecureBackgroundColor() {
- return ColorWithRGBBytes(255, 245, 195); // Yellow
-}
-const NSColor* NormalBackgroundColor() {
- return [NSColor controlBackgroundColor];
-}
-const NSColor* InsecureBackgroundColor() {
- return [NSColor controlBackgroundColor];
-}
const NSColor* HostTextColor() {
return [NSColor blackColor];
@@ -77,11 +68,14 @@ const NSColor* HostTextColor() {
const NSColor* BaseTextColor() {
return [NSColor darkGrayColor];
}
+const NSColor* EVSecureSchemeColor() {
+ return ColorWithRGBBytes(0x07, 0x95, 0x00);
+}
const NSColor* SecureSchemeColor() {
- return ColorWithRGBBytes(0x00, 0x96, 0x14);
+ return ColorWithRGBBytes(0x00, 0x0e, 0x95);
}
-const NSColor* InsecureSchemeColor() {
- return ColorWithRGBBytes(0xc8, 0x00, 0x00);
+const NSColor* SecurityErrorSchemeColor() {
+ return ColorWithRGBBytes(0xa2, 0x00, 0x00);
}
// Store's the model and view state across tab switches.
@@ -410,32 +404,23 @@ void AutocompleteEditViewMac::SetText(const std::wstring& display_text) {
// TODO(shess): GTK has this as a member var, figure out why.
// [Could it be to not change if no change? If so, I'm guessing
// AppKit may already handle that.]
- const ToolbarModel::SecurityLevel scheme_security_level =
- toolbar_model_->GetSchemeSecurityLevel();
-
- if (scheme_security_level == ToolbarModel::SECURE) {
- [field_ setBackgroundColor:SecureBackgroundColor()];
- } else if (scheme_security_level == ToolbarModel::NORMAL) {
- [field_ setBackgroundColor:NormalBackgroundColor()];
- } else if (scheme_security_level == ToolbarModel::INSECURE) {
- [field_ setBackgroundColor:InsecureBackgroundColor()];
- } else {
- NOTREACHED() << "Unexpected scheme_security_level: "
- << scheme_security_level;
- }
+ const ToolbarModel::SecurityLevel security_level =
+ toolbar_model_->GetSecurityLevel();
// Emphasize the scheme for security UI display purposes (if necessary).
if (!model_->user_input_in_progress() && scheme.is_nonempty() &&
- (scheme_security_level != ToolbarModel::NORMAL)) {
+ (security_level != ToolbarModel::NONE)) {
NSColor* color;
- if (scheme_security_level == ToolbarModel::SECURE) {
- color = SecureSchemeColor();
- } else {
- color = InsecureSchemeColor();
+ if (security_level == ToolbarModel::EV_SECURE) {
+ color = EVSecureSchemeColor();
+ } else if (security_level == ToolbarModel::SECURITY_ERROR) {
+ color = SecurityErrorSchemeColor();
// Add a strikethrough through the scheme.
[as addAttribute:NSStrikethroughStyleAttributeName
value:[NSNumber numberWithInt:NSUnderlineStyleSingle]
range:ComponentToNSRange(scheme)];
+ } else {
+ color = SecureSchemeColor();
}
[as addAttribute:NSForegroundColorAttributeName value:color
range:ComponentToNSRange(scheme)];
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_win.cc b/chrome/browser/autocomplete/autocomplete_edit_view_win.cc
index 6ead1fe..3bed00a 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_win.cc
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_win.cc
@@ -407,8 +407,9 @@ AutocompleteEditViewWin::AutocompleteEditViewWin(
in_drag_(false),
initiated_drag_(false),
drop_highlight_position_(-1),
- background_color_(0),
- scheme_security_level_(ToolbarModel::NORMAL),
+ background_color_(skia::SkColorToCOLORREF(LocationBarView::GetColor(
+ ToolbarModel::NONE, LocationBarView::BACKGROUND))),
+ security_level_(ToolbarModel::NONE),
text_object_model_(NULL) {
// Dummy call to a function exported by riched20.dll to ensure it sets up an
// import dependency on the dll.
@@ -459,6 +460,8 @@ AutocompleteEditViewWin::AutocompleteEditViewWin(
cf.yOffset = -font_y_adjustment_ * kTwipsPerPixel;
SetDefaultCharFormat(cf);
+ SetBackgroundColor(background_color_);
+
// By default RichEdit has a drop target. Revoke it so that we can install our
// own. Revoke takes care of deleting the existing one.
RevokeDragDrop(m_hWnd);
@@ -508,30 +511,21 @@ void AutocompleteEditViewWin::Update(
model_->UpdatePermanentText(toolbar_model_->GetText());
const ToolbarModel::SecurityLevel security_level =
- toolbar_model_->GetSchemeSecurityLevel();
- const COLORREF background_color =
- skia::SkColorToCOLORREF(LocationBarView::GetColor(
- security_level == ToolbarModel::SECURE, LocationBarView::BACKGROUND));
- const bool changed_security_level =
- (security_level != scheme_security_level_);
+ toolbar_model_->GetSecurityLevel();
+ const bool changed_security_level = (security_level != security_level_);
// Bail early when no visible state will actually change (prevents an
// unnecessary ScopedFreeze, and thus UpdateWindow()).
- if ((background_color == background_color_) && !changed_security_level &&
- !visibly_changed_permanent_text && !tab_for_state_restoring)
+ if (!changed_security_level && !visibly_changed_permanent_text &&
+ !tab_for_state_restoring)
return;
- // Update our local state as desired. We set scheme_security_level_ here so
- // it will already be correct before we get to any RevertAll()s below and use
- // it.
- ScopedFreeze freeze(this, GetTextObjectModel());
- if (background_color_ != background_color) {
- background_color_ = background_color;
- SetBackgroundColor(background_color_);
- }
- scheme_security_level_ = security_level;
+ // Update our local state as desired. We set security_level_ here so it will
+ // already be correct before we get to any RevertAll()s below and use it.
+ security_level_ = security_level;
// When we're switching to a new tab, restore its state, if any.
+ ScopedFreeze freeze(this, GetTextObjectModel());
if (tab_for_state_restoring) {
// Make sure we reset our own state first. The new tab may not have any
// saved state, or it may not have had input in progress, in which case we
@@ -2060,11 +2054,11 @@ void AutocompleteEditViewWin::EmphasizeURLComponents() {
// Set the baseline emphasis.
CHARFORMAT cf = {0};
cf.dwMask = CFM_COLOR;
- const bool is_secure = (scheme_security_level_ == ToolbarModel::SECURE);
// If we're going to emphasize parts of the text, then the baseline state
// should be "de-emphasized". If not, then everything should be rendered in
// the standard text color.
- cf.crTextColor = skia::SkColorToCOLORREF(LocationBarView::GetColor(is_secure,
+ cf.crTextColor = skia::SkColorToCOLORREF(LocationBarView::GetColor(
+ security_level_,
emphasize ? LocationBarView::DEEMPHASIZED_TEXT : LocationBarView::TEXT));
// NOTE: Don't use SetDefaultCharFormat() instead of the below; that sets the
// format that will get applied to text added in the future, not to text
@@ -2075,7 +2069,7 @@ void AutocompleteEditViewWin::EmphasizeURLComponents() {
if (emphasize) {
// We've found a host name, give it more emphasis.
cf.crTextColor = skia::SkColorToCOLORREF(LocationBarView::GetColor(
- is_secure, LocationBarView::TEXT));
+ security_level_, LocationBarView::TEXT));
SetSelection(host.begin, host.end());
SetSelectionCharFormat(cf);
}
@@ -2083,13 +2077,13 @@ void AutocompleteEditViewWin::EmphasizeURLComponents() {
// Emphasize the scheme for security UI display purposes (if necessary).
insecure_scheme_component_.reset();
if (!model_->user_input_in_progress() && scheme.is_nonempty() &&
- (scheme_security_level_ != ToolbarModel::NORMAL)) {
- if (!is_secure) {
+ (security_level_ != ToolbarModel::NONE)) {
+ if (security_level_ == ToolbarModel::SECURITY_ERROR) {
insecure_scheme_component_.begin = scheme.begin;
insecure_scheme_component_.len = scheme.len;
}
cf.crTextColor = skia::SkColorToCOLORREF(LocationBarView::GetColor(
- is_secure, LocationBarView::SECURITY_TEXT));
+ security_level_, LocationBarView::SECURITY_TEXT));
SetSelection(scheme.begin, scheme.end());
SetSelectionCharFormat(cf);
}
@@ -2183,8 +2177,8 @@ void AutocompleteEditViewWin::DrawSlashForInsecureScheme(
canvas.save();
if (selection_rect.isEmpty() ||
canvas.clipRect(selection_rect, SkRegion::kDifference_Op)) {
- paint.setColor(LocationBarView::GetColor(false,
- LocationBarView::SCHEME_STRIKEOUT));
+ paint.setColor(LocationBarView::GetColor(security_level_,
+ LocationBarView::SECURITY_TEXT));
canvas.drawLine(start_point.fX, start_point.fY,
end_point.fX, end_point.fY, paint);
}
@@ -2192,7 +2186,7 @@ void AutocompleteEditViewWin::DrawSlashForInsecureScheme(
// Draw the selected portion of the stroke.
if (!selection_rect.isEmpty() && canvas.clipRect(selection_rect)) {
- paint.setColor(LocationBarView::GetColor(false,
+ paint.setColor(LocationBarView::GetColor(security_level_,
LocationBarView::SELECTED_TEXT));
canvas.drawLine(start_point.fX, start_point.fY,
end_point.fX, end_point.fY, paint);
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_win.h b/chrome/browser/autocomplete/autocomplete_edit_view_win.h
index 9de2d34..42e1a35 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_win.h
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_win.h
@@ -476,7 +476,7 @@ class AutocompleteEditViewWin
// Security UI-related data.
COLORREF background_color_;
- ToolbarModel::SecurityLevel scheme_security_level_;
+ ToolbarModel::SecurityLevel security_level_;
// This interface is useful for accessing the CRichEditCtrl at a low level.
mutable ITextDocument* text_object_model_;