| OLD | NEW |
| 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/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 | 78 |
| 79 using content::WebContents; | 79 using content::WebContents; |
| 80 | 80 |
| 81 namespace { | 81 namespace { |
| 82 | 82 |
| 83 // Vertical space between the bottom edge of the location_bar and the first run | 83 // Vertical space between the bottom edge of the location_bar and the first run |
| 84 // bubble arrow point. | 84 // bubble arrow point. |
| 85 const static int kFirstRunBubbleYOffset = 1; | 85 const static int kFirstRunBubbleYOffset = 1; |
| 86 | 86 |
| 87 const int kDefaultIconSize = 16; | 87 const int kDefaultIconSize = 16; |
| 88 const int kMaterialSmallIconSize = 12; | 88 const int kMaterialIconSize = 18; |
| 89 |
| 90 // Color of the vector graphic icons when the location bar is dark. |
| 91 // SkColorSetARGB(0xCC, 0xFF, 0xFF 0xFF); |
| 92 const SkColor kMaterialDarkVectorIconColor = 0xCCFFFFFF; |
| 89 | 93 |
| 90 } // namespace | 94 } // namespace |
| 91 | 95 |
| 92 // TODO(shess): This code is mostly copied from the gtk | 96 // TODO(shess): This code is mostly copied from the gtk |
| 93 // implementation. Make sure it's all appropriate and flesh it out. | 97 // implementation. Make sure it's all appropriate and flesh it out. |
| 94 | 98 |
| 95 LocationBarViewMac::LocationBarViewMac(AutocompleteTextField* field, | 99 LocationBarViewMac::LocationBarViewMac(AutocompleteTextField* field, |
| 96 CommandUpdater* command_updater, | 100 CommandUpdater* command_updater, |
| 97 Profile* profile, | 101 Profile* profile, |
| 98 Browser* browser) | 102 Browser* browser) |
| (...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 } | 564 } |
| 561 | 565 |
| 562 void LocationBarViewMac::UpdateLocationIcon() { | 566 void LocationBarViewMac::UpdateLocationIcon() { |
| 563 bool in_dark_mode = IsLocationBarDark(); | 567 bool in_dark_mode = IsLocationBarDark(); |
| 564 | 568 |
| 565 SkColor vector_icon_color = gfx::kPlaceholderColor; | 569 SkColor vector_icon_color = gfx::kPlaceholderColor; |
| 566 gfx::VectorIconId vector_icon_id = gfx::VectorIconId::VECTOR_ICON_NONE; | 570 gfx::VectorIconId vector_icon_id = gfx::VectorIconId::VECTOR_ICON_NONE; |
| 567 int icon_size = kDefaultIconSize; | 571 int icon_size = kDefaultIconSize; |
| 568 if (ShouldShowEVBubble()) { | 572 if (ShouldShowEVBubble()) { |
| 569 vector_icon_id = gfx::VectorIconId::LOCATION_BAR_HTTPS_VALID_IN_CHIP; | 573 vector_icon_id = gfx::VectorIconId::LOCATION_BAR_HTTPS_VALID_IN_CHIP; |
| 570 vector_icon_color = gfx::kGoogleGreen700; | 574 vector_icon_color = in_dark_mode |
| 571 icon_size = kMaterialSmallIconSize; | 575 ? LocationBarDecoration::kMaterialDarkModeTextColor |
| 576 : gfx::kGoogleGreen700; |
| 577 icon_size = kMaterialIconSize; |
| 572 } else { | 578 } else { |
| 573 vector_icon_id = omnibox_view_->GetVectorIcon(in_dark_mode); | 579 vector_icon_id = omnibox_view_->GetVectorIcon(in_dark_mode); |
| 574 if (in_dark_mode) { | 580 if (in_dark_mode) { |
| 575 vector_icon_color = SK_ColorWHITE; | 581 vector_icon_color = SK_ColorWHITE; |
| 576 } else { | 582 } else { |
| 577 vector_icon_color = OmniboxViewMac::BaseTextColorSkia(in_dark_mode); | 583 vector_icon_color = OmniboxViewMac::BaseTextColorSkia(in_dark_mode); |
| 578 } | 584 } |
| 579 } | 585 } |
| 580 | 586 |
| 581 DCHECK(vector_icon_id != gfx::VectorIconId::VECTOR_ICON_NONE); | 587 DCHECK(vector_icon_id != gfx::VectorIconId::VECTOR_ICON_NONE); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 659 | 665 |
| 660 NSImage* LocationBarViewMac::GetKeywordImage(const base::string16& keyword) { | 666 NSImage* LocationBarViewMac::GetKeywordImage(const base::string16& keyword) { |
| 661 const TemplateURL* template_url = TemplateURLServiceFactory::GetForProfile( | 667 const TemplateURL* template_url = TemplateURLServiceFactory::GetForProfile( |
| 662 profile())->GetTemplateURLForKeyword(keyword); | 668 profile())->GetTemplateURLForKeyword(keyword); |
| 663 if (template_url && | 669 if (template_url && |
| 664 (template_url->GetType() == TemplateURL::OMNIBOX_API_EXTENSION)) { | 670 (template_url->GetType() == TemplateURL::OMNIBOX_API_EXTENSION)) { |
| 665 return extensions::OmniboxAPI::Get(profile())-> | 671 return extensions::OmniboxAPI::Get(profile())-> |
| 666 GetOmniboxIcon(template_url->GetExtensionId()).AsNSImage(); | 672 GetOmniboxIcon(template_url->GetExtensionId()).AsNSImage(); |
| 667 } | 673 } |
| 668 | 674 |
| 669 return ui::MaterialDesignController::IsModeMaterial() | 675 if (ui::MaterialDesignController::IsModeMaterial()) { |
| 670 ? NSImageFromImageSkiaWithColorSpace( | 676 SkColor icon_color = IsLocationBarDark() ? kMaterialDarkVectorIconColor |
| 671 gfx::CreateVectorIcon( | 677 : gfx::kGoogleBlue700; |
| 672 gfx::VectorIconId::OMNIBOX_SEARCH, | 678 return NSImageFromImageSkiaWithColorSpace( |
| 673 kDefaultIconSize, | 679 gfx::CreateVectorIcon(gfx::VectorIconId::OMNIBOX_SEARCH, |
| 674 gfx::kGoogleBlue700), | 680 kDefaultIconSize, icon_color), |
| 675 base::mac::GetSRGBColorSpace()) | 681 base::mac::GetSRGBColorSpace()); |
| 676 : OmniboxViewMac::ImageForResource(IDR_OMNIBOX_SEARCH); | 682 } |
| 683 |
| 684 return OmniboxViewMac::ImageForResource(IDR_OMNIBOX_SEARCH); |
| 677 } | 685 } |
| 678 | 686 |
| 679 void LocationBarViewMac::PostNotification(NSString* notification) { | 687 void LocationBarViewMac::PostNotification(NSString* notification) { |
| 680 [[NSNotificationCenter defaultCenter] postNotificationName:notification | 688 [[NSNotificationCenter defaultCenter] postNotificationName:notification |
| 681 object:[NSValue valueWithPointer:this]]; | 689 object:[NSValue valueWithPointer:this]]; |
| 682 } | 690 } |
| 683 | 691 |
| 684 PageActionDecoration* LocationBarViewMac::GetPageActionDecoration( | 692 PageActionDecoration* LocationBarViewMac::GetPageActionDecoration( |
| 685 ExtensionAction* page_action) { | 693 ExtensionAction* page_action) { |
| 686 DCHECK(page_action); | 694 DCHECK(page_action); |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 807 | 815 |
| 808 return zoom_decoration_->UpdateIfNecessary( | 816 return zoom_decoration_->UpdateIfNecessary( |
| 809 ui_zoom::ZoomController::FromWebContents(web_contents), | 817 ui_zoom::ZoomController::FromWebContents(web_contents), |
| 810 default_zoom_changed, IsLocationBarDark()); | 818 default_zoom_changed, IsLocationBarDark()); |
| 811 } | 819 } |
| 812 | 820 |
| 813 void LocationBarViewMac::OnDefaultZoomLevelChanged() { | 821 void LocationBarViewMac::OnDefaultZoomLevelChanged() { |
| 814 if (UpdateZoomDecoration(/*default_zoom_changed=*/true)) | 822 if (UpdateZoomDecoration(/*default_zoom_changed=*/true)) |
| 815 OnDecorationsChanged(); | 823 OnDecorationsChanged(); |
| 816 } | 824 } |
| OLD | NEW |