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 SecurityStateModel::SecurityLevel security_level) const { | 341 SecurityStateModel::SecurityLevel security_level) const { |
342 bool inverted = | 342 bool inverted = color_utils::IsDark(GetColor(BACKGROUND)); |
343 color_utils::GetLuminanceForColor(GetColor(BACKGROUND)) < 128; | |
344 SkColor color; | 343 SkColor color; |
345 switch (security_level) { | 344 switch (security_level) { |
346 case SecurityStateModel::EV_SECURE: | 345 case SecurityStateModel::EV_SECURE: |
347 case SecurityStateModel::SECURE: | 346 case SecurityStateModel::SECURE: |
348 if (ui::MaterialDesignController::IsModeMaterial() && inverted) | 347 if (ui::MaterialDesignController::IsModeMaterial() && inverted) |
349 return GetColor(TEXT); | 348 return GetColor(TEXT); |
350 color = GetColor(EV_BUBBLE_TEXT_AND_BORDER); | 349 color = GetColor(EV_BUBBLE_TEXT_AND_BORDER); |
351 break; | 350 break; |
352 | 351 |
353 case SecurityStateModel::SECURITY_POLICY_WARNING: | 352 case SecurityStateModel::SECURITY_POLICY_WARNING: |
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
785 location_bounds.right(), location_bounds.y(), | 784 location_bounds.right(), location_bounds.y(), |
786 std::min(width, entry_width), location_bounds.height()); | 785 std::min(width, entry_width), location_bounds.height()); |
787 } | 786 } |
788 omnibox_view_->SetBoundsRect(location_bounds); | 787 omnibox_view_->SetBoundsRect(location_bounds); |
789 } | 788 } |
790 | 789 |
791 void LocationBarView::OnNativeThemeChanged(const ui::NativeTheme* theme) { | 790 void LocationBarView::OnNativeThemeChanged(const ui::NativeTheme* theme) { |
792 if (!ui::MaterialDesignController::IsModeMaterial()) | 791 if (!ui::MaterialDesignController::IsModeMaterial()) |
793 return; | 792 return; |
794 | 793 |
794 RefreshLocationIcon(); | |
795 set_background(new BackgroundWith1PxBorder( | 795 set_background(new BackgroundWith1PxBorder( |
796 GetColor(BACKGROUND), SkColorSetARGB(0x4D, 0x00, 0x00, 0x00), | 796 GetColor(BACKGROUND), SkColorSetARGB(0x4D, 0x00, 0x00, 0x00), |
797 is_popup_mode_)); | 797 is_popup_mode_)); |
798 } | 798 } |
799 | 799 |
800 void LocationBarView::Update(const WebContents* contents) { | 800 void LocationBarView::Update(const WebContents* contents) { |
801 RefreshContentSettingViews(); | 801 RefreshContentSettingViews(); |
802 RefreshZoomView(); | 802 RefreshZoomView(); |
803 RefreshPageActionViews(); | 803 RefreshPageActionViews(); |
804 RefreshTranslateIcon(); | 804 RefreshTranslateIcon(); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
861 int LocationBarView::GetVerticalEdgeThickness() const { | 861 int LocationBarView::GetVerticalEdgeThickness() const { |
862 return is_popup_mode_ ? kPopupEdgeThickness | 862 return is_popup_mode_ ? kPopupEdgeThickness |
863 : GetLayoutConstant(LOCATION_BAR_BORDER_THICKNESS); | 863 : GetLayoutConstant(LOCATION_BAR_BORDER_THICKNESS); |
864 } | 864 } |
865 | 865 |
866 int LocationBarView::VerticalPadding() const { | 866 int LocationBarView::VerticalPadding() const { |
867 return is_popup_mode_ ? | 867 return is_popup_mode_ ? |
868 kPopupEdgeThickness : GetLayoutConstant(LOCATION_BAR_VERTICAL_PADDING); | 868 kPopupEdgeThickness : GetLayoutConstant(LOCATION_BAR_VERTICAL_PADDING); |
869 } | 869 } |
870 | 870 |
871 void LocationBarView::RefreshLocationIcon() { | |
872 // |omnibox_view_| may not be ready yet. | |
Peter Kasting
2015/11/17 21:27:03
If you really need this conditional, this comment
Evan Stade
2015/11/17 22:57:21
Done.
| |
873 if (!omnibox_view_) | |
874 return; | |
875 | |
876 if (ui::MaterialDesignController::IsModeMaterial()) { | |
877 location_icon_view_->SetImage(gfx::CreateVectorIcon( | |
878 omnibox_view_->GetVectorIcon(color_utils::IsDark(GetColor(BACKGROUND))), | |
879 16, color_utils::DeriveDefaultIconColor(GetColor(TEXT)))); | |
880 } else { | |
881 location_icon_view_->SetImage( | |
882 *GetThemeProvider()->GetImageSkiaNamed(omnibox_view_->GetIcon())); | |
883 } | |
884 } | |
885 | |
871 bool LocationBarView::RefreshContentSettingViews() { | 886 bool LocationBarView::RefreshContentSettingViews() { |
872 bool visibility_changed = false; | 887 bool visibility_changed = false; |
873 for (ContentSettingViews::const_iterator i(content_setting_views_.begin()); | 888 for (ContentSettingViews::const_iterator i(content_setting_views_.begin()); |
874 i != content_setting_views_.end(); ++i) { | 889 i != content_setting_views_.end(); ++i) { |
875 const bool was_visible = (*i)->visible(); | 890 const bool was_visible = (*i)->visible(); |
876 (*i)->Update(GetToolbarModel()->input_in_progress() ? | 891 (*i)->Update(GetToolbarModel()->input_in_progress() ? |
877 NULL : GetWebContents()); | 892 NULL : GetWebContents()); |
878 if (was_visible != (*i)->visible()) | 893 if (was_visible != (*i)->visible()) |
879 visibility_changed = true; | 894 visibility_changed = true; |
880 } | 895 } |
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1350 } | 1365 } |
1351 | 1366 |
1352 void LocationBarView::AnimationEnded(const gfx::Animation* animation) { | 1367 void LocationBarView::AnimationEnded(const gfx::Animation* animation) { |
1353 browser_->window()->ToolbarSizeChanged(false); | 1368 browser_->window()->ToolbarSizeChanged(false); |
1354 } | 1369 } |
1355 | 1370 |
1356 //////////////////////////////////////////////////////////////////////////////// | 1371 //////////////////////////////////////////////////////////////////////////////// |
1357 // LocationBarView, private OmniboxEditController implementation: | 1372 // LocationBarView, private OmniboxEditController implementation: |
1358 | 1373 |
1359 void LocationBarView::OnChanged() { | 1374 void LocationBarView::OnChanged() { |
1360 location_icon_view_->SetImage( | 1375 RefreshLocationIcon(); |
1361 ui::MaterialDesignController::IsModeMaterial() | |
1362 ? gfx::CreateVectorIcon(omnibox_view_->GetVectorIcon(), 16, | |
1363 gfx::kChromeIconGrey) | |
1364 : *GetThemeProvider()->GetImageSkiaNamed(omnibox_view_->GetIcon())); | |
1365 location_icon_view_->ShowTooltip(!GetOmniboxView()->IsEditingOrEmpty()); | 1376 location_icon_view_->ShowTooltip(!GetOmniboxView()->IsEditingOrEmpty()); |
1366 | 1377 |
1367 Layout(); | 1378 Layout(); |
1368 SchedulePaint(); | 1379 SchedulePaint(); |
1369 } | 1380 } |
1370 | 1381 |
1371 void LocationBarView::OnSetFocus() { | 1382 void LocationBarView::OnSetFocus() { |
1372 GetFocusManager()->SetFocusedView(this); | 1383 GetFocusManager()->SetFocusedView(this); |
1373 } | 1384 } |
1374 | 1385 |
(...skipping 16 matching lines...) Expand all Loading... | |
1391 // LocationBarView, private TemplateURLServiceObserver implementation: | 1402 // LocationBarView, private TemplateURLServiceObserver implementation: |
1392 | 1403 |
1393 void LocationBarView::OnTemplateURLServiceChanged() { | 1404 void LocationBarView::OnTemplateURLServiceChanged() { |
1394 template_url_service_->RemoveObserver(this); | 1405 template_url_service_->RemoveObserver(this); |
1395 template_url_service_ = NULL; | 1406 template_url_service_ = NULL; |
1396 // If the browser is no longer active, let's not show the info bubble, as this | 1407 // If the browser is no longer active, let's not show the info bubble, as this |
1397 // would make the browser the active window again. | 1408 // would make the browser the active window again. |
1398 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive()) | 1409 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive()) |
1399 ShowFirstRunBubble(); | 1410 ShowFirstRunBubble(); |
1400 } | 1411 } |
OLD | NEW |