Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(558)

Side by Side Diff: chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm

Issue 2375033002: cocoa browser: remove non-MD location bar support (Closed)
Patch Set: fix nits Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" 5 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #import "base/mac/mac_util.h" 9 #import "base/mac/mac_util.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 vector_icon_color), 626 vector_icon_color),
627 base::mac::GetSRGBColorSpace()); 627 base::mac::GetSRGBColorSpace());
628 location_icon_decoration_->SetImage(image); 628 location_icon_decoration_->SetImage(image);
629 security_state_bubble_decoration_->SetImage(image); 629 security_state_bubble_decoration_->SetImage(image);
630 security_state_bubble_decoration_->SetLabelColor(vector_icon_color); 630 security_state_bubble_decoration_->SetLabelColor(vector_icon_color);
631 631
632 Layout(); 632 Layout();
633 } 633 }
634 634
635 void LocationBarViewMac::UpdateColorsToMatchTheme() { 635 void LocationBarViewMac::UpdateColorsToMatchTheme() {
636 if (!ui::MaterialDesignController::IsModeMaterial() ||
637 ![[field_ window] inIncognitoMode]) {
638 return;
639 }
640
641 // Update the location-bar icon. 636 // Update the location-bar icon.
642 UpdateLocationIcon(); 637 UpdateLocationIcon();
643 638
644 // Make sure we're displaying the correct star color for Incognito mode. If 639 // Make sure we're displaying the correct star color for Incognito mode. If
645 // the window is in Incognito mode, switching between a theme and no theme 640 // the window is in Incognito mode, switching between a theme and no theme
646 // can move the window in and out of dark mode. 641 // can move the window in and out of dark mode.
647 star_decoration_->SetStarred(star_decoration_->starred(), 642 star_decoration_->SetStarred(star_decoration_->starred(),
648 IsLocationBarDark()); 643 IsLocationBarDark());
649 644
650 // Update the appearance of the text in the Omnibox. 645 // Update the appearance of the text in the Omnibox.
651 omnibox_view_->Update(); 646 omnibox_view_->Update();
652 } 647 }
653 648
654 void LocationBarViewMac::OnAddedToWindow() { 649 void LocationBarViewMac::OnAddedToWindow() {
655 UpdateColorsToMatchTheme(); 650 UpdateColorsToMatchTheme();
656 } 651 }
657 652
658 void LocationBarViewMac::OnThemeChanged() { 653 void LocationBarViewMac::OnThemeChanged() {
659 UpdateColorsToMatchTheme(); 654 UpdateColorsToMatchTheme();
660 } 655 }
661 656
662 void LocationBarViewMac::OnChanged() { 657 void LocationBarViewMac::OnChanged() {
663 if (!ui::MaterialDesignController::IsModeMaterial()) {
664 const int resource_id = omnibox_view_->GetIcon();
665 NSImage* image = OmniboxViewMac::ImageForResource(resource_id);
666 location_icon_decoration_->SetImage(image);
667 security_state_bubble_decoration_->SetImage(image);
668 Layout();
669 return;
670 }
671 UpdateSecurityState(false); 658 UpdateSecurityState(false);
672 UpdateLocationIcon(); 659 UpdateLocationIcon();
673 } 660 }
674 661
675 ToolbarModel* LocationBarViewMac::GetToolbarModel() { 662 ToolbarModel* LocationBarViewMac::GetToolbarModel() {
676 return browser_->toolbar_model(); 663 return browser_->toolbar_model();
677 } 664 }
678 665
679 const ToolbarModel* LocationBarViewMac::GetToolbarModel() const { 666 const ToolbarModel* LocationBarViewMac::GetToolbarModel() const {
680 return browser_->toolbar_model(); 667 return browser_->toolbar_model();
681 } 668 }
682 669
683 WebContents* LocationBarViewMac::GetWebContents() { 670 WebContents* LocationBarViewMac::GetWebContents() {
684 return browser_->tab_strip_model()->GetActiveWebContents(); 671 return browser_->tab_strip_model()->GetActiveWebContents();
685 } 672 }
686 673
687 bool LocationBarViewMac::ShouldShowEVBubble() const { 674 bool LocationBarViewMac::ShouldShowEVBubble() const {
688 return (GetToolbarModel()->GetSecurityLevel(false) == 675 return (GetToolbarModel()->GetSecurityLevel(false) ==
689 security_state::SecurityStateModel::EV_SECURE) && 676 security_state::SecurityStateModel::EV_SECURE) &&
690 should_show_secure_verbose_; 677 should_show_secure_verbose_;
691 } 678 }
692 679
693 bool LocationBarViewMac::ShouldShowSecurityState() const { 680 bool LocationBarViewMac::ShouldShowSecurityState() const {
694 security_state::SecurityStateModel::SecurityLevel security = 681 security_state::SecurityStateModel::SecurityLevel security =
695 GetToolbarModel()->GetSecurityLevel(false); 682 GetToolbarModel()->GetSecurityLevel(false);
696 bool has_verbose_for_security = 683 bool has_verbose_for_security =
697 security == security_state::SecurityStateModel::DANGEROUS || 684 security == security_state::SecurityStateModel::DANGEROUS ||
698 (IsSecureConnection(security) && should_show_secure_verbose_); 685 (IsSecureConnection(security) && should_show_secure_verbose_);
699 686
700 return ui::MaterialDesignController::IsModeMaterial() && 687 return has_verbose_for_security && !omnibox_view_->IsEditingOrEmpty() &&
701 has_verbose_for_security && !omnibox_view_->IsEditingOrEmpty() &&
702 !omnibox_view_->model()->is_keyword_hint(); 688 !omnibox_view_->model()->is_keyword_hint();
703 } 689 }
704 690
705 bool LocationBarViewMac::IsLocationBarDark() const { 691 bool LocationBarViewMac::IsLocationBarDark() const {
706 return [[field_ window] inIncognitoModeWithSystemTheme]; 692 return [[field_ window] inIncognitoModeWithSystemTheme];
707 } 693 }
708 694
709 NSImage* LocationBarViewMac::GetKeywordImage(const base::string16& keyword) { 695 NSImage* LocationBarViewMac::GetKeywordImage(const base::string16& keyword) {
710 const TemplateURL* template_url = TemplateURLServiceFactory::GetForProfile( 696 const TemplateURL* template_url = TemplateURLServiceFactory::GetForProfile(
711 profile())->GetTemplateURLForKeyword(keyword); 697 profile())->GetTemplateURLForKeyword(keyword);
712 if (template_url && 698 if (template_url &&
713 (template_url->type() == TemplateURL::OMNIBOX_API_EXTENSION)) { 699 (template_url->type() == TemplateURL::OMNIBOX_API_EXTENSION)) {
714 return extensions::OmniboxAPI::Get(profile())-> 700 return extensions::OmniboxAPI::Get(profile())->
715 GetOmniboxIcon(template_url->GetExtensionId()).AsNSImage(); 701 GetOmniboxIcon(template_url->GetExtensionId()).AsNSImage();
716 } 702 }
717 703
718 if (ui::MaterialDesignController::IsModeMaterial()) { 704 SkColor icon_color =
719 SkColor icon_color = IsLocationBarDark() ? kMaterialDarkVectorIconColor 705 IsLocationBarDark() ? kMaterialDarkVectorIconColor : gfx::kGoogleBlue700;
720 : gfx::kGoogleBlue700; 706 return NSImageFromImageSkiaWithColorSpace(
721 return NSImageFromImageSkiaWithColorSpace( 707 gfx::CreateVectorIcon(gfx::VectorIconId::OMNIBOX_SEARCH, kDefaultIconSize,
722 gfx::CreateVectorIcon(gfx::VectorIconId::OMNIBOX_SEARCH, 708 icon_color),
723 kDefaultIconSize, icon_color), 709 base::mac::GetSRGBColorSpace());
724 base::mac::GetSRGBColorSpace());
725 }
726
727 return OmniboxViewMac::ImageForResource(IDR_OMNIBOX_SEARCH);
728 } 710 }
729 711
730 SkColor LocationBarViewMac::GetLocationBarIconColor() const { 712 SkColor LocationBarViewMac::GetLocationBarIconColor() const {
731 bool in_dark_mode = IsLocationBarDark(); 713 bool in_dark_mode = IsLocationBarDark();
732 if (in_dark_mode) 714 if (in_dark_mode)
733 return kMaterialDarkVectorIconColor; 715 return kMaterialDarkVectorIconColor;
734 716
735 if (ShouldShowEVBubble()) 717 if (ShouldShowEVBubble())
736 return gfx::kGoogleGreen700; 718 return gfx::kGoogleGreen700;
737 719
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 OnDecorationsChanged(); 929 OnDecorationsChanged();
948 } 930 }
949 931
950 std::vector<NSView*> LocationBarViewMac::GetDecorationAccessibilityViews() { 932 std::vector<NSView*> LocationBarViewMac::GetDecorationAccessibilityViews() {
951 std::vector<LocationBarDecoration*> decorations = GetDecorations(); 933 std::vector<LocationBarDecoration*> decorations = GetDecorations();
952 std::vector<NSView*> views; 934 std::vector<NSView*> views;
953 for (auto* decoration : decorations) 935 for (auto* decoration : decorations)
954 views.push_back(decoration->GetAccessibilityView()); 936 views.push_back(decoration->GetAccessibilityView());
955 return views; 937 return views;
956 } 938 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698