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/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 332 return ui::MaterialDesignController::IsModeMaterial() | 332 return ui::MaterialDesignController::IsModeMaterial() |
| 333 ? gfx::kGoogleGreen700 | 333 ? gfx::kGoogleGreen700 |
| 334 : SkColorSetRGB(7, 149, 0); | 334 : SkColorSetRGB(7, 149, 0); |
| 335 } | 335 } |
| 336 NOTREACHED(); | 336 NOTREACHED(); |
| 337 return gfx::kPlaceholderColor; | 337 return gfx::kPlaceholderColor; |
| 338 } | 338 } |
| 339 | 339 |
| 340 SkColor LocationBarView::GetSecureTextColor( | 340 SkColor LocationBarView::GetSecureTextColor( |
| 341 security_state::SecurityStateModel::SecurityLevel security_level) const { | 341 security_state::SecurityStateModel::SecurityLevel security_level) const { |
| 342 bool inverted = color_utils::IsDark(GetColor(BACKGROUND)); | 342 if (security_level == |
| 343 SkColor color; | 343 security_state::SecurityStateModel::SECURITY_POLICY_WARNING) { |
|
Peter Kasting
2016/05/20 00:14:12
Nit: No {} (use it when the body is multiple lines
| |
| 344 switch (security_level) { | 344 return GetColor(DEEMPHASIZED_TEXT); |
| 345 case security_state::SecurityStateModel::EV_SECURE: | 345 } |
| 346 case security_state::SecurityStateModel::SECURE: | |
| 347 if (ui::MaterialDesignController::IsModeMaterial() && inverted) | |
| 348 return GetColor(TEXT); | |
| 349 color = GetColor(EV_BUBBLE_TEXT_AND_BORDER); | |
| 350 break; | |
| 351 | 346 |
| 352 case security_state::SecurityStateModel::SECURITY_POLICY_WARNING: | 347 SkColor text_color = GetColor(TEXT); |
| 353 return GetColor(DEEMPHASIZED_TEXT); | 348 if ((security_level == security_state::SecurityStateModel::EV_SECURE) || |
| 354 break; | 349 (security_level == security_state::SecurityStateModel::SECURE) || |
| 355 | 350 (security_level == security_state::SecurityStateModel::SECURITY_ERROR)) { |
| 356 case security_state::SecurityStateModel::SECURITY_ERROR: { | 351 const bool md = ui::MaterialDesignController::IsModeMaterial(); |
| 357 bool md = ui::MaterialDesignController::IsModeMaterial(); | 352 if (md && color_utils::IsDark(GetColor(BACKGROUND))) |
| 358 if (md && inverted) | 353 return text_color; |
| 359 return GetColor(TEXT); | 354 if (security_level == security_state::SecurityStateModel::SECURITY_ERROR) |
| 360 color = md ? gfx::kGoogleRed700 : SkColorSetRGB(162, 0, 0); | 355 text_color = md ? gfx::kGoogleRed700 : SkColorSetRGB(162, 0, 0); |
| 361 break; | 356 else |
| 362 } | 357 text_color = GetColor(EV_BUBBLE_TEXT_AND_BORDER); |
| 363 | |
| 364 case security_state::SecurityStateModel::SECURITY_WARNING: | |
| 365 return GetColor(TEXT); | |
| 366 break; | |
| 367 | |
| 368 default: | |
| 369 NOTREACHED(); | |
| 370 return gfx::kPlaceholderColor; | |
| 371 } | 358 } |
| 372 return color_utils::GetReadableColor(color, GetColor(BACKGROUND)); | 359 return color_utils::GetReadableColor(text_color, GetColor(BACKGROUND)); |
| 373 } | 360 } |
| 374 | 361 |
| 375 void LocationBarView::ZoomChangedForActiveTab(bool can_show_bubble) { | 362 void LocationBarView::ZoomChangedForActiveTab(bool can_show_bubble) { |
| 376 DCHECK(zoom_view_); | 363 DCHECK(zoom_view_); |
| 377 if (RefreshZoomView()) { | 364 if (RefreshZoomView()) { |
| 378 Layout(); | 365 Layout(); |
| 379 SchedulePaint(); | 366 SchedulePaint(); |
| 380 } | 367 } |
| 381 | 368 |
| 382 WebContents* web_contents = GetWebContents(); | 369 WebContents* web_contents = GetWebContents(); |
| (...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 862 return; | 849 return; |
| 863 | 850 |
| 864 if (ui::MaterialDesignController::IsModeMaterial()) { | 851 if (ui::MaterialDesignController::IsModeMaterial()) { |
| 865 gfx::VectorIconId icon_id = gfx::VectorIconId::VECTOR_ICON_NONE; | 852 gfx::VectorIconId icon_id = gfx::VectorIconId::VECTOR_ICON_NONE; |
| 866 const int kIconSize = 16; | 853 const int kIconSize = 16; |
| 867 SkColor icon_color = gfx::kPlaceholderColor; | 854 SkColor icon_color = gfx::kPlaceholderColor; |
| 868 if (ShouldShowEVBubble()) { | 855 if (ShouldShowEVBubble()) { |
| 869 icon_id = gfx::VectorIconId::LOCATION_BAR_HTTPS_VALID_IN_CHIP; | 856 icon_id = gfx::VectorIconId::LOCATION_BAR_HTTPS_VALID_IN_CHIP; |
| 870 icon_color = location_icon_view_->GetTextColor(); | 857 icon_color = location_icon_view_->GetTextColor(); |
| 871 } else { | 858 } else { |
| 872 icon_id = omnibox_view_->GetVectorIcon( | 859 icon_id = omnibox_view_->GetVectorIcon(); |
| 873 color_utils::IsDark(GetColor(BACKGROUND))); | 860 security_state::SecurityStateModel::SecurityLevel security_level = |
| 874 icon_color = color_utils::DeriveDefaultIconColor(GetColor(TEXT)); | 861 GetToolbarModel()->GetSecurityLevel(false); |
| 862 icon_color = (security_level == security_state::SecurityStateModel::NONE) | |
| 863 ? color_utils::DeriveDefaultIconColor(GetColor(TEXT)) | |
| 864 : GetSecureTextColor(security_level); | |
| 875 } | 865 } |
| 876 location_icon_view_->SetImage( | 866 location_icon_view_->SetImage( |
| 877 gfx::CreateVectorIcon(icon_id, kIconSize, icon_color)); | 867 gfx::CreateVectorIcon(icon_id, kIconSize, icon_color)); |
| 878 } else { | 868 } else { |
| 879 location_icon_view_->SetImage( | 869 location_icon_view_->SetImage( |
| 880 *GetThemeProvider()->GetImageSkiaNamed(omnibox_view_->GetIcon())); | 870 *GetThemeProvider()->GetImageSkiaNamed(omnibox_view_->GetIcon())); |
| 881 } | 871 } |
| 882 } | 872 } |
| 883 | 873 |
| 884 bool LocationBarView::RefreshContentSettingViews() { | 874 bool LocationBarView::RefreshContentSettingViews() { |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1384 // LocationBarView, private TemplateURLServiceObserver implementation: | 1374 // LocationBarView, private TemplateURLServiceObserver implementation: |
| 1385 | 1375 |
| 1386 void LocationBarView::OnTemplateURLServiceChanged() { | 1376 void LocationBarView::OnTemplateURLServiceChanged() { |
| 1387 template_url_service_->RemoveObserver(this); | 1377 template_url_service_->RemoveObserver(this); |
| 1388 template_url_service_ = nullptr; | 1378 template_url_service_ = nullptr; |
| 1389 // If the browser is no longer active, let's not show the info bubble, as this | 1379 // If the browser is no longer active, let's not show the info bubble, as this |
| 1390 // would make the browser the active window again. | 1380 // would make the browser the active window again. |
| 1391 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive()) | 1381 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive()) |
| 1392 ShowFirstRunBubble(); | 1382 ShowFirstRunBubble(); |
| 1393 } | 1383 } |
| OLD | NEW |