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..cac429c34f81038a8dcd58289fa68ec35f3c8f9a 100644 |
--- a/chrome/browser/ui/views/location_bar/location_bar_view.cc |
+++ b/chrome/browser/ui/views/location_bar/location_bar_view.cc |
@@ -22,6 +22,7 @@ |
#include "chrome/browser/extensions/tab_helper.h" |
#include "chrome/browser/profiles/profile.h" |
#include "chrome/browser/search_engines/template_url_service_factory.h" |
+#include "chrome/browser/ssl/chrome_security_state_model_client.h" |
Peter Kasting
2016/08/18 06:24:37
Nit: I think none of these new #includes are neces
Kevin Bailey
2016/08/18 16:09:36
Done.
|
#include "chrome/browser/themes/theme_properties.h" |
#include "chrome/browser/translate/chrome_translate_client.h" |
#include "chrome/browser/translate/translate_service.h" |
@@ -63,8 +64,10 @@ |
#include "components/translate/core/browser/language_state.h" |
#include "components/zoom/zoom_controller.h" |
#include "components/zoom/zoom_event_manager.h" |
+#include "content/public/browser/navigation_entry.h" |
#include "content/public/browser/render_widget_host_view.h" |
#include "content/public/browser/web_contents.h" |
+#include "content/public/common/ssl_status.h" |
#include "extensions/browser/extension_registry.h" |
#include "extensions/common/feature_switch.h" |
#include "grit/components_scaled_resources.h" |
@@ -137,6 +140,7 @@ LocationBarView::LocationBarView(Browser* browser, |
size_animation_(this), |
is_popup_mode_(is_popup_mode), |
show_focus_rect_(false), |
+ showing_security_chip_(false), |
template_url_service_(NULL), |
web_contents_null_at_last_refresh_(true) { |
edit_bookmarks_enabled_.Init( |
@@ -326,10 +330,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 +362,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 +536,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 label = GetSecurityText(); |
Peter Kasting
2016/08/18 06:24:37
Nit: |security_text| might be a better name.
Kevin Bailey
2016/08/18 16:09:36
If you prefer. I think once we cross line 540, it'
|
+ leading_width += |
+ GetLayoutConstant(LOCATION_BAR_BUBBLE_HORIZONTAL_PADDING) + |
+ location_icon_view_->GetMinimumSizeForLabelText(label).width(); |
} else { |
leading_width += padding + location_icon_view_->GetMinimumSize().width(); |
} |
@@ -612,8 +616,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 +794,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 +806,16 @@ void LocationBarView::Update(const WebContents* contents) { |
else |
omnibox_view_->Update(); |
+ if (ShouldShowSecurityChip() != showing_security_chip_) { |
Peter Kasting
2016/08/18 06:24:37
If it is safe to rely on the animation calls being
Kevin Bailey
2016/08/18 16:09:36
Done, but it looks like this whole thing needs to
|
+ if (ShouldShowSecurityChip()) { |
+ showing_security_chip_ = true; |
+ location_icon_view_->StartAnimation(); |
+ } else { |
+ showing_security_chip_ = false; |
+ location_icon_view_->StopAnimation(); |
+ } |
+ } |
+ |
OnChanged(); // NOTE: Calls Layout(). |
} |
@@ -1038,6 +1052,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 +1067,20 @@ bool LocationBarView::ShouldShowEVBubble() const { |
security_state::SecurityStateModel::EV_SECURE); |
} |
+bool LocationBarView::ShouldShowSecurityChip() const { |
+ if (ShouldShowKeywordBubble()) |
+ return false; |
+ security_state::SecurityStateModel::SecurityLevel level = |
+ GetToolbarModel()->GetSecurityLevel(false); |
+ if (level == security_state::SecurityStateModel::SecurityLevel::EV_SECURE || |
Peter Kasting
2016/08/18 06:24:37
Nit: Could just
return level == ... ||
Kevin Bailey
2016/08/18 16:09:36
I can go as far as SecurityStateModel, so I don't
Peter Kasting
2016/08/20 01:16:43
Helps enough, probably. A type alias might get yo
Kevin Bailey
2016/08/22 15:58:56
Done.
|
+ level == security_state::SecurityStateModel::SecurityLevel::SECURE || |
+ level == |
+ security_state::SecurityStateModel::SecurityLevel::SECURITY_ERROR) { |
Peter Kasting
2016/08/18 06:24:37
What about SECURITY_WARNING and SECURITY_POLICY_WA
Kevin Bailey
2016/08/18 16:09:36
I asked spqchan why it wasn't handled in her CL an
|
+ return true; |
+ } |
+ return false; |
Peter Kasting
2016/08/18 06:24:37
Checking: Does the toolbar model return NONE any t
Kevin Bailey
2016/08/18 16:09:36
If the user starts editing after things have settl
Peter Kasting
2016/08/20 01:16:43
I don't understand this comment.
What does "prior
Kevin Bailey
2016/08/22 15:58:56
'omnibox_view_->IsEditingOrEmpty()' almost appears
Peter Kasting
2016/08/22 22:58:09
ToolbarModel::GetSecurityLevel()'s argument is cal
Kevin Bailey
2016/08/23 15:17:13
You should see my log. The omnibox_view_ goes from
Peter Kasting
2016/08/23 18:01:56
Since I don't know what you're looking at to deter
|
+} |
+ |
//////////////////////////////////////////////////////////////////////////////// |
// LocationBarView, private LocationBar implementation: |