summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/app/generated_resources.grd6
-rw-r--r--chrome/app/theme/theme_resources.grd5
-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
-rw-r--r--chrome/browser/cert_store.cc5
-rw-r--r--chrome/browser/cert_store.h8
-rw-r--r--chrome/browser/cocoa/autocomplete_text_field_cell_unittest.mm13
-rw-r--r--chrome/browser/cocoa/autocomplete_text_field_unittest.mm7
-rw-r--r--chrome/browser/cocoa/location_bar_view_mac.h21
-rw-r--r--chrome/browser/cocoa/location_bar_view_mac.mm109
-rw-r--r--chrome/browser/gtk/browser_toolbar_gtk.cc12
-rw-r--r--chrome/browser/gtk/location_bar_view_gtk.cc121
-rw-r--r--chrome/browser/gtk/location_bar_view_gtk.h16
-rw-r--r--chrome/browser/ssl/ssl_manager.cc27
-rw-r--r--chrome/browser/ssl/ssl_manager.h10
-rw-r--r--chrome/browser/toolbar_model.cc204
-rw-r--r--chrome/browser/toolbar_model.h44
-rw-r--r--chrome/browser/views/app_launcher.cc4
-rw-r--r--chrome/browser/views/location_bar_view.cc587
-rw-r--r--chrome/browser/views/location_bar_view.h155
23 files changed, 563 insertions, 959 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index a94816f..ed029e4 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -4754,12 +4754,12 @@ Keep your key file in a safe place. You will need it to create new versions of y
Secure connection to <ph name="DOMAIN">$1<ex>paypal.com</ex></ph>
</message>
- <message name="IDS_SECURE_CONNECTION_EV" desc="Short text shown in the location when the connection is secure with an EV cert.">
+ <message name="IDS_SECURE_CONNECTION_EV" desc="Short text shown in the location bar when the connection is secure with an EV cert.">
<ph name="ORGANIZATION">$1<ex>Paypal Inc.</ex></ph> [<ph name="COUNTRY">$2<ex>US</ex></ph>]
</message>
- <message name="IDS_SECURE_CONNECTION_EV_CA" desc="Info popup text showing the certification authority's name when hovering the mouse over the EV label ie., we have a secure connection to the site with an EV cert.">
- Verified by <ph name="ISSUER">$1<ex>VeriSign</ex></ph>
+ <message name="IDS_SECURITY_BROKEN" desc="Short text shown in the location bar when a secure connection cannot be established.">
+ Untrusted website
</message>
<!-- Page Information Window -->
diff --git a/chrome/app/theme/theme_resources.grd b/chrome/app/theme/theme_resources.grd
index 9f2482d..a7520a8 100644
--- a/chrome/app/theme/theme_resources.grd
+++ b/chrome/app/theme/theme_resources.grd
@@ -123,7 +123,10 @@
<include name="IDR_BLOCKED_JAVASCRIPT" file="blocked_javascript.png" type="BINDATA" />
<include name="IDR_BLOCKED_PLUGINS" file="blocked_plugins.png" type="BINDATA" />
<include name="IDR_BLOCKED_POPUPS" file="blocked_popups.png" type="BINDATA" />
- <include name="IDR_LOCK" file="lock_small.png" type="BINDATA" />
+ <include name="IDR_EV_SECURE" file="ev_secure.png" type="BINDATA" />
+ <include name="IDR_SECURE" file="secure.png" type="BINDATA" />
+ <include name="IDR_SECURITY_WARNING" file="security_warning.png" type="BINDATA" />
+ <include name="IDR_SECURITY_ERROR" file="security_error.png" type="BINDATA" />
<include name="IDR_WARNING" file="alert_small.png" type="BINDATA" />
<include name="IDR_STOP" file="stop.png" type="BINDATA" />
<include name="IDR_STOP_NOBORDER" file="stop_noborder.png" type="BINDATA" />
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_;
diff --git a/chrome/browser/cert_store.cc b/chrome/browser/cert_store.cc
index 4d804ca..89c5ffe 100644
--- a/chrome/browser/cert_store.cc
+++ b/chrome/browser/cert_store.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 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.
@@ -88,7 +88,8 @@ bool CertStore::RetrieveCert(int cert_id,
CertMap::iterator iter = id_to_cert_.find(cert_id);
if (iter == id_to_cert_.end())
return false;
- *cert = iter->second;
+ if (cert)
+ *cert = iter->second;
return true;
}
diff --git a/chrome/browser/cert_store.h b/chrome/browser/cert_store.h
index 995a3db..0b19540 100644
--- a/chrome/browser/cert_store.h
+++ b/chrome/browser/cert_store.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 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.
@@ -34,9 +34,9 @@ class CertStore : public NotificationObserver {
// Note: ids starts at 1.
int StoreCert(net::X509Certificate* cert, int render_process_host_id);
- // Retrieves the previously stored cert associated with the specified
- // |cert_id| and set it in |cert|. Returns false if no cert was found for
- // that id.
+ // Tries to retrieve the previously stored cert associated with the specified
+ // |cert_id|. Returns whether the cert could be found, and, if |cert| is
+ // non-NULL, copies it in.
bool RetrieveCert(int cert_id, scoped_refptr<net::X509Certificate>* cert);
// NotificationObserver implementation.
diff --git a/chrome/browser/cocoa/autocomplete_text_field_cell_unittest.mm b/chrome/browser/cocoa/autocomplete_text_field_cell_unittest.mm
index 9023d4b..9b3e6b6 100644
--- a/chrome/browser/cocoa/autocomplete_text_field_cell_unittest.mm
+++ b/chrome/browser/cocoa/autocomplete_text_field_cell_unittest.mm
@@ -7,6 +7,7 @@
#include "base/scoped_nsobject.h"
#import "chrome/browser/cocoa/autocomplete_text_field_cell.h"
#import "chrome/browser/cocoa/cocoa_test_helper.h"
+#include "grit/theme_resources.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
@@ -200,8 +201,7 @@ TEST_F(AutocompleteTextFieldCellTest, TextFrame) {
EXPECT_TRUE(NSContainsRect(cursorFrame, textFrame));
// Security icon takes up space on the right
- security_image_view_.SetImageShown(
- LocationBarViewMac::SecurityImageView::LOCK);
+ security_image_view_.SetImageShown(IDR_SECURE);
security_image_view_.SetVisible(true);
textFrame = [cell textFrameForFrame:bounds];
@@ -265,8 +265,7 @@ TEST_F(AutocompleteTextFieldCellTest, DrawingRectForBounds) {
EXPECT_TRUE(NSContainsRect(NSInsetRect(textFrame, 1, 1), drawingRect));
EXPECT_TRUE(NSEqualRects(drawingRect, originalDrawingRect));
- security_image_view_.SetImageShown(
- LocationBarViewMac::SecurityImageView::LOCK);
+ security_image_view_.SetImageShown(IDR_SECURE);
security_image_view_.SetVisible(true);
textFrame = [cell textFrameForFrame:bounds];
@@ -280,8 +279,7 @@ TEST_F(AutocompleteTextFieldCellTest, SecurityImageFrame) {
AutocompleteTextFieldCell* cell =
static_cast<AutocompleteTextFieldCell*>([view_ cell]);
const NSRect bounds([view_ bounds]);
- security_image_view_.SetImageShown(
- LocationBarViewMac::SecurityImageView::LOCK);
+ security_image_view_.SetImageShown(IDR_SECURE);
security_image_view_.SetVisible(false);
EXPECT_EQ(0u, [[cell layedOutIcons:bounds] count]);
@@ -349,8 +347,7 @@ TEST_F(AutocompleteTextFieldCellTest, PageActionImageFrame) {
AutocompleteTextFieldCell* cell =
static_cast<AutocompleteTextFieldCell*>([view_ cell]);
const NSRect bounds([view_ bounds]);
- security_image_view_.SetImageShown(
- LocationBarViewMac::SecurityImageView::LOCK);
+ security_image_view_.SetImageShown(IDR_SECURE);
TestPageActionImageView page_action_view;
// We'll assume that the extensions code enforces icons smaller than the
diff --git a/chrome/browser/cocoa/autocomplete_text_field_unittest.mm b/chrome/browser/cocoa/autocomplete_text_field_unittest.mm
index b2f1f2d..fccae5c 100644
--- a/chrome/browser/cocoa/autocomplete_text_field_unittest.mm
+++ b/chrome/browser/cocoa/autocomplete_text_field_unittest.mm
@@ -11,6 +11,7 @@
#import "chrome/browser/cocoa/autocomplete_text_field_editor.h"
#import "chrome/browser/cocoa/autocomplete_text_field_unittest_helper.h"
#import "chrome/browser/cocoa/cocoa_test_helper.h"
+#include "grit/theme_resources.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
@@ -581,8 +582,7 @@ TEST_F(AutocompleteTextFieldObserverTest, SecurityIconMouseDown) {
MockSecurityImageView security_image_view(NULL, NULL, NULL);
[cell setSecurityImageView:&security_image_view];
- security_image_view.SetImageShown(
- LocationBarViewMac::SecurityImageView::LOCK);
+ security_image_view.SetImageShown(IDR_SECURE);
security_image_view.SetVisible(true);
NSRect iconFrame([cell securityImageFrameForFrame:[field_ bounds]]);
@@ -598,8 +598,7 @@ TEST_F(AutocompleteTextFieldObserverTest, PageActionMouseDown) {
AutocompleteTextFieldCell* cell = [field_ autocompleteTextFieldCell];
MockSecurityImageView security_image_view(NULL, NULL, NULL);
- security_image_view.SetImageShown(
- LocationBarViewMac::SecurityImageView::LOCK);
+ security_image_view.SetImageShown(IDR_SECURE);
[cell setSecurityImageView:&security_image_view];
MockPageActionImageView page_action_view;
diff --git a/chrome/browser/cocoa/location_bar_view_mac.h b/chrome/browser/cocoa/location_bar_view_mac.h
index 687fb7d..b7f5187 100644
--- a/chrome/browser/cocoa/location_bar_view_mac.h
+++ b/chrome/browser/cocoa/location_bar_view_mac.h
@@ -177,30 +177,23 @@ class LocationBarViewMac : public AutocompleteEditController,
// current URL's scheme is https.
class SecurityImageView : public LocationBarImageView {
public:
- enum Image {
- LOCK = 0,
- WARNING
- };
-
SecurityImageView(LocationBarViewMac* owner,
Profile* profile,
ToolbarModel* model);
virtual ~SecurityImageView();
// Sets the image to the appropriate icon.
- void SetImageShown(Image image);
+ void SetImageShown(int resource_id);
// Shows the page info dialog.
virtual void OnMousePressed(NSRect bounds);
private:
- // The lock icon shown when using HTTPS. Loaded lazily, the first time it's
- // needed.
- scoped_nsobject<NSImage> lock_icon_;
-
- // The warning icon shown when HTTPS is broken. Loaded lazily, the first
- // time it's needed.
- scoped_nsobject<NSImage> warning_icon_;
+ // Icons for various states. Lazily loaded the first time they're needed.
+ scoped_nsobject<NSImage> ev_secure_icon_;
+ scoped_nsobject<NSImage> secure_icon_;
+ scoped_nsobject<NSImage> security_warning_icon_;
+ scoped_nsobject<NSImage> security_error_icon_;
// The location bar view that owns us.
LocationBarViewMac* owner_;
@@ -382,7 +375,7 @@ class LocationBarViewMac : public AutocompleteEditController,
private:
// Sets the SSL icon we should be showing.
- void SetSecurityIcon(ToolbarModel::Icon icon);
+ void SetSecurityIcon(int resource_id);
// Sets the label for the SSL icon.
void SetSecurityIconLabel();
diff --git a/chrome/browser/cocoa/location_bar_view_mac.mm b/chrome/browser/cocoa/location_bar_view_mac.mm
index b2416f3..ee795b8 100644
--- a/chrome/browser/cocoa/location_bar_view_mac.mm
+++ b/chrome/browser/cocoa/location_bar_view_mac.mm
@@ -62,11 +62,13 @@ std::wstring GetKeywordName(Profile* profile, const std::wstring& keyword) {
return std::wstring();
}
-// Values for the green text color displayed for EV certificates, based
-// on the values for kEvTextColor in location_bar_view_gtk.cc.
-static const CGFloat kEvTextColorRedComponent = 0.0;
-static const CGFloat kEvTextColorGreenComponent = 0.59;
-static const CGFloat kEvTextColorBlueComponent = 0.08;
+// Values for the label colors for different security states.
+static const CGFloat kEVSecureTextColorRedComponent = 0.03;
+static const CGFloat kEVSecureTextColorGreenComponent = 0.58;
+static const CGFloat kEVSecureTextColorBlueComponent = 0.0;
+static const CGFloat kSecurityErrorTextColorRedComponent = 0.63;
+static const CGFloat kSecurityErrorTextColorGreenComponent = 0.0;
+static const CGFloat kSecurityErrorTextColorBlueComponent = 0.0;
// Build a short string to use in keyword-search when the field isn't
// very big.
@@ -205,7 +207,7 @@ void LocationBarViewMac::SaveStateToContents(TabContents* contents) {
void LocationBarViewMac::Update(const TabContents* contents,
bool should_restore_state) {
- SetSecurityIcon(toolbar_model_->GetIcon());
+ SetSecurityIcon(toolbar_model_->GetSecurityIcon());
page_action_views_.RefreshViews();
RefreshContentSettingsViews();
// AutocompleteEditView restores state if the tab is non-NULL.
@@ -455,41 +457,36 @@ NSImage* LocationBarViewMac::GetTabButtonImage() {
}
void LocationBarViewMac::SetSecurityIconLabel() {
- std::wstring info_text;
- std::wstring info_tooltip;
- ToolbarModel::InfoTextType info_text_type =
- toolbar_model_->GetInfoText(&info_text, &info_tooltip);
- if (info_text_type == ToolbarModel::INFO_EV_TEXT) {
- NSString* icon_label = base::SysWideToNSString(info_text);
- NSColor* color = [NSColor colorWithCalibratedRed:kEvTextColorRedComponent
- green:kEvTextColorGreenComponent
- blue:kEvTextColorBlueComponent
- alpha:1.0];
- security_image_view_.SetLabel(icon_label, [field_ font], color);
- } else {
+ // TODO(shess): Separate from security icon and move icon to left of address.
+ std::wstring security_info_text(toolbar_model_->GetSecurityInfoText());
+ if (security_info_text.empty()) {
security_image_view_.SetLabel(nil, nil, nil);
+ } else {
+ NSString* icon_label = base::SysWideToNSString(security_info_text);
+ NSColor* color;
+ if (toolbar_model_->GetSecurityLevel() == ToolbarModel::EV_SECURE) {
+ color = [NSColor colorWithCalibratedRed:kEVSecureTextColorRedComponent
+ green:kEVSecureTextColorGreenComponent
+ blue:kEVSecureTextColorBlueComponent
+ alpha:1.0];
+ } else {
+ color =
+ [NSColor colorWithCalibratedRed:kSecurityErrorTextColorRedComponent
+ green:kSecurityErrorTextColorGreenComponent
+ blue:kSecurityErrorTextColorBlueComponent
+ alpha:1.0];
+ }
+ security_image_view_.SetLabel(icon_label, [field_ font], color);
}
}
-void LocationBarViewMac::SetSecurityIcon(ToolbarModel::Icon icon) {
- switch (icon) {
- case ToolbarModel::LOCK_ICON:
- security_image_view_.SetImageShown(SecurityImageView::LOCK);
- security_image_view_.SetVisible(true);
- SetSecurityIconLabel();
- break;
- case ToolbarModel::WARNING_ICON:
- security_image_view_.SetImageShown(SecurityImageView::WARNING);
- security_image_view_.SetVisible(true);
- SetSecurityIconLabel();
- break;
- case ToolbarModel::NO_ICON:
- security_image_view_.SetVisible(false);
- break;
- default:
- NOTREACHED();
- security_image_view_.SetVisible(false);
- break;
+void LocationBarViewMac::SetSecurityIcon(int resource_id) {
+ if (resource_id == 0) {
+ security_image_view_.SetVisible(false);
+ } else {
+ security_image_view_.SetImageShown(resource_id);
+ security_image_view_.SetVisible(true);
+ SetSecurityIconLabel();
}
[field_ resetFieldEditorFrameIfNeeded];
}
@@ -569,34 +566,30 @@ LocationBarViewMac::SecurityImageView::SecurityImageView(
LocationBarViewMac* owner,
Profile* profile,
ToolbarModel* model)
- : lock_icon_(nil),
- warning_icon_(nil),
+ : ev_secure_icon_(nil),
+ secure_icon_(nil),
+ security_warning_icon_(nil),
+ security_error_icon_(nil),
owner_(owner),
profile_(profile),
model_(model) {}
LocationBarViewMac::SecurityImageView::~SecurityImageView() {}
-void LocationBarViewMac::SecurityImageView::SetImageShown(Image image) {
- switch (image) {
- case LOCK:
- if (!lock_icon_.get()) {
- ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- lock_icon_.reset([rb.GetNSImageNamed(IDR_LOCK) retain]);
- }
- SetImage(lock_icon_);
- break;
- case WARNING:
- if (!warning_icon_.get()) {
- ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- warning_icon_.reset([rb.GetNSImageNamed(IDR_WARNING) retain]);
- }
- SetImage(warning_icon_);
- break;
- default:
- NOTREACHED();
- break;
+void LocationBarViewMac::SecurityImageView::SetImageShown(int resource_id) {
+ scoped_nsobject<NSImage>* icon;
+ switch (resource_id) {
+ case IDR_EV_SECURE: icon = &ev_secure_icon_; break;
+ case IDR_SECURE: icon = &secure_icon_; break;
+ case IDR_SECURITY_WARNING: icon = &security_warning_icon_; break;
+ case IDR_SECURITY_ERROR: icon = &security_error_icon_; break;
+ default: NOTREACHED(); return;
+ }
+ if (!icon->get()) {
+ ResourceBundle& rb = ResourceBundle::GetSharedInstance();
+ icon->reset([rb.GetNSImageNamed(resource_id) retain]);
}
+ SetImage(*icon);
}
void LocationBarViewMac::SecurityImageView::OnMousePressed(NSRect bounds) {
diff --git a/chrome/browser/gtk/browser_toolbar_gtk.cc b/chrome/browser/gtk/browser_toolbar_gtk.cc
index b7b96d2..6bdb18e 100644
--- a/chrome/browser/gtk/browser_toolbar_gtk.cc
+++ b/chrome/browser/gtk/browser_toolbar_gtk.cc
@@ -69,10 +69,6 @@ const int kToolbarHeightLocationBarOnly = kToolbarHeight - 2;
// Interior spacing between toolbar widgets.
const int kToolbarWidgetSpacing = 4;
-// The color used as the base[] color of the location entry during a secure
-// connection.
-const GdkColor kSecureColor = GDK_COLOR_RGB(255, 245, 195);
-
} // namespace
// BrowserToolbarGtk, public ---------------------------------------------------
@@ -596,14 +592,6 @@ gboolean BrowserToolbarGtk::OnLocationHboxExpose(GtkWidget* location_hbox,
(right->allocation.y - left->allocation.y) + right->allocation.height
};
- // Make sure our off screen entry has the correct base color if we're in
- // secure mode.
- gtk_widget_modify_base(
- offscreen_entry_.get(), GTK_STATE_NORMAL,
- (browser_->toolbar_model()->GetSchemeSecurityLevel() ==
- ToolbarModel::SECURE) ?
- &kSecureColor : NULL);
-
gtk_util::DrawTextEntryBackground(offscreen_entry_.get(),
location_hbox, &e->area,
&rec);
diff --git a/chrome/browser/gtk/location_bar_view_gtk.cc b/chrome/browser/gtk/location_bar_view_gtk.cc
index a764b3d..bab7259 100644
--- a/chrome/browser/gtk/location_bar_view_gtk.cc
+++ b/chrome/browser/gtk/location_bar_view_gtk.cc
@@ -76,7 +76,8 @@ static const int kInnerPadding = 4;
// TODO(deanm): Eventually this should be painted with the background png
// image, but for now we get pretty close by just drawing a solid border.
const GdkColor kBorderColor = GDK_COLOR_RGB(0xbe, 0xc8, 0xd4);
-const GdkColor kEvTextColor = GDK_COLOR_RGB(0x00, 0x96, 0x14); // Green.
+const GdkColor kEvSecureTextColor = GDK_COLOR_RGB(0x07, 0x95, 0x00);
+const GdkColor kSecurityErrorTextColor = GDK_COLOR_RGB(0xa2, 0x00, 0x00);
const GdkColor kKeywordBackgroundColor = GDK_COLOR_RGB(0xf0, 0xf4, 0xfa);
const GdkColor kKeywordBorderColor = GDK_COLOR_RGB(0xcb, 0xde, 0xf7);
@@ -131,19 +132,18 @@ std::wstring CalculateMinString(const std::wstring& description) {
// LocationBarViewGtk
// static
-const GdkColor LocationBarViewGtk::kBackgroundColorByLevel[3] = {
- GDK_COLOR_RGB(255, 245, 195), // SecurityLevel SECURE: Yellow.
- GDK_COLOR_RGB(255, 255, 255), // SecurityLevel NORMAL: White.
- GDK_COLOR_RGB(255, 255, 255), // SecurityLevel INSECURE: White.
-};
+const GdkColor LocationBarViewGtk::kBackgroundColor =
+ GDK_COLOR_RGB(255, 255, 255);
LocationBarViewGtk::LocationBarViewGtk(
const BubblePositioner* bubble_positioner,
Browser* browser)
: security_icon_event_box_(NULL),
- security_lock_icon_image_(NULL),
+ ev_secure_icon_image_(NULL),
+ secure_icon_image_(NULL),
security_warning_icon_image_(NULL),
- info_label_(NULL),
+ security_error_icon_image_(NULL),
+ security_info_label_(NULL),
tab_to_search_box_(NULL),
tab_to_search_full_label_(NULL),
tab_to_search_partial_label_(NULL),
@@ -194,21 +194,25 @@ void LocationBarViewGtk::Init(bool popup_window_mode) {
gtk_widget_set_redraw_on_allocate(hbox_.get(), TRUE);
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- security_lock_icon_image_ = gtk_image_new_from_pixbuf(
- rb.GetPixbufNamed(IDR_LOCK));
- gtk_widget_set_name(security_lock_icon_image_, "chrome-security-lock-icon");
- gtk_widget_hide(GTK_WIDGET(security_lock_icon_image_));
- security_warning_icon_image_ = gtk_image_new();
+ ev_secure_icon_image_ =
+ gtk_image_new_from_pixbuf(rb.GetPixbufNamed(IDR_EV_SECURE));
+ gtk_widget_set_name(ev_secure_icon_image_, "chrome-ev-secure-icon");
+ secure_icon_image_ = gtk_image_new_from_pixbuf(rb.GetPixbufNamed(IDR_SECURE));
+ gtk_widget_set_name(secure_icon_image_, "chrome-secure-icon");
+ security_warning_icon_image_ =
+ gtk_image_new_from_pixbuf(rb.GetPixbufNamed(IDR_SECURITY_WARNING));
gtk_widget_set_name(security_warning_icon_image_,
"chrome-security-warning-icon");
- gtk_widget_hide(GTK_WIDGET(security_warning_icon_image_));
+ security_error_icon_image_ =
+ gtk_image_new_from_pixbuf(rb.GetPixbufNamed(IDR_SECURITY_ERROR));
+ gtk_widget_set_name(security_error_icon_image_,
+ "chrome-security-error-icon");
- info_label_ = gtk_label_new(NULL);
- gtk_widget_modify_base(info_label_, GTK_STATE_NORMAL,
- &LocationBarViewGtk::kBackgroundColorByLevel[0]);
- gtk_widget_hide(GTK_WIDGET(info_label_));
- gtk_widget_set_name(info_label_,
- "chrome-location-bar-info-label");
+ security_info_label_ = gtk_label_new(NULL);
+ gtk_widget_modify_base(security_info_label_, GTK_STATE_NORMAL,
+ &LocationBarViewGtk::kBackgroundColor);
+ gtk_widget_set_name(security_info_label_,
+ "chrome-location-bar-security-info-label");
g_signal_connect(hbox_.get(), "expose-event",
G_CALLBACK(&HandleExposeThunk), this);
@@ -269,7 +273,7 @@ void LocationBarViewGtk::Init(bool popup_window_mode) {
kBottomMargin + kBorderThickness,
0, 0);
}
- gtk_container_add(GTK_CONTAINER(align), location_entry_->widget());
+ gtk_container_add(GTK_CONTAINER(align), location_entry_->GetNativeView());
gtk_box_pack_start(GTK_BOX(entry_box), align, TRUE, TRUE, 0);
// Tab to search notification (the hint on the right hand side).
@@ -303,15 +307,19 @@ void LocationBarViewGtk::Init(bool popup_window_mode) {
gtk_widget_set_sensitive(type_to_search_hint_, FALSE);
gtk_box_pack_end(GTK_BOX(entry_box), type_to_search_hint_, FALSE, FALSE, 0);
- // Pack info_label_ and security icons in hbox. We hide/show them
+ // Pack security_info_label_ and security icons in hbox. We hide/show them
// by SetSecurityIcon() and SetInfoText().
- gtk_box_pack_end(GTK_BOX(hbox_.get()), info_label_, FALSE, FALSE, 0);
+ gtk_box_pack_end(GTK_BOX(hbox_.get()), security_info_label_, FALSE, FALSE, 0);
GtkWidget* security_icon_box = gtk_hbox_new(FALSE, 0);
gtk_box_pack_start(GTK_BOX(security_icon_box),
- security_lock_icon_image_, FALSE, FALSE, 0);
+ ev_secure_icon_image_, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(security_icon_box),
+ secure_icon_image_, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(security_icon_box),
security_warning_icon_image_, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(security_icon_box),
+ security_error_icon_image_, FALSE, FALSE, 0);
// GtkImage is a "no window" widget and requires a GtkEventBox to receive
// events.
@@ -352,7 +360,7 @@ void LocationBarViewGtk::Init(bool popup_window_mode) {
// Until we switch to vector graphics, force the font size of labels.
gtk_util::ForceFontSizePixels(type_to_search_hint_,
browser_defaults::kAutocompleteEditFontPixelSize);
- gtk_util::ForceFontSizePixels(info_label_,
+ gtk_util::ForceFontSizePixels(security_info_label_,
browser_defaults::kAutocompleteEditFontPixelSize);
gtk_util::ForceFontSizePixels(tab_to_search_full_label_,
browser_defaults::kAutocompleteEditFontPixelSize);
@@ -410,7 +418,7 @@ GtkWidget* LocationBarViewGtk::GetPageActionWidget(
}
void LocationBarViewGtk::Update(const TabContents* contents) {
- SetSecurityIcon(toolbar_model_->GetIcon());
+ SetSecurityIcon(toolbar_model_->GetSecurityIcon());
UpdateContentSettingsIcons();
UpdatePageActions();
SetInfoText();
@@ -691,10 +699,6 @@ void LocationBarViewGtk::Observe(NotificationType type,
gtk_util::SetLabelColor(tab_to_search_hint_leading_label_, NULL);
gtk_util::SetLabelColor(tab_to_search_hint_trailing_label_, NULL);
gtk_util::SetLabelColor(type_to_search_hint_, NULL);
-
- gtk_image_set_from_stock(GTK_IMAGE(security_warning_icon_image_),
- GTK_STOCK_DIALOG_WARNING,
- GTK_ICON_SIZE_SMALL_TOOLBAR);
} else {
gtk_widget_modify_bg(tab_to_search_box_, GTK_STATE_NORMAL,
&kKeywordBackgroundColor);
@@ -708,10 +712,6 @@ void LocationBarViewGtk::Observe(NotificationType type,
gtk_util::SetLabelColor(tab_to_search_hint_trailing_label_,
&kHintTextColor);
gtk_util::SetLabelColor(type_to_search_hint_, &kHintTextColor);
-
- ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- gtk_image_set_from_pixbuf(GTK_IMAGE(security_warning_icon_image_),
- rb.GetPixbufNamed(IDR_WARNING));
}
}
@@ -745,8 +745,7 @@ gboolean LocationBarViewGtk::HandleExpose(GtkWidget* widget,
alloc_rect->width,
alloc_rect->height - kTopMargin -
kBottomMargin - 2 * kBorderThickness);
- gdk_cairo_set_source_color(cr, const_cast<GdkColor*>(
- &kBackgroundColorByLevel[toolbar_model_->GetSchemeSecurityLevel()]));
+ gdk_cairo_set_source_color(cr, const_cast<GdkColor*>(&kBackgroundColor));
cairo_fill(cr);
cairo_destroy(cr);
@@ -755,21 +754,28 @@ gboolean LocationBarViewGtk::HandleExpose(GtkWidget* widget,
return FALSE; // Continue propagating the expose.
}
-void LocationBarViewGtk::SetSecurityIcon(ToolbarModel::Icon icon) {
- gtk_widget_hide(GTK_WIDGET(security_lock_icon_image_));
+void LocationBarViewGtk::SetSecurityIcon(int resource_id) {
+ gtk_widget_hide(GTK_WIDGET(ev_secure_icon_image_));
+ gtk_widget_hide(GTK_WIDGET(secure_icon_image_));
gtk_widget_hide(GTK_WIDGET(security_warning_icon_image_));
- if (icon != ToolbarModel::NO_ICON)
- gtk_widget_show(GTK_WIDGET(security_icon_event_box_));
- else
+ gtk_widget_hide(GTK_WIDGET(security_error_icon_image_));
+ if (resource_id == 0) {
gtk_widget_hide(GTK_WIDGET(security_icon_event_box_));
- switch (icon) {
- case ToolbarModel::LOCK_ICON:
- gtk_widget_show(GTK_WIDGET(security_lock_icon_image_));
+ return;
+ }
+ gtk_widget_show(GTK_WIDGET(security_icon_event_box_));
+ switch (resource_id) {
+ case IDR_EV_SECURE:
+ gtk_widget_show(GTK_WIDGET(ev_secure_icon_image_));
+ break;
+ case IDR_SECURE:
+ gtk_widget_show(GTK_WIDGET(secure_icon_image_));
break;
- case ToolbarModel::WARNING_ICON:
+ case IDR_SECURITY_WARNING:
gtk_widget_show(GTK_WIDGET(security_warning_icon_image_));
break;
- case ToolbarModel::NO_ICON:
+ case IDR_SECURITY_ERROR:
+ gtk_widget_show(GTK_WIDGET(security_error_icon_image_));
break;
default:
NOTREACHED();
@@ -778,22 +784,17 @@ void LocationBarViewGtk::SetSecurityIcon(ToolbarModel::Icon icon) {
}
void LocationBarViewGtk::SetInfoText() {
- std::wstring info_text, info_tooltip;
- ToolbarModel::InfoTextType info_text_type =
- toolbar_model_->GetInfoText(&info_text, &info_tooltip);
- if (info_text_type == ToolbarModel::INFO_EV_TEXT) {
- gtk_widget_modify_fg(GTK_WIDGET(info_label_), GTK_STATE_NORMAL,
- &kEvTextColor);
- gtk_widget_show(GTK_WIDGET(info_label_));
+ std::wstring info_text = toolbar_model_->GetSecurityInfoText();
+ if (info_text.empty()) {
+ gtk_widget_hide(GTK_WIDGET(security_info_label_));
} else {
- DCHECK_EQ(info_text_type, ToolbarModel::INFO_NO_INFO);
- DCHECK(info_text.empty());
- // Clear info_text. Should we reset the fg here?
- gtk_widget_hide(GTK_WIDGET(info_label_));
+ gtk_widget_modify_fg(GTK_WIDGET(security_info_label_), GTK_STATE_NORMAL,
+ toolbar_model_->GetSecurityLevel() == ToolbarModel::EV_SECURE ?
+ &kEvSecureTextColor : &kSecurityErrorTextColor);
+ gtk_widget_show(GTK_WIDGET(security_info_label_));
}
- gtk_label_set_text(GTK_LABEL(info_label_), WideToUTF8(info_text).c_str());
- gtk_widget_set_tooltip_text(GTK_WIDGET(info_label_),
- WideToUTF8(info_tooltip).c_str());
+ gtk_label_set_text(GTK_LABEL(security_info_label_),
+ WideToUTF8(info_text).c_str());
}
void LocationBarViewGtk::SetKeywordLabel(const std::wstring& keyword) {
diff --git a/chrome/browser/gtk/location_bar_view_gtk.h b/chrome/browser/gtk/location_bar_view_gtk.h
index a92d894..6f8b708 100644
--- a/chrome/browser/gtk/location_bar_view_gtk.h
+++ b/chrome/browser/gtk/location_bar_view_gtk.h
@@ -120,9 +120,8 @@ class LocationBarViewGtk : public AutocompleteEditController,
const NotificationSource& source,
const NotificationDetails& details);
- // Translation between a security level and the background color. Both the
- // location bar and edit have to manage and match the background color.
- static const GdkColor kBackgroundColorByLevel[3];
+ // Edit background color.
+ static const GdkColor kBackgroundColor;
private:
class ContentSettingImageViewGtk : public InfoBubbleGtkDelegate {
@@ -276,7 +275,7 @@ class LocationBarViewGtk : public AutocompleteEditController,
LocationBarViewGtk* location_bar);
// Set the SSL icon we should be showing.
- void SetSecurityIcon(ToolbarModel::Icon icon);
+ void SetSecurityIcon(int resource_id);
// Sets the text that should be displayed in the info label and its associated
// tooltip text. Call with an empty string if the info label should be
@@ -308,12 +307,13 @@ class LocationBarViewGtk : public AutocompleteEditController,
// The outermost widget we want to be hosted.
OwnedWidgetGtk hbox_;
- // SSL icons.
+ // SSL state.
GtkWidget* security_icon_event_box_;
- GtkWidget* security_lock_icon_image_;
+ GtkWidget* ev_secure_icon_image_;
+ GtkWidget* secure_icon_image_;
GtkWidget* security_warning_icon_image_;
- // Toolbar info text (EV cert info).
- GtkWidget* info_label_;
+ GtkWidget* security_error_icon_image_;
+ GtkWidget* security_info_label_;
// Content setting icons.
OwnedWidgetGtk content_setting_hbox_;
diff --git a/chrome/browser/ssl/ssl_manager.cc b/chrome/browser/ssl/ssl_manager.cc
index c1350e4..7683221 100644
--- a/chrome/browser/ssl/ssl_manager.cc
+++ b/chrome/browser/ssl/ssl_manager.cc
@@ -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.
@@ -271,30 +271,15 @@ bool SSLManager::DeserializeSecurityInfo(const std::string& state,
}
// static
-bool SSLManager::GetEVCertNames(const net::X509Certificate& cert,
- std::wstring* short_name,
- std::wstring* ca_name) {
- DCHECK(short_name || ca_name);
-
+std::wstring SSLManager::GetEVCertName(const net::X509Certificate& cert) {
// EV are required to have an organization name and country.
if (cert.subject().organization_names.empty() ||
cert.subject().country_name.empty()) {
NOTREACHED();
- return false;
+ return std::wstring();
}
- if (short_name) {
- *short_name = l10n_util::GetStringF(
- IDS_SECURE_CONNECTION_EV,
- UTF8ToWide(cert.subject().organization_names[0]),
- UTF8ToWide(cert.subject().country_name));
- }
-
- if (ca_name) {
- // TODO(wtc): should we show the root CA's name instead?
- *ca_name = l10n_util::GetStringF(
- IDS_SECURE_CONNECTION_EV_CA,
- UTF8ToWide(cert.issuer().organization_names[0]));
- }
- return true;
+ return l10n_util::GetStringF(IDS_SECURE_CONNECTION_EV,
+ UTF8ToWide(cert.subject().organization_names[0]),
+ UTF8ToWide(cert.subject().country_name));
}
diff --git a/chrome/browser/ssl/ssl_manager.h b/chrome/browser/ssl/ssl_manager.h
index b0f18e1..f9e1685 100644
--- a/chrome/browser/ssl/ssl_manager.h
+++ b/chrome/browser/ssl/ssl_manager.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 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.
@@ -92,12 +92,8 @@ class SSLManager : public NotificationObserver {
int* cert_status,
int* security_bits);
- // Sets |short_name| to <organization_name> [<country>] and |ca_name|
- // to something like:
- // "Verified by <issuer_organization_name>"
- static bool GetEVCertNames(const net::X509Certificate& cert,
- std::wstring* short_name,
- std::wstring* ca_name);
+ // Returns "<organization_name> [<country>]".
+ static std::wstring GetEVCertName(const net::X509Certificate& cert);
private:
// SSLMessageInfo contains the information necessary for displaying a message
diff --git a/chrome/browser/toolbar_model.cc b/chrome/browser/toolbar_model.cc
index f3f87a3..d93edae 100644
--- a/chrome/browser/toolbar_model.cc
+++ b/chrome/browser/toolbar_model.cc
@@ -16,6 +16,7 @@
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "grit/generated_resources.h"
+#include "grit/theme_resources.h"
#include "net/base/cert_status_flags.h"
#include "net/base/net_util.h"
@@ -37,7 +38,6 @@ std::wstring ToolbarModel::GetText() const {
languages = navigation_controller->profile()->GetPrefs()->GetString(
prefs::kAcceptLanguages);
NavigationEntry* entry = navigation_controller->GetActiveEntry();
- // We may not have a navigation entry yet
if (!navigation_controller->tab_contents()->ShouldDisplayURL()) {
// Explicitly hide the URL for this tab.
url = GURL();
@@ -51,138 +51,113 @@ std::wstring ToolbarModel::GetText() const {
ToolbarModel::SecurityLevel ToolbarModel::GetSecurityLevel() const {
if (input_in_progress_) // When editing, assume no security style.
- return ToolbarModel::NORMAL;
+ return NONE;
NavigationController* navigation_controller = GetNavigationController();
if (!navigation_controller) // We might not have a controller on init.
- return ToolbarModel::NORMAL;
+ return NONE;
NavigationEntry* entry = navigation_controller->GetActiveEntry();
if (!entry)
- return ToolbarModel::NORMAL;
+ return NONE;
- switch (entry->ssl().security_style()) {
- case SECURITY_STYLE_AUTHENTICATED:
- if (entry->ssl().has_mixed_content())
- return ToolbarModel::NORMAL;
- return ToolbarModel::SECURE;
- case SECURITY_STYLE_AUTHENTICATION_BROKEN:
- return ToolbarModel::INSECURE;
+ const NavigationEntry::SSLStatus& ssl = entry->ssl();
+ switch (ssl.security_style()) {
case SECURITY_STYLE_UNKNOWN:
case SECURITY_STYLE_UNAUTHENTICATED:
- return ToolbarModel::NORMAL;
- default:
- NOTREACHED();
- return ToolbarModel::NORMAL;
- }
-}
-
-ToolbarModel::SecurityLevel ToolbarModel::GetSchemeSecurityLevel() const {
- // For now, in sync with the security level.
- return GetSecurityLevel();
-}
-
-ToolbarModel::Icon ToolbarModel::GetIcon() const {
- if (input_in_progress_)
- return ToolbarModel::NO_ICON;
+ return NONE;
- NavigationController* navigation_controller = GetNavigationController();
- if (!navigation_controller) // We might not have a controller on init.
- return ToolbarModel::NO_ICON;
-
- NavigationEntry* entry = navigation_controller->GetActiveEntry();
- if (!entry)
- return ToolbarModel::NO_ICON;
+ case SECURITY_STYLE_AUTHENTICATION_BROKEN:
+ return SECURITY_ERROR;
- const NavigationEntry::SSLStatus& ssl = entry->ssl();
- switch (ssl.security_style()) {
case SECURITY_STYLE_AUTHENTICATED:
if (ssl.has_mixed_content())
- return ToolbarModel::WARNING_ICON;
- return ToolbarModel::LOCK_ICON;
- case SECURITY_STYLE_AUTHENTICATION_BROKEN:
- return ToolbarModel::WARNING_ICON;
- case SECURITY_STYLE_UNKNOWN:
- case SECURITY_STYLE_UNAUTHENTICATED:
- return ToolbarModel::NO_ICON;
+ return SECURITY_WARNING;
+ if ((ssl.cert_status() & net::CERT_STATUS_IS_EV) &&
+ CertStore::GetSharedInstance()->RetrieveCert(ssl.cert_id(), NULL))
+ return EV_SECURE;
+ return SECURE;
+
default:
NOTREACHED();
- return ToolbarModel::NO_ICON;
+ return NONE;
}
}
+int ToolbarModel::GetSecurityIcon() const {
+ static int icon_ids[NUM_SECURITY_LEVELS] = {
+ 0,
+ IDR_EV_SECURE,
+ IDR_SECURE,
+ IDR_SECURITY_WARNING,
+ IDR_SECURITY_ERROR,
+ };
+ DCHECK(arraysize(icon_ids) == NUM_SECURITY_LEVELS);
+ return icon_ids[GetSecurityLevel()];
+}
+
void ToolbarModel::GetIconHoverText(std::wstring* text) const {
DCHECK(text);
+ text->clear();
- NavigationController* navigation_controller = GetNavigationController();
- // We don't expect to be called during initialization, so the controller
- // should never be NULL.
- DCHECK(navigation_controller);
- NavigationEntry* entry = navigation_controller->GetActiveEntry();
- DCHECK(entry);
+ switch (GetSecurityLevel()) {
+ case NONE:
+ // There's no security icon, and thus no hover text.
+ return;
+
+ case EV_SECURE:
+ case SECURE: {
+ // Note: Navigation controller and active entry are guaranteed non-NULL or
+ // the security level would be NONE.
+ GURL url(GetNavigationController()->GetActiveEntry()->url());
+ DCHECK(url.has_host());
+ *text = l10n_util::GetStringF(IDS_SECURE_CONNECTION,
+ UTF8ToWide(url.host()));
+ return;
+ }
+ case SECURITY_WARNING:
+ *text = SSLErrorInfo::CreateError(SSLErrorInfo::MIXED_CONTENTS, NULL,
+ GURL()).short_description();
+ return;
+
+ case SECURITY_ERROR:
+ // See note above.
+ CreateErrorText(GetNavigationController()->GetActiveEntry(), text);
+ // If the authentication is broken, we should always have at least one
+ // error.
+ DCHECK(!text->empty());
+ return;
- const NavigationEntry::SSLStatus& ssl = entry->ssl();
- switch (ssl.security_style()) {
- case SECURITY_STYLE_AUTHENTICATED: {
- if (ssl.has_mixed_content()) {
- SSLErrorInfo error_info = SSLErrorInfo::CreateError(
- SSLErrorInfo::MIXED_CONTENTS, NULL, GURL());
- text->assign(error_info.short_description());
- } else {
- DCHECK(entry->url().has_host());
- text->assign(l10n_util::GetStringF(IDS_SECURE_CONNECTION,
- UTF8ToWide(entry->url().host())));
- }
- break;
- }
- case SECURITY_STYLE_AUTHENTICATION_BROKEN: {
- CreateErrorText(entry, text);
- if (text->empty()) {
- // If the authentication is broken, we should always have at least one
- // error.
- NOTREACHED();
- return;
- }
- break;
- }
default:
- // Don't show the info bubble in any other cases.
- text->clear();
- break;
+ NOTREACHED();
+ return;
}
}
-ToolbarModel::InfoTextType ToolbarModel::GetInfoText(
- std::wstring* text,
- std::wstring* tooltip) const {
- DCHECK(text && tooltip);
- text->clear();
- tooltip->clear();
-
- if (input_in_progress_)
- return INFO_NO_INFO;
+std::wstring ToolbarModel::GetSecurityInfoText() const {
+ switch (GetSecurityLevel()) {
+ case NONE:
+ case SECURE:
+ case SECURITY_WARNING:
+ return std::wstring();
+
+ case EV_SECURE: {
+ scoped_refptr<net::X509Certificate> cert;
+ // See note in GetIconHoverText().
+ CertStore::GetSharedInstance()->RetrieveCert(
+ GetNavigationController()->GetActiveEntry()->ssl().cert_id(),
+ &cert);
+ return SSLManager::GetEVCertName(*cert);
+ }
- NavigationController* navigation_controller = GetNavigationController();
- if (!navigation_controller) // We might not have a controller on init.
- return INFO_NO_INFO;
+ case SECURITY_ERROR:
+ return l10n_util::GetString(IDS_SECURITY_BROKEN);
- NavigationEntry* entry = navigation_controller->GetActiveEntry();
- const NavigationEntry::SSLStatus& ssl = entry->ssl();
- if (!entry || ssl.has_mixed_content() ||
- net::IsCertStatusError(ssl.cert_status()) ||
- ((ssl.cert_status() & net::CERT_STATUS_IS_EV) == 0))
- return INFO_NO_INFO;
-
- scoped_refptr<net::X509Certificate> cert;
- CertStore::GetSharedInstance()->RetrieveCert(ssl.cert_id(), &cert);
- if (!cert.get()) {
- NOTREACHED();
- return INFO_NO_INFO;
+ default:
+ NOTREACHED();
+ return std::wstring();
}
-
- SSLManager::GetEVCertNames(*cert, text, tooltip);
- return INFO_EV_TEXT;
}
NavigationController* ToolbarModel::GetNavigationController() const {
@@ -197,10 +172,8 @@ void ToolbarModel::CreateErrorText(NavigationEntry* entry,
std::wstring* text) const {
const NavigationEntry::SSLStatus& ssl = entry->ssl();
std::vector<SSLErrorInfo> errors;
- SSLErrorInfo::GetErrorsForCertStatus(ssl.cert_id(),
- ssl.cert_status(),
- entry->url(),
- &errors);
+ SSLErrorInfo::GetErrorsForCertStatus(ssl.cert_id(), ssl.cert_status(),
+ entry->url(), &errors);
if (ssl.has_mixed_content()) {
errors.push_back(SSLErrorInfo::CreateError(SSLErrorInfo::MIXED_CONTENTS,
NULL, GURL()));
@@ -210,19 +183,16 @@ void ToolbarModel::CreateErrorText(NavigationEntry* entry,
NULL, GURL()));
}
- int error_count = static_cast<int>(errors.size());
- if (error_count == 0) {
- text->assign(L"");
- } else if (error_count == 1) {
- text->assign(errors[0].short_description());
+ if (errors.empty()) {
+ text->clear();
+ } else if (errors.size() == 1) {
+ *text = errors[0].short_description();
} else {
// Multiple errors.
- text->assign(l10n_util::GetString(IDS_SEVERAL_SSL_ERRORS));
- text->append(L"\n");
- for (int i = 0; i < error_count; ++i) {
+ *text = l10n_util::GetString(IDS_SEVERAL_SSL_ERRORS);
+ for (size_t i = 0; i < errors.size(); ++i) {
+ text->append(L"\n");
text->append(errors[i].short_description());
- if (i != error_count - 1)
- text->append(L"\n");
}
}
}
diff --git a/chrome/browser/toolbar_model.h b/chrome/browser/toolbar_model.h
index 1d959c5..7827e41 100644
--- a/chrome/browser/toolbar_model.h
+++ b/chrome/browser/toolbar_model.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 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.
@@ -19,53 +19,33 @@ class NavigationEntry;
class ToolbarModel {
public:
enum SecurityLevel {
- SECURE = 0,
- NORMAL,
- INSECURE
- };
-
- enum Icon {
- NO_ICON = 0,
- LOCK_ICON,
- WARNING_ICON
- };
-
- enum InfoTextType {
- INFO_NO_INFO = 0,
- INFO_EV_TEXT,
+ NONE = 0, // HTTP/no URL/user is editing
+ EV_SECURE, // HTTPS with valid EV cert
+ SECURE, // HTTPS (non-EV)
+ SECURITY_WARNING, // HTTPS, but with mixed content on the page
+ SECURITY_ERROR, // Attempted HTTPS and failed, page not authenticated
+ NUM_SECURITY_LEVELS,
};
explicit ToolbarModel(Browser* browser);
~ToolbarModel();
// Returns the text that should be displayed in the location bar.
- // Default value: empty string.
std::wstring GetText() const;
// Returns the security level that the toolbar should display.
- // Default value: NORMAL.
SecurityLevel GetSecurityLevel() const;
- // Returns the security level that should be used in the scheme part of the
- // displayed URL. If SECURE, then the scheme is painted in green. If
- // INSECURE, it is painted in red and stricken-out.
- // Default value: NORMAL.
- SecurityLevel GetSchemeSecurityLevel() const;
-
- // Returns the icon that should be displayed on the right of the location bar.
- // Default value: NO_ICON.
- Icon GetIcon() const;
+ // Returns the resource_id of the icon to show to the left of the address.
+ int GetSecurityIcon() const;
// Sets the text displayed in the info bubble that appears when the user
// hovers the mouse over the icon.
- // Default value: empty string.
void GetIconHoverText(std::wstring* text) const;
- // Sets |text| to contain the text that should be displayed on the right of
- // the location bar, and |tooltip| to the tooltip text that should be shown
- // when the mouse hover over that info label.
- // Default value: NO_INFO and empty string for |text| and |tooltip|.
- InfoTextType GetInfoText(std::wstring* text, std::wstring* tooltip) const;
+ // Returns the text, if any, that should be displayed on the right of the
+ // location bar.
+ std::wstring GetSecurityInfoText() const;
// Getter/setter of whether the text in location bar is currently being
// edited.
diff --git a/chrome/browser/views/app_launcher.cc b/chrome/browser/views/app_launcher.cc
index f9c99a8..aa0db1d 100644
--- a/chrome/browser/views/app_launcher.cc
+++ b/chrome/browser/views/app_launcher.cc
@@ -197,8 +197,8 @@ class NavigationBar : public views::View,
browser->profile(),
browser->command_updater(), false, this);
autocomplete_view->Init();
- gtk_widget_show_all(autocomplete_view->widget());
- gtk_widget_hide(autocomplete_view->widget());
+ gtk_widget_show_all(autocomplete_view->GetNativeView());
+ gtk_widget_hide(autocomplete_view->GetNativeView());
location_entry_.reset(autocomplete_view);
#else
NOTIMPLEMENTED();
diff --git a/chrome/browser/views/location_bar_view.cc b/chrome/browser/views/location_bar_view.cc
index 6aa9795..1d9ced9 100644
--- a/chrome/browser/views/location_bar_view.cc
+++ b/chrome/browser/views/location_bar_view.cc
@@ -57,10 +57,6 @@ static const SkBitmap* kBackground = NULL;
static const SkBitmap* kPopupBackground = NULL;
-// The delay the mouse has to be hovering over the lock/warning icon before the
-// info bubble is shown.
-static const int kInfoBubbleHoverDelayMs = 500;
-
// The tab key image.
static const SkBitmap* kTabButtonBitmap = NULL;
@@ -139,11 +135,11 @@ LocationBarView::LocationBarView(Profile* profile,
model_(model),
delegate_(delegate),
disposition_(CURRENT_TAB),
+ security_image_view_(this),
location_entry_view_(NULL),
selected_keyword_view_(profile),
keyword_hint_view_(profile),
type_to_search_view_(l10n_util::GetString(IDS_OMNIBOX_EMPTY_TEXT)),
- security_image_view_(this, profile, model, bubble_positioner),
popup_window_mode_(popup_window_mode),
first_run_bubble_(this),
bubble_positioner_(bubble_positioner) {
@@ -170,46 +166,39 @@ void LocationBarView::Init() {
font_ = font_.DeriveFont(3);
}
+ AddChildView(&security_image_view_);
+ security_image_view_.SetVisible(false);
+ security_image_view_.set_parent_owned(false);
+
// URL edit field.
// View container for URL edit field.
#if defined(OS_WIN)
- views::Widget* widget = GetWidget();
location_entry_.reset(new AutocompleteEditViewWin(font_, this, model_, this,
- widget->GetNativeView(),
- profile_, command_updater_,
- popup_window_mode_,
- bubble_positioner_));
+ GetWidget()->GetNativeView(), profile_, command_updater_,
+ popup_window_mode_, bubble_positioner_));
#else
location_entry_.reset(new AutocompleteEditViewGtk(this, model_, profile_,
- command_updater_,
- popup_window_mode_,
- bubble_positioner_));
+ command_updater_, popup_window_mode_, bubble_positioner_));
location_entry_->Init();
// Make all the children of the widget visible. NOTE: this won't display
// anything, it just toggles the visible flag.
- gtk_widget_show_all(location_entry_->widget());
+ gtk_widget_show_all(location_entry_->GetNativeView());
// Hide the widget. NativeViewHostGtk will make it visible again as
// necessary.
- gtk_widget_hide(location_entry_->widget());
+ gtk_widget_hide(location_entry_->GetNativeView());
#endif
location_entry_view_ = new views::NativeViewHost;
location_entry_view_->SetID(VIEW_ID_AUTOCOMPLETE);
AddChildView(location_entry_view_);
location_entry_view_->set_focus_view(this);
- location_entry_view_->Attach(
-#if defined(OS_WIN)
- location_entry_->m_hWnd
-#else
- location_entry_->widget()
-#endif
- ); // NOLINT
+ location_entry_view_->Attach(location_entry_->GetNativeView());
AddChildView(&selected_keyword_view_);
selected_keyword_view_.SetFont(font_);
selected_keyword_view_.SetVisible(false);
selected_keyword_view_.set_parent_owned(false);
- SkColor dimmed_text = GetColor(false, DEEMPHASIZED_TEXT);
+ SkColor dimmed_text = GetColor(ToolbarModel::NONE, DEEMPHASIZED_TEXT);
AddChildView(&type_to_search_view_);
type_to_search_view_.SetVisible(false);
@@ -223,9 +212,9 @@ void LocationBarView::Init() {
keyword_hint_view_.SetColor(dimmed_text);
keyword_hint_view_.set_parent_owned(false);
- AddChildView(&security_image_view_);
- security_image_view_.SetVisible(false);
- security_image_view_.set_parent_owned(false);
+ AddChildView(&security_info_label_);
+ security_info_label_.SetVisible(false);
+ security_info_label_.set_parent_owned(false);
for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) {
ContentSettingImageView* content_blocked_view =
@@ -236,10 +225,6 @@ void LocationBarView::Init() {
content_blocked_view->SetVisible(false);
}
- AddChildView(&info_label_);
- info_label_.SetVisible(false);
- info_label_.set_parent_owned(false);
-
// Notify us when any ancestor is resized. In this case we want to tell the
// AutocompleteEditView to close its popup.
SetNotifyWhenVisibleBoundsInRootChanges(true);
@@ -256,60 +241,66 @@ bool LocationBarView::IsInitialized() const {
}
// static
-SkColor LocationBarView::GetColor(bool is_secure, ColorKind kind) {
- enum SecurityState {
- NOT_SECURE = 0,
- SECURE,
- NUM_STATES
- };
-
- static bool initialized = false;
- static SkColor colors[NUM_STATES][NUM_KINDS];
- if (!initialized) {
+SkColor LocationBarView::GetColor(ToolbarModel::SecurityLevel security_level,
+ ColorKind kind) {
+ switch (kind) {
#if defined(OS_WIN)
- colors[NOT_SECURE][BACKGROUND] = color_utils::GetSysSkColor(COLOR_WINDOW);
- colors[NOT_SECURE][TEXT] = color_utils::GetSysSkColor(COLOR_WINDOWTEXT);
- colors[NOT_SECURE][SELECTED_TEXT] =
- color_utils::GetSysSkColor(COLOR_HIGHLIGHTTEXT);
+ case BACKGROUND: return color_utils::GetSysSkColor(COLOR_WINDOW);
+ case TEXT: return color_utils::GetSysSkColor(COLOR_WINDOWTEXT);
+ case SELECTED_TEXT: return color_utils::GetSysSkColor(COLOR_HIGHLIGHTTEXT);
#else
// TODO(beng): source from theme provider.
- colors[NOT_SECURE][BACKGROUND] = SK_ColorWHITE;
- colors[NOT_SECURE][TEXT] = SK_ColorBLACK;
- colors[NOT_SECURE][SELECTED_TEXT] = SK_ColorWHITE;
+ case BACKGROUND: return SK_ColorWHITE;
+ case TEXT: return SK_ColorBLACK;
+ case SELECTED_TEXT: return SK_ColorWHITE;
#endif
- colors[SECURE][BACKGROUND] = SkColorSetRGB(255, 245, 195);
- colors[SECURE][TEXT] = SK_ColorBLACK;
- colors[SECURE][SELECTED_TEXT] = 0; // Unused
- colors[NOT_SECURE][DEEMPHASIZED_TEXT] =
- color_utils::AlphaBlend(colors[NOT_SECURE][TEXT],
- colors[NOT_SECURE][BACKGROUND], 128);
- colors[SECURE][DEEMPHASIZED_TEXT] =
- color_utils::AlphaBlend(colors[SECURE][TEXT],
- colors[SECURE][BACKGROUND], 128);
- colors[NOT_SECURE][SECURITY_TEXT] = color_utils::GetReadableColor(
- SkColorSetRGB(200, 0, 0), colors[NOT_SECURE][BACKGROUND]);
- colors[SECURE][SECURITY_TEXT] = SkColorSetRGB(0, 150, 20);
- colors[NOT_SECURE][SECURITY_INFO_BUBBLE_TEXT] =
- colors[NOT_SECURE][SECURITY_TEXT];
- colors[SECURE][SECURITY_INFO_BUBBLE_TEXT] = color_utils::GetReadableColor(
- SkColorSetRGB(0, 153, 51), colors[NOT_SECURE][BACKGROUND]);
- colors[NOT_SECURE][SCHEME_STRIKEOUT] = color_utils::GetReadableColor(
- SkColorSetRGB(210, 0, 0), colors[NOT_SECURE][BACKGROUND]);
- colors[SECURE][SCHEME_STRIKEOUT] = 0; // Unused
- initialized = true;
- }
- return colors[is_secure ? SECURE : NOT_SECURE][kind];
+ case DEEMPHASIZED_TEXT:
+ return color_utils::AlphaBlend(GetColor(security_level, TEXT),
+ GetColor(security_level, BACKGROUND), 128);
+
+ case SECURITY_TEXT: {
+ SkColor color;
+ switch (security_level) {
+ case ToolbarModel::EV_SECURE:
+ color = SkColorSetRGB(7, 149, 0);
+ break;
+
+ case ToolbarModel::SECURE:
+ case ToolbarModel::SECURITY_WARNING:
+ color = SkColorSetRGB(0, 14, 149);
+ break;
+
+ case ToolbarModel::SECURITY_ERROR:
+ color = SkColorSetRGB(162, 0, 0);
+ break;
+
+ default:
+ NOTREACHED();
+ return GetColor(security_level, TEXT);
+ }
+ return color_utils::GetReadableColor(color, GetColor(security_level,
+ BACKGROUND));
+ }
+
+ default:
+ NOTREACHED();
+ return GetColor(security_level, TEXT);
+ }
}
void LocationBarView::Update(const TabContents* tab_for_state_restoring) {
- SetSecurityIcon(model_->GetIcon());
+ security_image_view_.SetSecurityIcon(model_->GetSecurityIcon());
+ // The visibility of the |security_info_label_| will be set during layout.
+ std::wstring security_info_text(model_->GetSecurityInfoText());
+ security_info_label_.SetText(security_info_text);
+ if (!security_info_text.empty()) {
+ security_info_label_.SetColor(GetColor(model_->GetSecurityLevel(),
+ SECURITY_TEXT));
+ }
+
RefreshContentSettingViews();
RefreshPageActionViews();
- std::wstring info_text, info_tooltip;
- ToolbarModel::InfoTextType info_text_type =
- model_->GetInfoText(&info_text, &info_tooltip);
- SetInfoText(info_text, info_text_type, info_tooltip);
location_entry_->Update(tab_for_state_restoring);
Layout();
SchedulePaint();
@@ -362,7 +353,6 @@ void LocationBarView::SetProfile(Profile* profile) {
for (ContentSettingViews::const_iterator i(content_setting_views_.begin());
i != content_setting_views_.end(); ++i)
(*i)->set_profile(profile);
- security_image_view_.set_profile(profile);
}
}
@@ -419,10 +409,9 @@ void LocationBarView::Paint(gfx::Canvas* canvas) {
canvas->TileImageInt(*background, 0, 0, 0, 0, width(), height());
int top_margin = TopMargin();
- canvas->FillRectInt(
- GetColor(model_->GetSchemeSecurityLevel() == ToolbarModel::SECURE,
- BACKGROUND),
- 0, top_margin, width(), std::max(height() - top_margin - kVertMargin, 0));
+ canvas->FillRectInt(GetColor(ToolbarModel::NONE, BACKGROUND), 0,
+ top_margin, width(),
+ std::max(height() - top_margin - kVertMargin, 0));
}
void LocationBarView::VisibleBoundsInRootChanged() {
@@ -546,6 +535,11 @@ void LocationBarView::DoLayout(const bool force_layout) {
int entry_width = width() - (kEntryPadding * 2);
+ gfx::Size security_image_size;
+ if (security_image_view_.IsVisible()) {
+ security_image_size = security_image_view_.GetPreferredSize();
+ entry_width -= security_image_size.width() + kInnerPadding;
+ }
for (PageActionViews::const_iterator i(page_action_views_.begin());
i != page_action_views_.end(); ++i) {
if ((*i)->IsVisible())
@@ -556,16 +550,6 @@ void LocationBarView::DoLayout(const bool force_layout) {
if ((*i)->IsVisible())
entry_width -= (*i)->GetPreferredSize().width() + kInnerPadding;
}
- gfx::Size security_image_size;
- if (security_image_view_.IsVisible()) {
- security_image_size = security_image_view_.GetPreferredSize();
- entry_width -= security_image_size.width() + kInnerPadding;
- }
- gfx::Size info_label_size;
- if (info_label_.IsVisible()) {
- info_label_size = info_label_.GetPreferredSize();
- entry_width -= (info_label_size.width() + kInnerPadding);
- }
#if defined(OS_WIN)
RECT formatting_rect;
@@ -582,7 +566,7 @@ void LocationBarView::DoLayout(const bool force_layout) {
return;
const int available_width = AvailableWidth(max_edit_width);
bool needs_layout = force_layout;
- needs_layout |= AdjustHints(available_width);
+ needs_layout |= AdjustAutocollapseViews(available_width);
if (!needs_layout)
return;
@@ -591,23 +575,8 @@ void LocationBarView::DoLayout(const bool force_layout) {
int location_y = TopMargin();
int location_height = std::max(height() - location_y - kVertMargin, 0);
- // First set the bounds for the label that appears to the right of the
- // security icon.
+ // Lay out items to the right of the edit field.
int offset = width() - kEntryPadding;
- if (info_label_.IsVisible()) {
- offset -= info_label_size.width();
- info_label_.SetBounds(offset, location_y,
- info_label_size.width(), location_height);
- offset -= kInnerPadding;
- }
- if (security_image_view_.IsVisible()) {
- offset -= security_image_size.width();
- security_image_view_.SetBounds(offset, location_y,
- security_image_size.width(),
- location_height);
- offset -= kInnerPadding;
- }
-
for (PageActionViews::const_iterator i(page_action_views_.begin());
i != page_action_views_.end(); ++i) {
if ((*i)->IsVisible()) {
@@ -630,8 +599,19 @@ void LocationBarView::DoLayout(const bool force_layout) {
offset -= kInnerPadding;
}
}
- gfx::Rect location_bounds(kEntryPadding, location_y, entry_width,
- location_height);
+
+ // Now lay out items to the left of the edit field.
+ offset = kEntryPadding;
+ if (security_image_view_.IsVisible()) {
+ security_image_view_.SetBounds(offset, location_y,
+ security_image_size.width(),
+ location_height);
+ offset = security_image_view_.bounds().right() + kInnerPadding;
+ }
+
+ // Now lay out the edit field and views that autocollapse to give it more
+ // room.
+ gfx::Rect location_bounds(offset, location_y, entry_width, location_height);
if (selected_keyword_view_.IsVisible()) {
LayoutView(true, &selected_keyword_view_, available_width,
&location_bounds);
@@ -642,6 +622,10 @@ void LocationBarView::DoLayout(const bool force_layout) {
LayoutView(false, &type_to_search_view_, available_width,
&location_bounds);
}
+ if (security_info_label_.IsVisible()) {
+ LayoutView(false, &security_info_label_, available_width,
+ &location_bounds);
+ }
location_entry_view_->SetBounds(location_bounds);
if (!force_layout) {
@@ -679,7 +663,7 @@ bool LocationBarView::NeedsResize(View* view, int available_width) {
return (view->width() != size.width());
}
-bool LocationBarView::AdjustHints(int available_width) {
+bool LocationBarView::AdjustAutocollapseViews(int available_width) {
const std::wstring keyword(location_entry_->model()->keyword());
const bool is_keyword_hint(location_entry_->model()->is_keyword_hint());
const bool show_selected_keyword = !keyword.empty() && !is_keyword_hint;
@@ -689,8 +673,15 @@ bool LocationBarView::AdjustHints(int available_width) {
if (show_search_hint) {
// Only show type to search if all the text fits.
- gfx::Size view_pref = type_to_search_view_.GetPreferredSize();
- show_search_hint = UsePref(view_pref.width(), available_width);
+ gfx::Size preferred_size = type_to_search_view_.GetPreferredSize();
+ show_search_hint = UsePref(preferred_size.width(), available_width);
+ }
+
+ bool show_security_info_label = !security_info_label_.GetText().empty();
+ if (show_security_info_label) {
+ // Only show the security info label if all the text fits.
+ gfx::Size preferred_size = security_info_label_.GetPreferredSize();
+ show_security_info_label = UsePref(preferred_size.width(), available_width);
}
// NOTE: This isn't just one big || statement as ToggleVisibility MUST be
@@ -700,6 +691,8 @@ bool LocationBarView::AdjustHints(int available_width) {
&selected_keyword_view_);
needs_layout |= ToggleVisibility(show_keyword_hint, &keyword_hint_view_);
needs_layout |= ToggleVisibility(show_search_hint, &type_to_search_view_);
+ needs_layout |= ToggleVisibility(show_security_info_label,
+ &security_info_label_);
if (show_selected_keyword) {
if (selected_keyword_view_.keyword() != keyword) {
needs_layout = true;
@@ -725,40 +718,20 @@ void LocationBarView::LayoutView(bool leading,
gfx::Size view_size = view->GetPreferredSize();
if (!UsePref(view_size.width(), available_width))
view_size = view->GetMinimumSize();
- if (view_size.width() + kInnerPadding < bounds->width()) {
- view->SetVisible(true);
- if (leading) {
- view->SetBounds(bounds->x(), bounds->y(), view_size.width(),
- bounds->height());
- bounds->Offset(view_size.width() + kInnerPadding, 0);
- } else {
- view->SetBounds(bounds->right() - view_size.width(), bounds->y(),
- view_size.width(), bounds->height());
- }
- bounds->set_width(bounds->width() - view_size.width() - kInnerPadding);
- } else {
+ if (view_size.width() + kInnerPadding >= bounds->width()) {
view->SetVisible(false);
+ return;
}
-}
-
-void LocationBarView::SetSecurityIcon(ToolbarModel::Icon icon) {
- switch (icon) {
- case ToolbarModel::LOCK_ICON:
- security_image_view_.SetImageShown(SecurityImageView::LOCK);
- security_image_view_.SetVisible(true);
- break;
- case ToolbarModel::WARNING_ICON:
- security_image_view_.SetImageShown(SecurityImageView::WARNING);
- security_image_view_.SetVisible(true);
- break;
- case ToolbarModel::NO_ICON:
- security_image_view_.SetVisible(false);
- break;
- default:
- NOTREACHED();
- security_image_view_.SetVisible(false);
- break;
+ if (leading) {
+ view->SetBounds(bounds->x(), bounds->y(), view_size.width(),
+ bounds->height());
+ bounds->Offset(view_size.width() + kInnerPadding, 0);
+ } else {
+ view->SetBounds(bounds->right() - view_size.width(), bounds->y(),
+ view_size.width(), bounds->height());
}
+ bounds->set_width(bounds->width() - view_size.width() - kInnerPadding);
+ view->SetVisible(true);
}
void LocationBarView::RefreshContentSettingViews() {
@@ -804,8 +777,7 @@ void LocationBarView::RefreshPageActionViews() {
for (size_t i = 0; i < page_actions.size(); ++i) {
page_action_views_[i] = new PageActionWithBadgeView(
- new PageActionImageView(this, profile_,
- page_actions[i], bubble_positioner_));
+ new PageActionImageView(this, profile_, page_actions[i]));
page_action_views_[i]->SetVisible(false);
AddChildView(page_action_views_[i]);
}
@@ -832,23 +804,12 @@ void LocationBarView::RefreshPageActionViews() {
}
}
-void LocationBarView::SetInfoText(const std::wstring& text,
- ToolbarModel::InfoTextType text_type,
- const std::wstring& tooltip_text) {
- info_label_.SetVisible(!text.empty());
- info_label_.SetText(text);
- if (text_type == ToolbarModel::INFO_EV_TEXT)
- info_label_.SetColor(GetColor(true, SECURITY_TEXT));
- info_label_.SetTooltipText(tooltip_text);
-}
-
bool LocationBarView::ToggleVisibility(bool new_vis, View* view) {
DCHECK(view);
- if (view->IsVisible() != new_vis) {
- view->SetVisible(new_vis);
- return true;
- }
- return false;
+ if (view->IsVisible() == new_vis)
+ return false;
+ view->SetVisible(new_vis);
+ return true;
}
#if defined(OS_WIN)
@@ -872,6 +833,40 @@ void LocationBarView::OnMouseEvent(const views::MouseEvent& event, UINT msg) {
}
#endif
+void LocationBarView::ShowFirstRunBubbleInternal(bool use_OEM_bubble) {
+ if (!location_entry_view_)
+ return;
+ if (!location_entry_view_->GetWidget()->IsActive()) {
+ // The browser is no longer active. Let's not show the info bubble, this
+ // would make the browser the active window again.
+ return;
+ }
+
+ gfx::Point location;
+
+ // If the UI layout is RTL, the coordinate system is not transformed and
+ // therefore we need to adjust the X coordinate so that bubble appears on the
+ // right hand side of the location bar.
+ if (UILayoutIsRightToLeft())
+ location.Offset(width(), 0);
+ views::View::ConvertPointToScreen(this, &location);
+
+ // We try to guess that 20 pixels offset is a good place for the first
+ // letter in the OmniBox.
+ gfx::Rect bounds(location.x(), location.y(), 20, height());
+
+ // Moving the bounds "backwards" so that it appears within the location bar
+ // if the UI layout is RTL.
+ if (UILayoutIsRightToLeft())
+ bounds.set_x(location.x() - 20);
+
+#if defined(OS_WIN)
+ FirstRunBubble::Show(profile_, GetWindow(), bounds, use_OEM_bubble);
+#else
+ // First run bubble doesn't make sense for Chrome OS.
+#endif
+}
+
bool LocationBarView::GetAccessibleName(std::wstring* name) {
DCHECK(name);
@@ -893,6 +888,39 @@ void LocationBarView::SetAccessibleName(const std::wstring& name) {
accessible_name_.assign(name);
}
+// SecurityImageView------------------------------------------------------------
+
+LocationBarView::SecurityImageView::SecurityImageView(
+ const LocationBarView* parent)
+ : parent_(parent) {
+ SetSecurityIcon(0);
+}
+
+LocationBarView::SecurityImageView::~SecurityImageView() {
+}
+
+void LocationBarView::SecurityImageView::SetSecurityIcon(int icon_id) {
+ if (icon_id == 0) {
+ SetVisible(false);
+ return;
+ }
+
+ SetImage(ResourceBundle::GetSharedInstance().GetBitmapNamed(icon_id));
+ SetVisible(true);
+}
+
+bool LocationBarView::SecurityImageView::OnMousePressed(
+ const views::MouseEvent& event) {
+ TabContents* tab = parent_->GetTabContents();
+ NavigationEntry* nav_entry = tab->controller().GetActiveEntry();
+ if (!nav_entry) {
+ NOTREACHED();
+ return true;
+ }
+ tab->ShowPageInfo(nav_entry->url(), nav_entry->ssl(), true);
+ return true;
+}
+
// SelectedKeywordView -------------------------------------------------------
// The background is drawn using HorizontalPainter. This is the
@@ -1131,214 +1159,6 @@ bool LocationBarView::SkipDefaultKeyEventProcessing(const views::KeyEvent& e) {
#endif
}
-// ShowInfoBubbleTask-----------------------------------------------------------
-
-class LocationBarView::ShowInfoBubbleTask : public Task {
- public:
- explicit ShowInfoBubbleTask(
- LocationBarView::LocationBarImageView* image_view);
- virtual void Run();
- void Cancel();
-
- private:
- LocationBarView::LocationBarImageView* image_view_;
- bool cancelled_;
-
- DISALLOW_COPY_AND_ASSIGN(ShowInfoBubbleTask);
-};
-
-LocationBarView::ShowInfoBubbleTask::ShowInfoBubbleTask(
- LocationBarView::LocationBarImageView* image_view)
- : image_view_(image_view),
- cancelled_(false) {
-}
-
-void LocationBarView::ShowInfoBubbleTask::Run() {
- if (cancelled_)
- return;
-
- if (!image_view_->GetWidget()->IsActive()) {
- // The browser is no longer active. Let's not show the info bubble, this
- // would make the browser the active window again. Also makes sure we NULL
- // show_info_bubble_task_ to prevent the SecurityImageView from keeping a
- // dangling pointer.
- image_view_->show_info_bubble_task_ = NULL;
- return;
- }
-
- image_view_->ShowInfoBubble();
-}
-
-void LocationBarView::ShowInfoBubbleTask::Cancel() {
- cancelled_ = true;
-}
-
-// -----------------------------------------------------------------------------
-
-void LocationBarView::ShowFirstRunBubbleInternal(bool use_OEM_bubble) {
- if (!location_entry_view_)
- return;
- if (!location_entry_view_->GetWidget()->IsActive()) {
- // The browser is no longer active. Let's not show the info bubble, this
- // would make the browser the active window again.
- return;
- }
-
- gfx::Point location;
-
- // If the UI layout is RTL, the coordinate system is not transformed and
- // therefore we need to adjust the X coordinate so that bubble appears on the
- // right hand side of the location bar.
- if (UILayoutIsRightToLeft())
- location.Offset(width(), 0);
- views::View::ConvertPointToScreen(this, &location);
-
- // We try to guess that 20 pixels offset is a good place for the first
- // letter in the OmniBox.
- gfx::Rect bounds(location.x(), location.y(), 20, height());
-
- // Moving the bounds "backwards" so that it appears within the location bar
- // if the UI layout is RTL.
- if (UILayoutIsRightToLeft())
- bounds.set_x(location.x() - 20);
-
-#if defined(OS_WIN)
- FirstRunBubble::Show(profile_, GetWindow(), bounds, use_OEM_bubble);
-#else
- // First run bubble doesn't make sense for Chrome OS.
-#endif
-}
-
-// LocationBarImageView---------------------------------------------------------
-
-LocationBarView::LocationBarImageView::LocationBarImageView(
- const BubblePositioner* bubble_positioner)
- : info_bubble_(NULL),
- show_info_bubble_task_(NULL),
- bubble_positioner_(bubble_positioner) {
-}
-
-LocationBarView::LocationBarImageView::~LocationBarImageView() {
- if (show_info_bubble_task_)
- show_info_bubble_task_->Cancel();
-
- if (info_bubble_)
- info_bubble_->Close();
-}
-
-void LocationBarView::LocationBarImageView::OnMouseMoved(
- const views::MouseEvent& event) {
- if (show_info_bubble_task_) {
- show_info_bubble_task_->Cancel();
- show_info_bubble_task_ = NULL;
- }
-
- if (info_bubble_) {
- // If an info bubble is currently showing, nothing to do.
- return;
- }
-
- show_info_bubble_task_ = new ShowInfoBubbleTask(this);
- MessageLoop::current()->PostDelayedTask(FROM_HERE, show_info_bubble_task_,
- kInfoBubbleHoverDelayMs);
-}
-
-void LocationBarView::LocationBarImageView::OnMouseExited(
- const views::MouseEvent& event) {
- if (show_info_bubble_task_) {
- show_info_bubble_task_->Cancel();
- show_info_bubble_task_ = NULL;
- }
-
- if (info_bubble_)
- info_bubble_->Close();
-}
-
-void LocationBarView::LocationBarImageView::InfoBubbleClosing(
- InfoBubble* info_bubble, bool closed_by_escape) {
- info_bubble_ = NULL;
-}
-
-void LocationBarView::LocationBarImageView::ShowInfoBubbleImpl(
- const std::wstring& text, SkColor text_color) {
- gfx::Rect bounds(bubble_positioner_->GetLocationStackBounds());
- gfx::Point location;
- views::View::ConvertPointToScreen(this, &location);
- bounds.set_x(location.x());
- bounds.set_width(width());
-
- views::Label* label = new views::Label(text);
- label->SetMultiLine(true);
- label->SetColor(text_color);
- label->SetFont(ResourceBundle::GetSharedInstance().GetFont(
- ResourceBundle::BaseFont).DeriveFont(2));
- label->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
- label->SizeToFit(0);
- DCHECK(info_bubble_ == NULL);
- info_bubble_ = InfoBubble::Show(GetWindow(), bounds, label, this);
- show_info_bubble_task_ = NULL;
-}
-
-// SecurityImageView------------------------------------------------------------
-
-// static
-SkBitmap* LocationBarView::SecurityImageView::lock_icon_ = NULL;
-SkBitmap* LocationBarView::SecurityImageView::warning_icon_ = NULL;
-
-LocationBarView::SecurityImageView::SecurityImageView(
- const LocationBarView* parent,
- Profile* profile,
- ToolbarModel* model,
- const BubblePositioner* bubble_positioner)
- : LocationBarImageView(bubble_positioner),
- parent_(parent),
- profile_(profile),
- model_(model) {
- if (!lock_icon_) {
- ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- lock_icon_ = rb.GetBitmapNamed(IDR_LOCK);
- warning_icon_ = rb.GetBitmapNamed(IDR_WARNING);
- }
- SetImageShown(LOCK);
-}
-
-LocationBarView::SecurityImageView::~SecurityImageView() {
-}
-
-void LocationBarView::SecurityImageView::SetImageShown(Image image) {
- switch (image) {
- case LOCK:
- SetImage(lock_icon_);
- break;
- case WARNING:
- SetImage(warning_icon_);
- break;
- default:
- NOTREACHED();
- break;
- }
-}
-
-bool LocationBarView::SecurityImageView::OnMousePressed(
- const views::MouseEvent& event) {
- TabContents* tab = parent_->GetTabContents();
- NavigationEntry* nav_entry = tab->controller().GetActiveEntry();
- if (!nav_entry) {
- NOTREACHED();
- return true;
- }
- tab->ShowPageInfo(nav_entry->url(), nav_entry->ssl(), true);
- return true;
-}
-
-void LocationBarView::SecurityImageView::ShowInfoBubble() {
- std::wstring text;
- model_->GetIconHoverText(&text);
- ShowInfoBubbleImpl(text, GetColor(
- model_->GetSecurityLevel() == ToolbarModel::SECURE,
- SECURITY_INFO_BUBBLE_TEXT));
-}
-
// ContentSettingImageView------------------------------------------------------
LocationBarView::ContentSettingImageView::ContentSettingImageView(
@@ -1364,16 +1184,16 @@ void LocationBarView::ContentSettingImageView::UpdateFromTabContents(
const TabContents* tab_contents) {
int old_icon = content_setting_image_model_->get_icon();
content_setting_image_model_->UpdateFromTabContents(tab_contents);
- if (content_setting_image_model_->is_visible()) {
- if (old_icon != content_setting_image_model_->get_icon()) {
- ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- SetImage(rb.GetBitmapNamed(content_setting_image_model_->get_icon()));
- }
- SetTooltipText(UTF8ToWide(content_setting_image_model_->get_tooltip()));
- SetVisible(true);
- } else {
+ if (!content_setting_image_model_->is_visible()) {
SetVisible(false);
+ return;
}
+ if (old_icon != content_setting_image_model_->get_icon()) {
+ ResourceBundle& rb = ResourceBundle::GetSharedInstance();
+ SetImage(rb.GetBitmapNamed(content_setting_image_model_->get_icon()));
+ }
+ SetTooltipText(UTF8ToWide(content_setting_image_model_->get_tooltip()));
+ SetVisible(true);
}
bool LocationBarView::ContentSettingImageView::OnMousePressed(
@@ -1421,10 +1241,8 @@ bool LocationBarView::ContentSettingImageView::CloseOnEscape() {
LocationBarView::PageActionImageView::PageActionImageView(
LocationBarView* owner,
Profile* profile,
- ExtensionAction* page_action,
- const BubblePositioner* bubble_positioner)
- : LocationBarImageView(bubble_positioner),
- owner_(owner),
+ ExtensionAction* page_action)
+ : owner_(owner),
profile_(profile),
page_action_(page_action),
ALLOW_THIS_IN_INITIALIZER_LIST(tracker_(this)),
@@ -1505,13 +1323,6 @@ void LocationBarView::PageActionImageView::ExecuteAction(int button,
}
}
-void LocationBarView::PageActionImageView::OnMouseMoved(
- const views::MouseEvent& event) {
- // PageActionImageView uses normal tooltips rather than the info bubble,
- // so just do nothing here rather than letting LocationBarImageView start
- // its hover timer.
-}
-
bool LocationBarView::PageActionImageView::OnMousePressed(
const views::MouseEvent& event) {
// We are interested in capturing mouse messages, but we want want to wait
@@ -1552,10 +1363,6 @@ void LocationBarView::PageActionImageView::OnMouseReleased(
ExecuteAction(button, false); // inspect_with_devtools
}
-void LocationBarView::PageActionImageView::ShowInfoBubble() {
- ShowInfoBubbleImpl(ASCIIToWide(tooltip_), GetColor(false, TEXT));
-}
-
void LocationBarView::PageActionImageView::OnImageLoaded(
SkBitmap* image, ExtensionResource resource, int index) {
// We loaded icons()->size() icons, plus one extra if the page action had
diff --git a/chrome/browser/views/location_bar_view.h b/chrome/browser/views/location_bar_view.h
index 084006d..e2b5720 100644
--- a/chrome/browser/views/location_bar_view.h
+++ b/chrome/browser/views/location_bar_view.h
@@ -75,9 +75,6 @@ class LocationBarView : public LocationBar,
SELECTED_TEXT,
DEEMPHASIZED_TEXT,
SECURITY_TEXT,
- SECURITY_INFO_BUBBLE_TEXT,
- SCHEME_STRIKEOUT,
- NUM_KINDS
};
LocationBarView(Profile* profile,
@@ -96,7 +93,8 @@ class LocationBarView : public LocationBar,
// Returns the appropriate color for the desired kind, based on the user's
// system theme.
- static SkColor GetColor(bool is_secure, ColorKind kind);
+ static SkColor GetColor(ToolbarModel::SecurityLevel security_level,
+ ColorKind kind);
// Updates the location bar. We also reset the bar's permanent text and
// security style, and, if |tab_for_state_restoring| is non-NULL, also restore
@@ -191,6 +189,26 @@ class LocationBarView : public LocationBar,
void Focus();
private:
+ // SecurityImageView is used to display the appropriate status icon when the
+ // current URL's scheme is https.
+ class SecurityImageView : public views::ImageView {
+ public:
+ explicit SecurityImageView(const LocationBarView* parent);
+ virtual ~SecurityImageView();
+
+ // Sets the image that should be displayed.
+ void SetSecurityIcon(int resource_id);
+
+ // Overridden from view.
+ virtual bool OnMousePressed(const views::MouseEvent& event);
+
+ private:
+ // The owning LocationBarView.
+ const LocationBarView* parent_;
+
+ DISALLOW_COPY_AND_ASSIGN(SecurityImageView);
+ };
+
// View used when the user has selected a keyword.
//
// SelectedKeywordView maintains two labels. One label contains the
@@ -279,95 +297,6 @@ class LocationBarView : public LocationBar,
DISALLOW_COPY_AND_ASSIGN(KeywordHintView);
};
- class ShowInfoBubbleTask;
- class ShowFirstRunBubbleTask;
-
- class LocationBarImageView : public views::ImageView,
- public InfoBubbleDelegate {
- public:
- explicit LocationBarImageView(const BubblePositioner* bubble_positioner);
- virtual ~LocationBarImageView();
-
- // Overridden from view for the mouse hovering.
- virtual void OnMouseMoved(const views::MouseEvent& event);
- virtual void OnMouseExited(const views::MouseEvent& event);
- virtual bool OnMousePressed(const views::MouseEvent& event) = 0;
-
- // InfoBubbleDelegate
- void InfoBubbleClosing(InfoBubble* info_bubble, bool closed_by_escape);
- bool CloseOnEscape() { return true; }
-
- virtual void ShowInfoBubble() = 0;
-
- protected:
- void ShowInfoBubbleImpl(const std::wstring& text, SkColor text_color);
-
- private:
- friend class ShowInfoBubbleTask;
-
- // The currently shown info bubble if any.
- InfoBubble* info_bubble_;
-
- // A task used to display the info bubble when the mouse hovers on the
- // image.
- ShowInfoBubbleTask* show_info_bubble_task_;
-
- // A positioner used to give the info bubble the correct target bounds. The
- // caller maintains ownership of this and must ensure it's kept alive.
- const BubblePositioner* bubble_positioner_;
-
- DISALLOW_COPY_AND_ASSIGN(LocationBarImageView);
- };
-
- // SecurityImageView is used to display the lock or warning icon when the
- // current URL's scheme is https.
- //
- // If a message has been set with SetInfoBubbleText, it displays an info
- // bubble when the mouse hovers on the image.
- class SecurityImageView : public LocationBarImageView {
- public:
- enum Image {
- LOCK = 0,
- WARNING
- };
-
- SecurityImageView(const LocationBarView* parent,
- Profile* profile,
- ToolbarModel* model_,
- const BubblePositioner* bubble_positioner);
- virtual ~SecurityImageView();
-
- // Sets the image that should be displayed.
- void SetImageShown(Image image);
-
- // Overridden from view for the mouse hovering.
- virtual bool OnMousePressed(const views::MouseEvent& event);
-
- void set_profile(Profile* profile) { profile_ = profile; }
-
- virtual void ShowInfoBubble();
-
- private:
- // The lock icon shown when using HTTPS.
- static SkBitmap* lock_icon_;
-
- // The warning icon shown when HTTPS is broken.
- static SkBitmap* warning_icon_;
-
- // A task used to display the info bubble when the mouse hovers on the
- // image.
- ShowInfoBubbleTask* show_info_bubble_task_;
-
- // The owning LocationBarView.
- const LocationBarView* parent_;
-
- Profile* profile_;
-
- ToolbarModel* model_;
-
- DISALLOW_COPY_AND_ASSIGN(SecurityImageView);
- };
-
class ContentSettingImageView : public views::ImageView,
public InfoBubbleDelegate {
public:
@@ -411,15 +340,14 @@ class LocationBarView : public LocationBar,
// PageActionImageView is used to display the icon for a given PageAction
// and notify the extension when the icon is clicked.
- class PageActionImageView : public LocationBarImageView,
+ class PageActionImageView : public views::ImageView,
public ImageLoadingTracker::Observer,
public ExtensionContextMenuModel::PopupDelegate,
public ExtensionPopup::Observer {
public:
PageActionImageView(LocationBarView* owner,
Profile* profile,
- ExtensionAction* page_action,
- const BubblePositioner* bubble_positioner);
+ ExtensionAction* page_action);
virtual ~PageActionImageView();
ExtensionAction* page_action() { return page_action_; }
@@ -431,13 +359,9 @@ class LocationBarView : public LocationBar,
}
// Overridden from view.
- virtual void OnMouseMoved(const views::MouseEvent& event);
virtual bool OnMousePressed(const views::MouseEvent& event);
virtual void OnMouseReleased(const views::MouseEvent& event, bool canceled);
- // Overridden from LocationBarImageView.
- virtual void ShowInfoBubble();
-
// Overridden from ImageLoadingTracker.
virtual void OnImageLoaded(
SkBitmap* image, ExtensionResource resource, int index);
@@ -531,10 +455,10 @@ class LocationBarView : public LocationBar,
// size.
bool NeedsResize(View* view, int available_width);
- // Adjusts the keyword hint, selected keyword and type to search views
- // based on the contents of the edit. Returns true if something changed that
- // necessitates a layout.
- bool AdjustHints(int available_width);
+ // Adjusts the keyword hint, selected keyword view, type to search label, and
+ // security info label based on the contents of the edit. Returns true if
+ // something changed that necessitates a layout.
+ bool AdjustAutocollapseViews(int available_width);
// If View fits in the specified region, it is made visible and the
// bounds are adjusted appropriately. If the View does not fit, it is
@@ -542,9 +466,6 @@ class LocationBarView : public LocationBar,
void LayoutView(bool leading, views::View* view, int available_width,
gfx::Rect* bounds);
- // Sets the security icon to display. Note that no repaint is done.
- void SetSecurityIcon(ToolbarModel::Icon icon);
-
// Update the visibility state of the Content Blocked icons to reflect what is
// actually blocked on the current page.
void RefreshContentSettingViews();
@@ -556,13 +477,6 @@ class LocationBarView : public LocationBar,
// PageActions.
void RefreshPageActionViews();
- // Sets the text that should be displayed in the info label and its associated
- // tooltip text. Call with an empty string if the info label should be
- // hidden.
- void SetInfoText(const std::wstring& text,
- ToolbarModel::InfoTextType text_type,
- const std::wstring& tooltip_text);
-
// Sets the visibility of view to new_vis. Returns whether the visibility
// changed.
bool ToggleVisibility(bool new_vis, views::View* view);
@@ -610,6 +524,9 @@ class LocationBarView : public LocationBar,
// Font used by edit and some of the hints.
gfx::Font font_;
+ // The view that shows the lock/warning when in HTTPS mode.
+ SecurityImageView security_image_view_;
+
// Location_entry view wrapper
views::NativeViewHost* location_entry_view_;
@@ -617,6 +534,8 @@ class LocationBarView : public LocationBar,
// what is going in the edit. They are all added a children of the
// LocationBarView. At most one is visible at a time. Preference is
// given to the keyword_view_, then hint_view_, then type_to_search_view_.
+ // These, as well as |security_info_label_|, autocollapse when the edit needs
+ // the room.
// Shown if the user has selected a keyword.
SelectedKeywordView selected_keyword_view_;
@@ -627,8 +546,9 @@ class LocationBarView : public LocationBar,
// Shown if the text is not a keyword or url.
views::Label type_to_search_view_;
- // The view that shows the lock/warning when in HTTPS mode.
- SecurityImageView security_image_view_;
+ // A label displayed on the right side of the box to show more information
+ // about certain security states.
+ views::Label security_info_label_;
// The content setting views.
ContentSettingViews content_setting_views_;
@@ -636,9 +556,6 @@ class LocationBarView : public LocationBar,
// The page action icon views.
PageActionViews page_action_views_;
- // A label displayed after the lock icon to show some extra information.
- views::Label info_label_;
-
// When true, the location bar view is read only and also is has a slightly
// different presentation (font size / color). This is used for popups.
bool popup_window_mode_;