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/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 case SELECTED_TEXT: | 331 case SELECTED_TEXT: |
332 return native_theme->GetSystemColor( | 332 return native_theme->GetSystemColor( |
333 ui::NativeTheme::kColorId_TextfieldSelectionColor); | 333 ui::NativeTheme::kColorId_TextfieldSelectionColor); |
334 | 334 |
335 case DEEMPHASIZED_TEXT: | 335 case DEEMPHASIZED_TEXT: |
336 return color_utils::AlphaBlend(GetColor(TEXT), GetColor(BACKGROUND), 128); | 336 return color_utils::AlphaBlend(GetColor(TEXT), GetColor(BACKGROUND), 128); |
337 | 337 |
338 case EV_BUBBLE_TEXT_AND_BORDER: | 338 case EV_BUBBLE_TEXT_AND_BORDER: |
339 return ui::MaterialDesignController::IsModeMaterial() | 339 return ui::MaterialDesignController::IsModeMaterial() |
340 ? GetSecureTextColor( | 340 ? GetSecureTextColor( |
341 GetToolbarModel()->GetSecurityLevel(false)) | 341 security_state::SecurityStateModel::EV_SECURE) |
342 : SkColorSetRGB(7, 149, 0); | 342 : SkColorSetRGB(7, 149, 0); |
343 } | 343 } |
344 NOTREACHED(); | 344 NOTREACHED(); |
345 return gfx::kPlaceholderColor; | 345 return gfx::kPlaceholderColor; |
346 } | 346 } |
347 | 347 |
348 SkColor LocationBarView::GetSecureTextColor( | 348 SkColor LocationBarView::GetSecureTextColor( |
349 security_state::SecurityStateModel::SecurityLevel security_level) const { | 349 security_state::SecurityStateModel::SecurityLevel security_level) const { |
350 if (security_level == | 350 if (security_level == |
351 security_state::SecurityStateModel::SECURITY_POLICY_WARNING) { | 351 security_state::SecurityStateModel::SECURITY_POLICY_WARNING) { |
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
858 | 858 |
859 void LocationBarView::RefreshLocationIcon() { | 859 void LocationBarView::RefreshLocationIcon() { |
860 // |omnibox_view_| may not be ready yet if Init() has not been called. The | 860 // |omnibox_view_| may not be ready yet if Init() has not been called. The |
861 // icon will be set soon by OnChanged(). | 861 // icon will be set soon by OnChanged(). |
862 if (!omnibox_view_) | 862 if (!omnibox_view_) |
863 return; | 863 return; |
864 | 864 |
865 if (ui::MaterialDesignController::IsModeMaterial()) { | 865 if (ui::MaterialDesignController::IsModeMaterial()) { |
866 const int kIconSize = 16; | 866 const int kIconSize = 16; |
867 security_state::SecurityStateModel::SecurityLevel security_level = | 867 security_state::SecurityStateModel::SecurityLevel security_level = |
868 GetToolbarModel()->GetSecurityLevel(false); | 868 omnibox_view_->GetSecurityLevelForDisplay(); |
869 SkColor icon_color = | 869 SkColor icon_color = |
870 (security_level == security_state::SecurityStateModel::NONE) | 870 (security_level == security_state::SecurityStateModel::NONE) |
871 ? color_utils::DeriveDefaultIconColor(GetColor(TEXT)) | 871 ? color_utils::DeriveDefaultIconColor(GetColor(TEXT)) |
872 : GetSecureTextColor(security_level); | 872 : GetSecureTextColor(security_level); |
873 location_icon_view_->SetImage(gfx::CreateVectorIcon( | 873 location_icon_view_->SetImage(gfx::CreateVectorIcon( |
874 omnibox_view_->GetVectorIcon(), kIconSize, icon_color)); | 874 omnibox_view_->GetVectorIcon(), kIconSize, icon_color)); |
875 } else { | 875 } else { |
876 location_icon_view_->SetImage( | 876 location_icon_view_->SetImage( |
877 *GetThemeProvider()->GetImageSkiaNamed(omnibox_view_->GetIcon())); | 877 *GetThemeProvider()->GetImageSkiaNamed(omnibox_view_->GetIcon())); |
878 } | 878 } |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1041 return suggested_text_view_->visible() && | 1041 return suggested_text_view_->visible() && |
1042 !suggested_text_view_->size().IsEmpty(); | 1042 !suggested_text_view_->size().IsEmpty(); |
1043 } | 1043 } |
1044 | 1044 |
1045 bool LocationBarView::ShouldShowKeywordBubble() const { | 1045 bool LocationBarView::ShouldShowKeywordBubble() const { |
1046 return !omnibox_view_->model()->keyword().empty() && | 1046 return !omnibox_view_->model()->keyword().empty() && |
1047 !omnibox_view_->model()->is_keyword_hint(); | 1047 !omnibox_view_->model()->is_keyword_hint(); |
1048 } | 1048 } |
1049 | 1049 |
1050 bool LocationBarView::ShouldShowEVBubble() const { | 1050 bool LocationBarView::ShouldShowEVBubble() const { |
1051 return (GetToolbarModel()->GetSecurityLevel(false) == | 1051 return (omnibox_view_->GetSecurityLevelForDisplay() == |
1052 security_state::SecurityStateModel::EV_SECURE); | 1052 security_state::SecurityStateModel::EV_SECURE); |
1053 } | 1053 } |
1054 | 1054 |
1055 //////////////////////////////////////////////////////////////////////////////// | 1055 //////////////////////////////////////////////////////////////////////////////// |
1056 // LocationBarView, private LocationBar implementation: | 1056 // LocationBarView, private LocationBar implementation: |
1057 | 1057 |
1058 void LocationBarView::ShowFirstRunBubble() { | 1058 void LocationBarView::ShowFirstRunBubble() { |
1059 // Wait until search engines have loaded to show the first run bubble. | 1059 // Wait until search engines have loaded to show the first run bubble. |
1060 TemplateURLService* url_service = | 1060 TemplateURLService* url_service = |
1061 TemplateURLServiceFactory::GetForProfile(profile()); | 1061 TemplateURLServiceFactory::GetForProfile(profile()); |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1389 // LocationBarView, private TemplateURLServiceObserver implementation: | 1389 // LocationBarView, private TemplateURLServiceObserver implementation: |
1390 | 1390 |
1391 void LocationBarView::OnTemplateURLServiceChanged() { | 1391 void LocationBarView::OnTemplateURLServiceChanged() { |
1392 template_url_service_->RemoveObserver(this); | 1392 template_url_service_->RemoveObserver(this); |
1393 template_url_service_ = nullptr; | 1393 template_url_service_ = nullptr; |
1394 // If the browser is no longer active, let's not show the info bubble, as this | 1394 // If the browser is no longer active, let's not show the info bubble, as this |
1395 // would make the browser the active window again. | 1395 // would make the browser the active window again. |
1396 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive()) | 1396 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive()) |
1397 ShowFirstRunBubble(); | 1397 ShowFirstRunBubble(); |
1398 } | 1398 } |
OLD | NEW |