Index: chrome/browser/ui/views/location_bar/location_bar_view.cc |
diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.cc b/chrome/browser/ui/views/location_bar/location_bar_view.cc |
index 7ffa3e9e7d73a16df4e74ffa17c4b9c1c0b02f7e..99876e4df91ac45c6b698f0aff3b46e0e222b8a8 100644 |
--- a/chrome/browser/ui/views/location_bar/location_bar_view.cc |
+++ b/chrome/browser/ui/views/location_bar/location_bar_view.cc |
@@ -138,7 +138,9 @@ LocationBarView::LocationBarView(Browser* browser, |
is_popup_mode_(is_popup_mode), |
show_focus_rect_(false), |
template_url_service_(NULL), |
- web_contents_null_at_last_refresh_(true) { |
+ web_contents_null_at_last_refresh_(true), |
+ previous_security_level_( |
+ security_state::SecurityStateModel::SecurityLevel::NONE) { |
edit_bookmarks_enabled_.Init( |
bookmarks::prefs::kEditBookmarksEnabled, profile->GetPrefs(), |
base::Bind(&LocationBarView::UpdateWithoutTabRestore, |
@@ -326,10 +328,10 @@ SkColor LocationBarView::GetColor( |
case DEEMPHASIZED_TEXT: |
return color_utils::AlphaBlend(GetColor(TEXT), GetColor(BACKGROUND), 128); |
- case EV_BUBBLE_TEXT_AND_BORDER: |
+ case SECURITY_CHIP_TEXT_AND_BORDER: |
return ui::MaterialDesignController::IsModeMaterial() |
? GetSecureTextColor( |
- security_state::SecurityStateModel::EV_SECURE) |
+ GetToolbarModel()->GetSecurityLevel(false)) |
: SkColorSetRGB(7, 149, 0); |
} |
NOTREACHED(); |
@@ -358,7 +360,7 @@ SkColor LocationBarView::GetSecureTextColor( |
security_state::SecurityStateModel::SECURITY_ERROR) { |
text_color = SkColorSetRGB(162, 0, 0); |
} else { |
- text_color = GetColor(EV_BUBBLE_TEXT_AND_BORDER); |
+ text_color = GetColor(SECURITY_CHIP_TEXT_AND_BORDER); |
} |
} |
return color_utils::GetReadableColor(text_color, GetColor(BACKGROUND)); |
@@ -532,11 +534,11 @@ gfx::Size LocationBarView::GetPreferredSize() const { |
int leading_width = edge_thickness; |
if (ShouldShowKeywordBubble()) { |
// The selected keyword view can collapse completely. |
- } else if (ShouldShowEVBubble()) { |
- leading_width += GetLayoutConstant(LOCATION_BAR_BUBBLE_HORIZONTAL_PADDING) + |
- location_icon_view_->GetMinimumSizeForLabelText( |
- GetToolbarModel()->GetEVCertName()) |
- .width(); |
+ } else if (ShouldShowSecurityChip()) { |
+ base::string16 security_text = GetSecurityText(); |
+ leading_width += |
+ GetLayoutConstant(LOCATION_BAR_BUBBLE_HORIZONTAL_PADDING) + |
+ location_icon_view_->GetMinimumSizeForLabelText(security_text).width(); |
} else { |
leading_width += padding + location_icon_view_->GetMinimumSize().width(); |
} |
@@ -612,8 +614,8 @@ void LocationBarView::Layout() { |
selected_keyword_view_->set_is_extension_icon(false); |
} |
} |
- } else if (ShouldShowEVBubble()) { |
- location_icon_view_->SetLabel(GetToolbarModel()->GetEVCertName()); |
+ } else if (ShouldShowSecurityChip()) { |
+ location_icon_view_->SetLabel(GetSecurityText()); |
location_icon_view_->SetBackground(true); |
// The largest fraction of the omnibox that can be taken by the EV bubble. |
const double kMaxBubbleFraction = 0.5; |
@@ -790,7 +792,7 @@ void LocationBarView::Update(const WebContents* contents) { |
RefreshTranslateIcon(); |
RefreshSaveCreditCardIconView(); |
RefreshManagePasswordsIconView(); |
- content::WebContents* web_contents_for_sub_views = |
+ WebContents* web_contents_for_sub_views = |
GetToolbarModel()->input_in_progress() ? nullptr : GetWebContents(); |
open_pdf_in_reader_view_->Update(web_contents_for_sub_views); |
@@ -802,6 +804,22 @@ void LocationBarView::Update(const WebContents* contents) { |
else |
omnibox_view_->Update(); |
+ if (ShouldShowSecurityChip()) { |
+ security_state::SecurityStateModel::SecurityLevel level = |
+ GetToolbarModel()->GetSecurityLevel(false); |
+ if (level == security_state::SecurityStateModel::SecurityLevel::EV_SECURE) |
+ level = security_state::SecurityStateModel::SecurityLevel::SECURE; |
+ if (previous_security_level_ != level) { |
+ previous_security_level_ = level; |
+ location_icon_view_->AnimateSecurityChip(); |
+ } else if (!location_icon_view_->IsAnimatingSecurityChip()) { |
+ location_icon_view_->ShowSecurityChip(); |
+ } |
Peter Kasting
2016/08/20 01:16:43
I don't understand why this whole complicated bloc
Kevin Bailey
2016/08/22 15:58:56
Correct. I assumed that you saw this in:
coderevi
Peter Kasting
2016/08/22 22:58:09
I left a similar comment there. THanks for pointi
Kevin Bailey
2016/08/23 15:17:13
When the user presses back arrow or forwards, cont
Peter Kasting
2016/08/23 18:01:57
Yes, because that's an update to the state of the
Kevin Bailey
2016/08/23 20:01:39
I'm not sure who "we" is, but LocationBarView::Upd
Peter Kasting
2016/08/23 20:11:00
You always tell the icon to animate (or snap, if t
Kevin Bailey
2016/08/23 20:39:25
The UI designers want it such that, if you go from
Peter Kasting
2016/08/23 20:42:20
I'm confused. That's what you should get with my
groby-ooo-7-16
2016/08/23 22:11:15
I think the confusion here stems from a previous c
Peter Kasting
2016/08/23 22:17:18
No. We don't need to track the previous level. I
groby-ooo-7-16
2016/08/23 23:12:40
Thank you for clarifying that! That does cover the
Peter Kasting
2016/08/23 23:19:15
OK, that contradicts Kevin's earlier comment.
I w
|
+ } else { |
+ previous_security_level_ = GetToolbarModel()->GetSecurityLevel(false); |
+ location_icon_view_->HideSecurityChip(); |
+ } |
+ |
OnChanged(); // NOTE: Calls Layout(). |
} |
@@ -1038,6 +1056,11 @@ bool LocationBarView::HasValidSuggestText() const { |
!suggested_text_view_->size().IsEmpty(); |
} |
+base::string16 LocationBarView::GetSecurityText() const { |
+ return ShouldShowEVBubble() ? GetToolbarModel()->GetEVCertName() |
+ : GetToolbarModel()->GetSecureVerboseText(); |
+} |
+ |
bool LocationBarView::ShouldShowKeywordBubble() const { |
return !omnibox_view_->model()->keyword().empty() && |
!omnibox_view_->model()->is_keyword_hint(); |
@@ -1048,6 +1071,17 @@ bool LocationBarView::ShouldShowEVBubble() const { |
security_state::SecurityStateModel::EV_SECURE); |
} |
+bool LocationBarView::ShouldShowSecurityChip() const { |
+ if (ShouldShowKeywordBubble()) |
+ return false; |
+ using security_state::SecurityStateModel; |
+ SecurityStateModel::SecurityLevel level = |
+ GetToolbarModel()->GetSecurityLevel(false); |
+ return level == SecurityStateModel::SecurityLevel::SECURE || |
+ level == SecurityStateModel::SecurityLevel::EV_SECURE || |
+ level == SecurityStateModel::SecurityLevel::SECURITY_ERROR; |
+} |
+ |
//////////////////////////////////////////////////////////////////////////////// |
// LocationBarView, private LocationBar implementation: |