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 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 return color_utils::AlphaBlend(GetColor(TEXT), GetColor(BACKGROUND), 128); | 348 return color_utils::AlphaBlend(GetColor(TEXT), GetColor(BACKGROUND), 128); |
349 | 349 |
350 case SECURITY_CHIP_TEXT: | 350 case SECURITY_CHIP_TEXT: |
351 return GetSecureTextColor(GetToolbarModel()->GetSecurityLevel(false)); | 351 return GetSecureTextColor(GetToolbarModel()->GetSecurityLevel(false)); |
352 } | 352 } |
353 NOTREACHED(); | 353 NOTREACHED(); |
354 return gfx::kPlaceholderColor; | 354 return gfx::kPlaceholderColor; |
355 } | 355 } |
356 | 356 |
357 SkColor LocationBarView::GetSecureTextColor( | 357 SkColor LocationBarView::GetSecureTextColor( |
358 security_state::SecurityStateModel::SecurityLevel security_level) const { | 358 security_state::SecurityLevel security_level) const { |
359 if (security_level == | 359 if (security_level == security_state::SECURE_WITH_POLICY_INSTALLED_CERT) { |
360 security_state::SecurityStateModel::SECURE_WITH_POLICY_INSTALLED_CERT) { | |
361 return GetColor(DEEMPHASIZED_TEXT); | 360 return GetColor(DEEMPHASIZED_TEXT); |
362 } | 361 } |
363 | 362 |
364 SkColor text_color = GetColor(TEXT); | 363 SkColor text_color = GetColor(TEXT); |
365 if (!color_utils::IsDark(GetColor(BACKGROUND))) { | 364 if (!color_utils::IsDark(GetColor(BACKGROUND))) { |
366 if ((security_level == security_state::SecurityStateModel::EV_SECURE) || | 365 if ((security_level == security_state::EV_SECURE) || |
367 (security_level == security_state::SecurityStateModel::SECURE)) { | 366 (security_level == security_state::SECURE)) { |
368 text_color = gfx::kGoogleGreen700; | 367 text_color = gfx::kGoogleGreen700; |
369 } else if (security_level == | 368 } else if (security_level == security_state::DANGEROUS) { |
370 security_state::SecurityStateModel::DANGEROUS) { | |
371 text_color = gfx::kGoogleRed700; | 369 text_color = gfx::kGoogleRed700; |
372 } | 370 } |
373 } | 371 } |
374 return color_utils::GetReadableColor(text_color, GetColor(BACKGROUND)); | 372 return color_utils::GetReadableColor(text_color, GetColor(BACKGROUND)); |
375 } | 373 } |
376 | 374 |
377 void LocationBarView::ZoomChangedForActiveTab(bool can_show_bubble) { | 375 void LocationBarView::ZoomChangedForActiveTab(bool can_show_bubble) { |
378 DCHECK(zoom_view_); | 376 DCHECK(zoom_view_); |
379 if (RefreshZoomView()) { | 377 if (RefreshZoomView()) { |
380 Layout(); | 378 Layout(); |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
825 return GetLayoutConstant(LOCATION_BAR_BORDER_THICKNESS) + | 823 return GetLayoutConstant(LOCATION_BAR_BORDER_THICKNESS) + |
826 GetLayoutConstant(LOCATION_BAR_VERTICAL_PADDING); | 824 GetLayoutConstant(LOCATION_BAR_VERTICAL_PADDING); |
827 } | 825 } |
828 | 826 |
829 void LocationBarView::RefreshLocationIcon() { | 827 void LocationBarView::RefreshLocationIcon() { |
830 // |omnibox_view_| may not be ready yet if Init() has not been called. The | 828 // |omnibox_view_| may not be ready yet if Init() has not been called. The |
831 // icon will be set soon by OnChanged(). | 829 // icon will be set soon by OnChanged(). |
832 if (!omnibox_view_) | 830 if (!omnibox_view_) |
833 return; | 831 return; |
834 | 832 |
835 security_state::SecurityStateModel::SecurityLevel security_level = | 833 security_state::SecurityLevel security_level = |
836 GetToolbarModel()->GetSecurityLevel(false); | 834 GetToolbarModel()->GetSecurityLevel(false); |
837 SkColor icon_color = | 835 SkColor icon_color = (security_level == security_state::NONE || |
838 (security_level == security_state::SecurityStateModel::NONE || | 836 security_level == security_state::HTTP_SHOW_WARNING) |
839 security_level == security_state::SecurityStateModel::HTTP_SHOW_WARNING) | 837 ? color_utils::DeriveDefaultIconColor(GetColor(TEXT)) |
840 ? color_utils::DeriveDefaultIconColor(GetColor(TEXT)) | 838 : GetSecureTextColor(security_level); |
841 : GetSecureTextColor(security_level); | |
842 location_icon_view_->SetImage(gfx::CreateVectorIcon( | 839 location_icon_view_->SetImage(gfx::CreateVectorIcon( |
843 omnibox_view_->GetVectorIcon(), kIconWidth, icon_color)); | 840 omnibox_view_->GetVectorIcon(), kIconWidth, icon_color)); |
844 } | 841 } |
845 | 842 |
846 bool LocationBarView::RefreshContentSettingViews() { | 843 bool LocationBarView::RefreshContentSettingViews() { |
847 bool visibility_changed = false; | 844 bool visibility_changed = false; |
848 for (ContentSettingViews::const_iterator i(content_setting_views_.begin()); | 845 for (ContentSettingViews::const_iterator i(content_setting_views_.begin()); |
849 i != content_setting_views_.end(); ++i) { | 846 i != content_setting_views_.end(); ++i) { |
850 const bool was_visible = (*i)->visible(); | 847 const bool was_visible = (*i)->visible(); |
851 (*i)->Update(GetToolbarModel()->input_in_progress() ? nullptr | 848 (*i)->Update(GetToolbarModel()->input_in_progress() ? nullptr |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1000 FirstRunBubble::ShowBubble(browser, location_icon_view_); | 997 FirstRunBubble::ShowBubble(browser, location_icon_view_); |
1001 #endif | 998 #endif |
1002 } | 999 } |
1003 | 1000 |
1004 bool LocationBarView::HasValidSuggestText() const { | 1001 bool LocationBarView::HasValidSuggestText() const { |
1005 return suggested_text_view_->visible() && | 1002 return suggested_text_view_->visible() && |
1006 !suggested_text_view_->size().IsEmpty(); | 1003 !suggested_text_view_->size().IsEmpty(); |
1007 } | 1004 } |
1008 | 1005 |
1009 base::string16 LocationBarView::GetSecurityText() const { | 1006 base::string16 LocationBarView::GetSecurityText() const { |
1010 bool has_ev_cert = (GetToolbarModel()->GetSecurityLevel(false) == | 1007 bool has_ev_cert = |
1011 security_state::SecurityStateModel::EV_SECURE); | 1008 (GetToolbarModel()->GetSecurityLevel(false) == security_state::EV_SECURE); |
1012 return has_ev_cert ? GetToolbarModel()->GetEVCertName() | 1009 return has_ev_cert ? GetToolbarModel()->GetEVCertName() |
1013 : GetToolbarModel()->GetSecureVerboseText(); | 1010 : GetToolbarModel()->GetSecureVerboseText(); |
1014 } | 1011 } |
1015 | 1012 |
1016 bool LocationBarView::ShouldShowKeywordBubble() const { | 1013 bool LocationBarView::ShouldShowKeywordBubble() const { |
1017 return !omnibox_view_->model()->keyword().empty() && | 1014 return !omnibox_view_->model()->keyword().empty() && |
1018 !omnibox_view_->model()->is_keyword_hint(); | 1015 !omnibox_view_->model()->is_keyword_hint(); |
1019 } | 1016 } |
1020 | 1017 |
1021 bool LocationBarView::ShouldShowSecurityChip() const { | 1018 bool LocationBarView::ShouldShowSecurityChip() const { |
1022 using SecurityLevel = security_state::SecurityStateModel::SecurityLevel; | 1019 using SecurityLevel = security_state::SecurityLevel; |
1023 const SecurityLevel level = GetToolbarModel()->GetSecurityLevel(false); | 1020 const SecurityLevel level = GetToolbarModel()->GetSecurityLevel(false); |
1024 if (level == SecurityLevel::EV_SECURE) { | 1021 if (level == SecurityLevel::EV_SECURE) { |
1025 return true; | 1022 return true; |
1026 } else if (level == SecurityLevel::SECURE) { | 1023 } else if (level == SecurityLevel::SECURE) { |
1027 return should_show_secure_state_; | 1024 return should_show_secure_state_; |
1028 } else { | 1025 } else { |
1029 return should_show_nonsecure_state_ && | 1026 return should_show_nonsecure_state_ && |
1030 (level == SecurityLevel::DANGEROUS || | 1027 (level == SecurityLevel::DANGEROUS || |
1031 level == SecurityLevel::HTTP_SHOW_WARNING); | 1028 level == SecurityLevel::HTTP_SHOW_WARNING); |
1032 } | 1029 } |
1033 } | 1030 } |
1034 | 1031 |
1035 bool LocationBarView::ShouldAnimateSecurityChip() const { | 1032 bool LocationBarView::ShouldAnimateSecurityChip() const { |
1036 using SecurityLevel = security_state::SecurityStateModel::SecurityLevel; | 1033 using SecurityLevel = security_state::SecurityLevel; |
1037 SecurityLevel level = GetToolbarModel()->GetSecurityLevel(false); | 1034 SecurityLevel level = GetToolbarModel()->GetSecurityLevel(false); |
1038 if (!ShouldShowSecurityChip()) | 1035 if (!ShouldShowSecurityChip()) |
1039 return false; | 1036 return false; |
1040 if (level == SecurityLevel::SECURE || level == SecurityLevel::EV_SECURE) | 1037 if (level == SecurityLevel::SECURE || level == SecurityLevel::EV_SECURE) |
1041 return should_animate_secure_state_; | 1038 return should_animate_secure_state_; |
1042 return should_animate_nonsecure_state_ && | 1039 return should_animate_nonsecure_state_ && |
1043 (level == SecurityLevel::DANGEROUS || | 1040 (level == SecurityLevel::DANGEROUS || |
1044 level == SecurityLevel::HTTP_SHOW_WARNING); | 1041 level == SecurityLevel::HTTP_SHOW_WARNING); |
1045 } | 1042 } |
1046 | 1043 |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1351 // LocationBarView, private TemplateURLServiceObserver implementation: | 1348 // LocationBarView, private TemplateURLServiceObserver implementation: |
1352 | 1349 |
1353 void LocationBarView::OnTemplateURLServiceChanged() { | 1350 void LocationBarView::OnTemplateURLServiceChanged() { |
1354 template_url_service_->RemoveObserver(this); | 1351 template_url_service_->RemoveObserver(this); |
1355 template_url_service_ = nullptr; | 1352 template_url_service_ = nullptr; |
1356 // 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 |
1357 // would make the browser the active window again. | 1354 // would make the browser the active window again. |
1358 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive()) | 1355 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive()) |
1359 ShowFirstRunBubble(); | 1356 ShowFirstRunBubble(); |
1360 } | 1357 } |
OLD | NEW |