| 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_animate_secure_state_(true) { | 144 should_show_nonsecure_state_(false), |
| 145 should_animate_secure_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::kMaterialSecurityVerbose)) { |
| 155 std::string security_verbose_flag = | 156 std::string security_verbose_flag = |
| 156 command_line->GetSwitchValueASCII(switches::kMaterialSecurityVerbose); | 157 command_line->GetSwitchValueASCII(switches::kMaterialSecurityVerbose); |
| 157 | 158 should_show_nonsecure_state_ = true; |
| 158 should_show_secure_state_ = | 159 should_show_secure_state_ = |
| 159 security_verbose_flag == | 160 security_verbose_flag == |
| 160 switches::kMaterialSecurityVerboseShowAllAnimated || | 161 switches::kMaterialSecurityVerboseShowAllAnimated || |
| 161 security_verbose_flag == | 162 security_verbose_flag == |
| 162 switches::kMaterialSecurityVerboseShowAllNonAnimated; | 163 switches::kMaterialSecurityVerboseShowAllNonAnimated; |
| 163 | |
| 164 should_animate_secure_state_ = | 164 should_animate_secure_state_ = |
| 165 security_verbose_flag == | 165 security_verbose_flag == |
| 166 switches::kMaterialSecurityVerboseShowAllAnimated || | 166 switches::kMaterialSecurityVerboseShowAllAnimated || |
| 167 security_verbose_flag == | 167 security_verbose_flag == |
| 168 switches::kMaterialSecurityVerboseShowNonSecureAnimated; | 168 switches::kMaterialSecurityVerboseShowNonSecureAnimated; |
| 169 } | 169 } |
| 170 } | 170 } |
| 171 | 171 |
| 172 LocationBarView::~LocationBarView() { | 172 LocationBarView::~LocationBarView() { |
| 173 if (template_url_service_) | 173 if (template_url_service_) |
| (...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 988 FirstRunBubble::ShowBubble(browser, location_icon_view_); | 988 FirstRunBubble::ShowBubble(browser, location_icon_view_); |
| 989 #endif | 989 #endif |
| 990 } | 990 } |
| 991 | 991 |
| 992 bool LocationBarView::HasValidSuggestText() const { | 992 bool LocationBarView::HasValidSuggestText() const { |
| 993 return suggested_text_view_->visible() && | 993 return suggested_text_view_->visible() && |
| 994 !suggested_text_view_->size().IsEmpty(); | 994 !suggested_text_view_->size().IsEmpty(); |
| 995 } | 995 } |
| 996 | 996 |
| 997 base::string16 LocationBarView::GetSecurityText() const { | 997 base::string16 LocationBarView::GetSecurityText() const { |
| 998 return ShouldShowEVBubble() ? GetToolbarModel()->GetEVCertName() | 998 bool has_ev_cert = (GetToolbarModel()->GetSecurityLevel(false) == |
| 999 : GetToolbarModel()->GetSecureVerboseText(); | 999 security_state::SecurityStateModel::EV_SECURE); |
| 1000 return has_ev_cert ? GetToolbarModel()->GetEVCertName() |
| 1001 : GetToolbarModel()->GetSecureVerboseText(); |
| 1000 } | 1002 } |
| 1001 | 1003 |
| 1002 bool LocationBarView::ShouldShowKeywordBubble() const { | 1004 bool LocationBarView::ShouldShowKeywordBubble() const { |
| 1003 return !omnibox_view_->model()->keyword().empty() && | 1005 return !omnibox_view_->model()->keyword().empty() && |
| 1004 !omnibox_view_->model()->is_keyword_hint(); | 1006 !omnibox_view_->model()->is_keyword_hint(); |
| 1005 } | 1007 } |
| 1006 | 1008 |
| 1007 bool LocationBarView::ShouldShowEVBubble() const { | |
| 1008 return (GetToolbarModel()->GetSecurityLevel(false) == | |
| 1009 security_state::SecurityStateModel::EV_SECURE) && | |
| 1010 should_show_secure_state_; | |
| 1011 } | |
| 1012 | |
| 1013 bool LocationBarView::ShouldShowSecurityChip() const { | 1009 bool LocationBarView::ShouldShowSecurityChip() const { |
| 1014 using SecurityLevel = security_state::SecurityStateModel::SecurityLevel; | 1010 using SecurityLevel = security_state::SecurityStateModel::SecurityLevel; |
| 1015 SecurityLevel level = GetToolbarModel()->GetSecurityLevel(false); | 1011 const SecurityLevel level = GetToolbarModel()->GetSecurityLevel(false); |
| 1016 return ((level == SecurityLevel::SECURE || | 1012 if (level == SecurityLevel::EV_SECURE) { |
| 1017 level == SecurityLevel::EV_SECURE) && | 1013 return true; |
| 1018 should_show_secure_state_) || | 1014 } else if (level == SecurityLevel::SECURE) { |
| 1019 level == SecurityLevel::DANGEROUS; | 1015 return should_show_secure_state_; |
| 1016 } else { |
| 1017 return should_show_nonsecure_state_ && |
| 1018 level == SecurityLevel::DANGEROUS; |
| 1019 } |
| 1020 } | 1020 } |
| 1021 | 1021 |
| 1022 //////////////////////////////////////////////////////////////////////////////// | 1022 //////////////////////////////////////////////////////////////////////////////// |
| 1023 // LocationBarView, private LocationBar implementation: | 1023 // LocationBarView, private LocationBar implementation: |
| 1024 | 1024 |
| 1025 void LocationBarView::ShowFirstRunBubble() { | 1025 void LocationBarView::ShowFirstRunBubble() { |
| 1026 // Wait until search engines have loaded to show the first run bubble. | 1026 // Wait until search engines have loaded to show the first run bubble. |
| 1027 TemplateURLService* url_service = | 1027 TemplateURLService* url_service = |
| 1028 TemplateURLServiceFactory::GetForProfile(profile()); | 1028 TemplateURLServiceFactory::GetForProfile(profile()); |
| 1029 if (!url_service->loaded()) { | 1029 if (!url_service->loaded()) { |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1327 // LocationBarView, private TemplateURLServiceObserver implementation: | 1327 // LocationBarView, private TemplateURLServiceObserver implementation: |
| 1328 | 1328 |
| 1329 void LocationBarView::OnTemplateURLServiceChanged() { | 1329 void LocationBarView::OnTemplateURLServiceChanged() { |
| 1330 template_url_service_->RemoveObserver(this); | 1330 template_url_service_->RemoveObserver(this); |
| 1331 template_url_service_ = nullptr; | 1331 template_url_service_ = nullptr; |
| 1332 // If the browser is no longer active, let's not show the info bubble, as this | 1332 // 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. | 1333 // would make the browser the active window again. |
| 1334 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive()) | 1334 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive()) |
| 1335 ShowFirstRunBubble(); | 1335 ShowFirstRunBubble(); |
| 1336 } | 1336 } |
| OLD | NEW |