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

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

Issue 2378623007: [Material] Update Material Security Verbose Decoration Flag (Closed)
Patch Set: fixed an animation error on cocoa Created 4 years, 2 months 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 6196e8e18045cd2f9aa25fb5f045366cf87c6dfd..1d3501ef8faf2ecfd6f027df38ceba27becba973 100644
--- a/chrome/browser/ui/views/location_bar/location_bar_view.cc
+++ b/chrome/browser/ui/views/location_bar/location_bar_view.cc
@@ -141,7 +141,8 @@ LocationBarView::LocationBarView(Browser* browser,
template_url_service_(NULL),
web_contents_null_at_last_refresh_(true),
should_show_secure_state_(true),
- should_animate_secure_state_(true) {
+ should_animate_secure_state_(false),
+ should_animate_nonsecure_state_(false) {
edit_bookmarks_enabled_.Init(
bookmarks::prefs::kEditBookmarksEnabled, profile->GetPrefs(),
base::Bind(&LocationBarView::UpdateWithoutTabRestore,
@@ -151,21 +152,31 @@ LocationBarView::LocationBarView(Browser* browser,
->AddZoomEventManagerObserver(this);
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
- if (command_line->HasSwitch(switches::kMaterialSecurityVerbose)) {
+ if (command_line->HasSwitch(switches::kSecurityVerboseDecoration)) {
std::string security_verbose_flag =
- command_line->GetSwitchValueASCII(switches::kMaterialSecurityVerbose);
+ command_line->GetSwitchValueASCII(switches::kSecurityVerboseDecoration);
should_show_secure_state_ =
security_verbose_flag ==
- switches::kMaterialSecurityVerboseShowAllAnimated ||
+ switches::kSecurityVerboseDecorationShowAllAnimated ||
security_verbose_flag ==
- switches::kMaterialSecurityVerboseShowAllNonAnimated;
+ switches::kSecurityVerboseDecorationShowAllNonAnimated ||
+ security_verbose_flag ==
+ switches::
+ kSecurityVerboseDecorationShowAllWithOnlyNonSecureAnimated;
should_animate_secure_state_ =
security_verbose_flag ==
- switches::kMaterialSecurityVerboseShowAllAnimated ||
+ switches::kSecurityVerboseDecorationShowAllAnimated;
+
+ should_animate_nonsecure_state_ =
+ security_verbose_flag ==
+ switches::kSecurityVerboseDecorationShowAllAnimated ||
+ security_verbose_flag ==
+ switches::kSecurityVerboseDecorationShowNonSecureAnimated ||
security_verbose_flag ==
- switches::kMaterialSecurityVerboseShowNonSecureAnimated;
+ switches::
+ kSecurityVerboseDecorationShowAllWithOnlyNonSecureAnimated;
}
}
@@ -506,7 +517,7 @@ gfx::Size LocationBarView::GetPreferredSize() const {
int leading_width = edge_thickness;
if (ShouldShowKeywordBubble()) {
// The selected keyword view can collapse completely.
- } else if (ShouldShowSecurityChip()) {
+ } else if (ShouldShowSecurityChip(nullptr)) {
base::string16 security_text = GetSecurityText();
leading_width +=
GetLayoutConstant(LOCATION_BAR_BUBBLE_HORIZONTAL_PADDING) +
@@ -583,7 +594,7 @@ void LocationBarView::Layout() {
selected_keyword_view_->ResetImage();
}
}
- } else if (ShouldShowSecurityChip()) {
+ } else if (ShouldShowSecurityChip(nullptr)) {
location_icon_view_->SetLabel(GetSecurityText());
// The largest fraction of the omnibox that can be taken by the EV bubble.
const double kMaxBubbleFraction = 0.5;
@@ -770,9 +781,10 @@ void LocationBarView::Update(const WebContents* contents) {
else
omnibox_view_->Update();
- bool should_show = ShouldShowSecurityChip();
- location_icon_view_->SetSecurityState(
- should_show, should_show && !contents && should_animate_secure_state_);
+ bool should_animate;
+ bool should_show = ShouldShowSecurityChip(&should_animate);
+ location_icon_view_->SetSecurityState(should_show,
+ !contents && should_animate);
OnChanged(); // NOTE: Calls Layout().
}
@@ -1010,13 +1022,25 @@ bool LocationBarView::ShouldShowEVBubble() const {
should_show_secure_state_;
}
-bool LocationBarView::ShouldShowSecurityChip() const {
+bool LocationBarView::ShouldShowSecurityChip(bool* should_animate) const {
using SecurityLevel = security_state::SecurityStateModel::SecurityLevel;
SecurityLevel level = GetToolbarModel()->GetSecurityLevel(false);
- return ((level == SecurityLevel::SECURE ||
- level == SecurityLevel::EV_SECURE) &&
- should_show_secure_state_) ||
- level == SecurityLevel::DANGEROUS;
+
+ bool should_show =
+ ((level == SecurityLevel::SECURE || level == SecurityLevel::EV_SECURE) &&
+ should_show_secure_state_) ||
+ level == SecurityLevel::DANGEROUS;
+
+ if (should_animate) {
+ bool is_secure_level =
+ level == SecurityLevel::EV_SECURE || level == SecurityLevel::SECURE;
+ *should_animate =
+ should_show && ((level == SecurityLevel::DANGEROUS &&
+ should_animate_nonsecure_state_) ||
+ (is_secure_level && should_animate_secure_state_));
+ }
+
+ return should_show;
}
////////////////////////////////////////////////////////////////////////////////

Powered by Google App Engine
This is Rietveld 408576698