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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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_(true), |
| 144 should_animate_secure_state_(true) { | 144 should_animate_secure_state_(false), |
| 145 should_animate_nonsecure_state_(false) { | |
| 145 edit_bookmarks_enabled_.Init( | 146 edit_bookmarks_enabled_.Init( |
| 146 bookmarks::prefs::kEditBookmarksEnabled, profile->GetPrefs(), | 147 bookmarks::prefs::kEditBookmarksEnabled, profile->GetPrefs(), |
| 147 base::Bind(&LocationBarView::UpdateWithoutTabRestore, | 148 base::Bind(&LocationBarView::UpdateWithoutTabRestore, |
| 148 base::Unretained(this))); | 149 base::Unretained(this))); |
| 149 | 150 |
| 150 zoom::ZoomEventManager::GetForBrowserContext(profile) | 151 zoom::ZoomEventManager::GetForBrowserContext(profile) |
| 151 ->AddZoomEventManagerObserver(this); | 152 ->AddZoomEventManagerObserver(this); |
| 152 | 153 |
| 153 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 154 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 154 if (command_line->HasSwitch(switches::kMaterialSecurityVerbose)) { | 155 if (command_line->HasSwitch(switches::kSecurityChip)) { |
| 155 std::string security_verbose_flag = | 156 std::string security_chip_flag = |
| 156 command_line->GetSwitchValueASCII(switches::kMaterialSecurityVerbose); | 157 command_line->GetSwitchValueASCII(switches::kSecurityChip); |
| 158 should_show_secure_state_ = | |
| 159 security_chip_flag == switches::kSecurityChipShowAll; | |
| 160 } | |
| 157 | 161 |
| 158 should_show_secure_state_ = | 162 if (command_line->HasSwitch(switches::kSecurityChipAnimation)) { |
| 159 security_verbose_flag == | 163 std::string security_chip_animation_flag = |
| 160 switches::kMaterialSecurityVerboseShowAllAnimated || | 164 command_line->GetSwitchValueASCII(switches::kSecurityChipAnimation); |
| 161 security_verbose_flag == | 165 should_animate_secure_state_ = |
| 162 switches::kMaterialSecurityVerboseShowAllNonAnimated; | 166 security_chip_animation_flag == switches::kSecurityChipAnimationAll; |
| 163 | 167 |
| 164 should_animate_secure_state_ = | 168 should_animate_nonsecure_state_ = |
| 165 security_verbose_flag == | 169 security_chip_animation_flag == |
| 166 switches::kMaterialSecurityVerboseShowAllAnimated || | 170 switches::kSecurityChipAnimationNonSecureOnly || |
| 167 security_verbose_flag == | 171 security_chip_animation_flag == switches::kSecurityChipAnimationAll; |
| 168 switches::kMaterialSecurityVerboseShowNonSecureAnimated; | |
| 169 } | 172 } |
| 170 } | 173 } |
| 171 | 174 |
| 172 LocationBarView::~LocationBarView() { | 175 LocationBarView::~LocationBarView() { |
| 173 if (template_url_service_) | 176 if (template_url_service_) |
| 174 template_url_service_->RemoveObserver(this); | 177 template_url_service_->RemoveObserver(this); |
| 175 | 178 |
| 176 zoom::ZoomEventManager::GetForBrowserContext(profile()) | 179 zoom::ZoomEventManager::GetForBrowserContext(profile()) |
| 177 ->RemoveZoomEventManagerObserver(this); | 180 ->RemoveZoomEventManagerObserver(this); |
| 178 } | 181 } |
| (...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 763 open_pdf_in_reader_view_->Update(web_contents_for_sub_views); | 766 open_pdf_in_reader_view_->Update(web_contents_for_sub_views); |
| 764 | 767 |
| 765 if (star_view_) | 768 if (star_view_) |
| 766 UpdateBookmarkStarVisibility(); | 769 UpdateBookmarkStarVisibility(); |
| 767 | 770 |
| 768 if (contents) | 771 if (contents) |
| 769 omnibox_view_->OnTabChanged(contents); | 772 omnibox_view_->OnTabChanged(contents); |
| 770 else | 773 else |
| 771 omnibox_view_->Update(); | 774 omnibox_view_->Update(); |
| 772 | 775 |
| 773 bool should_show = ShouldShowSecurityChip(); | |
| 774 location_icon_view_->SetSecurityState( | 776 location_icon_view_->SetSecurityState( |
| 775 should_show, should_show && !contents && should_animate_secure_state_); | 777 ShouldShowSecurityChip(), !contents && ShouldAnimateSecurityChip()); |
| 776 | 778 |
| 777 OnChanged(); // NOTE: Calls Layout(). | 779 OnChanged(); // NOTE: Calls Layout(). |
| 778 } | 780 } |
| 779 | 781 |
| 780 void LocationBarView::ResetTabState(WebContents* contents) { | 782 void LocationBarView::ResetTabState(WebContents* contents) { |
| 781 omnibox_view_->ResetTabState(contents); | 783 omnibox_view_->ResetTabState(contents); |
| 782 } | 784 } |
| 783 | 785 |
| 784 //////////////////////////////////////////////////////////////////////////////// | 786 //////////////////////////////////////////////////////////////////////////////// |
| 785 // LocationBarView, public OmniboxEditController implementation: | 787 // LocationBarView, public OmniboxEditController implementation: |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1006 | 1008 |
| 1007 bool LocationBarView::ShouldShowEVBubble() const { | 1009 bool LocationBarView::ShouldShowEVBubble() const { |
| 1008 return (GetToolbarModel()->GetSecurityLevel(false) == | 1010 return (GetToolbarModel()->GetSecurityLevel(false) == |
| 1009 security_state::SecurityStateModel::EV_SECURE) && | 1011 security_state::SecurityStateModel::EV_SECURE) && |
| 1010 should_show_secure_state_; | 1012 should_show_secure_state_; |
| 1011 } | 1013 } |
| 1012 | 1014 |
| 1013 bool LocationBarView::ShouldShowSecurityChip() const { | 1015 bool LocationBarView::ShouldShowSecurityChip() const { |
| 1014 using SecurityLevel = security_state::SecurityStateModel::SecurityLevel; | 1016 using SecurityLevel = security_state::SecurityStateModel::SecurityLevel; |
| 1015 SecurityLevel level = GetToolbarModel()->GetSecurityLevel(false); | 1017 SecurityLevel level = GetToolbarModel()->GetSecurityLevel(false); |
| 1018 | |
|
Peter Kasting
2016/10/11 22:14:50
Nit: Any particular reason you added this blank li
spqchan
2016/10/12 20:25:48
Whoops, removed
| |
| 1016 return ((level == SecurityLevel::SECURE || | 1019 return ((level == SecurityLevel::SECURE || |
| 1017 level == SecurityLevel::EV_SECURE) && | 1020 level == SecurityLevel::EV_SECURE) && |
| 1018 should_show_secure_state_) || | 1021 should_show_secure_state_) || |
| 1019 level == SecurityLevel::DANGEROUS; | 1022 level == SecurityLevel::DANGEROUS; |
| 1020 } | 1023 } |
| 1021 | 1024 |
| 1025 bool LocationBarView::ShouldAnimateSecurityChip() const { | |
| 1026 using SecurityLevel = security_state::SecurityStateModel::SecurityLevel; | |
| 1027 SecurityLevel level = GetToolbarModel()->GetSecurityLevel(false); | |
| 1028 bool is_secure_level = | |
| 1029 level == SecurityLevel::EV_SECURE || level == SecurityLevel::SECURE; | |
| 1030 return ShouldShowSecurityChip() && | |
| 1031 ((level == SecurityLevel::DANGEROUS && | |
| 1032 should_animate_nonsecure_state_) || | |
| 1033 (is_secure_level && should_animate_secure_state_)); | |
| 1034 } | |
| 1035 | |
| 1022 //////////////////////////////////////////////////////////////////////////////// | 1036 //////////////////////////////////////////////////////////////////////////////// |
| 1023 // LocationBarView, private LocationBar implementation: | 1037 // LocationBarView, private LocationBar implementation: |
| 1024 | 1038 |
| 1025 void LocationBarView::ShowFirstRunBubble() { | 1039 void LocationBarView::ShowFirstRunBubble() { |
| 1026 // Wait until search engines have loaded to show the first run bubble. | 1040 // Wait until search engines have loaded to show the first run bubble. |
| 1027 TemplateURLService* url_service = | 1041 TemplateURLService* url_service = |
| 1028 TemplateURLServiceFactory::GetForProfile(profile()); | 1042 TemplateURLServiceFactory::GetForProfile(profile()); |
| 1029 if (!url_service->loaded()) { | 1043 if (!url_service->loaded()) { |
| 1030 template_url_service_ = url_service; | 1044 template_url_service_ = url_service; |
| 1031 template_url_service_->AddObserver(this); | 1045 template_url_service_->AddObserver(this); |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1327 // LocationBarView, private TemplateURLServiceObserver implementation: | 1341 // LocationBarView, private TemplateURLServiceObserver implementation: |
| 1328 | 1342 |
| 1329 void LocationBarView::OnTemplateURLServiceChanged() { | 1343 void LocationBarView::OnTemplateURLServiceChanged() { |
| 1330 template_url_service_->RemoveObserver(this); | 1344 template_url_service_->RemoveObserver(this); |
| 1331 template_url_service_ = nullptr; | 1345 template_url_service_ = nullptr; |
| 1332 // If the browser is no longer active, let's not show the info bubble, as this | 1346 // If the browser is no longer active, let's not show the info bubble, as this |
| 1333 // would make the browser the active window again. | 1347 // would make the browser the active window again. |
| 1334 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive()) | 1348 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive()) |
| 1335 ShowFirstRunBubble(); | 1349 ShowFirstRunBubble(); |
| 1336 } | 1350 } |
| OLD | NEW |