Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 5 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 133 open_pdf_in_reader_view_(nullptr), | 133 open_pdf_in_reader_view_(nullptr), |
| 134 manage_passwords_icon_view_(nullptr), | 134 manage_passwords_icon_view_(nullptr), |
| 135 save_credit_card_icon_view_(nullptr), | 135 save_credit_card_icon_view_(nullptr), |
| 136 translate_icon_view_(nullptr), | 136 translate_icon_view_(nullptr), |
| 137 star_view_(nullptr), | 137 star_view_(nullptr), |
| 138 size_animation_(this), | 138 size_animation_(this), |
| 139 is_popup_mode_(is_popup_mode), | 139 is_popup_mode_(is_popup_mode), |
| 140 show_focus_rect_(false), | 140 show_focus_rect_(false), |
| 141 template_url_service_(NULL), | 141 template_url_service_(NULL), |
| 142 web_contents_null_at_last_refresh_(true), | 142 web_contents_null_at_last_refresh_(true), |
| 143 should_show_secure_state_(true), | 143 should_show_secure_state_(false), |
| 144 should_show_nonsecure_state_(false), | |
| 144 should_animate_secure_state_(false), | 145 should_animate_secure_state_(false), |
| 145 should_animate_nonsecure_state_(false) { | 146 should_animate_nonsecure_state_(false) { |
| 146 edit_bookmarks_enabled_.Init( | 147 edit_bookmarks_enabled_.Init( |
| 147 bookmarks::prefs::kEditBookmarksEnabled, profile->GetPrefs(), | 148 bookmarks::prefs::kEditBookmarksEnabled, profile->GetPrefs(), |
| 148 base::Bind(&LocationBarView::UpdateWithoutTabRestore, | 149 base::Bind(&LocationBarView::UpdateWithoutTabRestore, |
| 149 base::Unretained(this))); | 150 base::Unretained(this))); |
| 150 | 151 |
| 151 zoom::ZoomEventManager::GetForBrowserContext(profile) | 152 zoom::ZoomEventManager::GetForBrowserContext(profile) |
| 152 ->AddZoomEventManagerObserver(this); | 153 ->AddZoomEventManagerObserver(this); |
| 153 | 154 |
| 154 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 155 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 155 if (command_line->HasSwitch(switches::kSecurityChip)) { | 156 if (command_line->HasSwitch(switches::kSecurityChip)) { |
| 156 std::string security_chip_flag = | 157 std::string security_chip_flag = |
| 157 command_line->GetSwitchValueASCII(switches::kSecurityChip); | 158 command_line->GetSwitchValueASCII(switches::kSecurityChip); |
| 158 should_show_secure_state_ = | 159 should_show_secure_state_ = |
| 159 security_chip_flag == switches::kSecurityChipShowAll; | 160 security_chip_flag == switches::kSecurityChipShowAll; |
| 161 should_show_nonsecure_state_ = | |
| 162 security_chip_flag == switches::kSecurityChipShowAll || | |
| 163 security_chip_flag == switches::kSecurityChipShowNonSecureOnly; | |
| 160 } | 164 } |
| 161 | 165 |
| 162 if (command_line->HasSwitch(switches::kSecurityChipAnimation)) { | 166 if (command_line->HasSwitch(switches::kSecurityChipAnimation)) { |
| 163 std::string security_chip_animation_flag = | 167 std::string security_chip_animation_flag = |
| 164 command_line->GetSwitchValueASCII(switches::kSecurityChipAnimation); | 168 command_line->GetSwitchValueASCII(switches::kSecurityChipAnimation); |
| 165 should_animate_secure_state_ = | 169 should_animate_secure_state_ = |
| 166 security_chip_animation_flag == switches::kSecurityChipAnimationAll; | 170 security_chip_animation_flag == switches::kSecurityChipAnimationAll; |
| 167 | 171 |
| 168 should_animate_nonsecure_state_ = | 172 should_animate_nonsecure_state_ = |
| 169 security_chip_animation_flag == | 173 security_chip_animation_flag == |
| (...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1002 : GetToolbarModel()->GetSecureVerboseText(); | 1006 : GetToolbarModel()->GetSecureVerboseText(); |
| 1003 } | 1007 } |
| 1004 | 1008 |
| 1005 bool LocationBarView::ShouldShowKeywordBubble() const { | 1009 bool LocationBarView::ShouldShowKeywordBubble() const { |
| 1006 return !omnibox_view_->model()->keyword().empty() && | 1010 return !omnibox_view_->model()->keyword().empty() && |
| 1007 !omnibox_view_->model()->is_keyword_hint(); | 1011 !omnibox_view_->model()->is_keyword_hint(); |
| 1008 } | 1012 } |
| 1009 | 1013 |
| 1010 bool LocationBarView::ShouldShowEVBubble() const { | 1014 bool LocationBarView::ShouldShowEVBubble() const { |
| 1011 return (GetToolbarModel()->GetSecurityLevel(false) == | 1015 return (GetToolbarModel()->GetSecurityLevel(false) == |
| 1012 security_state::SecurityStateModel::EV_SECURE) && | 1016 security_state::SecurityStateModel::EV_SECURE); |
|
Peter Kasting
2016/10/19 18:02:36
Nit: This function is only called in one place, an
spqchan
2016/10/19 19:03:50
Done.
| |
| 1013 should_show_secure_state_; | |
| 1014 } | 1017 } |
| 1015 | 1018 |
| 1016 bool LocationBarView::ShouldShowSecurityChip() const { | 1019 bool LocationBarView::ShouldShowSecurityChip() const { |
| 1017 using SecurityLevel = security_state::SecurityStateModel::SecurityLevel; | 1020 using SecurityLevel = security_state::SecurityStateModel::SecurityLevel; |
| 1018 const SecurityLevel level = GetToolbarModel()->GetSecurityLevel(false); | 1021 const SecurityLevel level = GetToolbarModel()->GetSecurityLevel(false); |
| 1019 if (level == SecurityLevel::SECURE || level == SecurityLevel::EV_SECURE) | 1022 if (level == SecurityLevel::SECURE) |
| 1020 return should_show_secure_state_; | 1023 return should_show_secure_state_; |
| 1021 return level == SecurityLevel::DANGEROUS || | 1024 else if (level == SecurityLevel::EV_SECURE) |
|
Peter Kasting
2016/10/19 18:02:36
Nit: No else after return
Trivial, but I'd swap t
spqchan
2016/10/19 19:03:50
Done.
| |
| 1022 level == SecurityLevel::HTTP_SHOW_WARNING; | 1025 return true; |
| 1026 return should_show_nonsecure_state_ && | |
| 1027 (level == SecurityLevel::DANGEROUS || | |
| 1028 level == SecurityLevel::HTTP_SHOW_WARNING); | |
| 1023 } | 1029 } |
| 1024 | 1030 |
| 1025 bool LocationBarView::ShouldAnimateSecurityChip() const { | 1031 bool LocationBarView::ShouldAnimateSecurityChip() const { |
| 1026 using SecurityLevel = security_state::SecurityStateModel::SecurityLevel; | 1032 using SecurityLevel = security_state::SecurityStateModel::SecurityLevel; |
| 1027 SecurityLevel level = GetToolbarModel()->GetSecurityLevel(false); | 1033 SecurityLevel level = GetToolbarModel()->GetSecurityLevel(false); |
| 1028 if (!ShouldShowSecurityChip()) | 1034 if (!ShouldShowSecurityChip()) |
| 1029 return false; | 1035 return false; |
| 1030 if (level == SecurityLevel::SECURE || level == SecurityLevel::EV_SECURE) | 1036 if (level == SecurityLevel::SECURE || level == SecurityLevel::EV_SECURE) |
| 1031 return should_animate_secure_state_; | 1037 return should_animate_secure_state_; |
| 1032 return should_animate_nonsecure_state_ && | 1038 return should_animate_nonsecure_state_ && |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1342 // LocationBarView, private TemplateURLServiceObserver implementation: | 1348 // LocationBarView, private TemplateURLServiceObserver implementation: |
| 1343 | 1349 |
| 1344 void LocationBarView::OnTemplateURLServiceChanged() { | 1350 void LocationBarView::OnTemplateURLServiceChanged() { |
| 1345 template_url_service_->RemoveObserver(this); | 1351 template_url_service_->RemoveObserver(this); |
| 1346 template_url_service_ = nullptr; | 1352 template_url_service_ = nullptr; |
| 1347 // If the browser is no longer active, let's not show the info bubble, as this | 1353 // If the browser is no longer active, let's not show the info bubble, as this |
| 1348 // would make the browser the active window again. | 1354 // would make the browser the active window again. |
| 1349 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive()) | 1355 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive()) |
| 1350 ShowFirstRunBubble(); | 1356 ShowFirstRunBubble(); |
| 1351 } | 1357 } |
| OLD | NEW |