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

Unified Diff: chrome/browser/ui/views/location_bar/location_bar_view.cc

Issue 2555063003: Render extension URLs with chips (Closed)
Patch Set: pkasting comments and rebase Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 fea33253023b616ba69c29bbdbb355669ec27959..9f2cf90bef5b18052e40aa24db412efcedc36506 100644
--- a/chrome/browser/ui/views/location_bar/location_bar_view.cc
+++ b/chrome/browser/ui/views/location_bar/location_bar_view.cc
@@ -456,8 +456,9 @@ gfx::Size LocationBarView::GetPreferredSize() const {
int leading_width = edge_thickness;
if (ShouldShowKeywordBubble()) {
// The selected keyword view can collapse completely.
- } else if (ShouldShowSecurityChip()) {
- base::string16 security_text = GetSecurityText();
+ } else if (ShouldShowSecurityText()) {
+ const base::string16 security_text = GetSecurityText(
+ GetToolbarModel()->GetURL(), delegate_->GetWebContents());
leading_width +=
location_icon_view_->GetMinimumSizeForLabelText(security_text).width();
} else {
@@ -530,8 +531,10 @@ void LocationBarView::Layout() {
selected_keyword_view_->ResetImage();
}
}
- } else if (ShouldShowSecurityChip()) {
- location_icon_view_->SetLabel(GetSecurityText());
+ } else if (ShouldShowSecurityText()) {
+ const base::string16 security_text = GetSecurityText(
+ GetToolbarModel()->GetURL(), delegate_->GetWebContents());
+ location_icon_view_->SetLabel(security_text);
// The largest fraction of the omnibox that can be taken by the EV bubble.
const double kMaxBubbleFraction = 0.5;
leading_decorations.AddDecoration(vertical_padding, location_height, false,
@@ -660,9 +663,8 @@ void LocationBarView::Update(const WebContents* contents) {
else
omnibox_view_->Update();
- location_icon_view_->SetSecurityState(
- ShouldShowSecurityChip(), !contents && ShouldAnimateSecurityChip());
-
+ location_icon_view_->SetTextVisibility(
+ ShouldShowSecurityText(), !contents && ShouldAnimateSecurityText());
OnChanged(); // NOTE: Calls Layout().
}
@@ -879,7 +881,12 @@ void LocationBarView::ShowFirstRunBubbleInternal() {
#endif
}
-base::string16 LocationBarView::GetSecurityText() const {
+base::string16 LocationBarView::GetSecurityText(const GURL& url,
+ WebContents* contents) const {
+ base::string16 extension_name = GetExtensionName(url, contents);
+ if (!extension_name.empty())
+ return extension_name;
+
bool has_ev_cert =
(GetToolbarModel()->GetSecurityLevel(false) == security_state::EV_SECURE);
return has_ev_cert ? GetToolbarModel()->GetEVCertName()
@@ -891,7 +898,10 @@ bool LocationBarView::ShouldShowKeywordBubble() const {
!omnibox_view_->model()->is_keyword_hint();
}
-bool LocationBarView::ShouldShowSecurityChip() const {
+bool LocationBarView::ShouldShowSecurityText() const {
+ if (GetToolbarModel()->GetURL().SchemeIs(extensions::kExtensionScheme))
+ return true;
+
using SecurityLevel = security_state::SecurityLevel;
const SecurityLevel level = GetToolbarModel()->GetSecurityLevel(false);
return level == SecurityLevel::EV_SECURE || level == SecurityLevel::SECURE ||
@@ -899,7 +909,7 @@ bool LocationBarView::ShouldShowSecurityChip() const {
level == SecurityLevel::HTTP_SHOW_WARNING;
}
-bool LocationBarView::ShouldAnimateSecurityChip() const {
+bool LocationBarView::ShouldAnimateSecurityText() const {
using SecurityLevel = security_state::SecurityLevel;
SecurityLevel level = GetToolbarModel()->GetSecurityLevel(false);
return level == SecurityLevel::DANGEROUS ||

Powered by Google App Engine
This is Rietveld 408576698