| 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 #import "base/mac/mac_util.h" | 8 #import "base/mac/mac_util.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" | 49 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" |
| 50 #include "chrome/browser/ui/content_settings/content_setting_image_model.h" | 50 #include "chrome/browser/ui/content_settings/content_setting_image_model.h" |
| 51 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" | 51 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" |
| 52 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 52 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 53 #include "chrome/common/pref_names.h" | 53 #include "chrome/common/pref_names.h" |
| 54 #include "chrome/grit/chromium_strings.h" | 54 #include "chrome/grit/chromium_strings.h" |
| 55 #include "chrome/grit/theme_resources.h" | 55 #include "chrome/grit/theme_resources.h" |
| 56 #include "components/bookmarks/common/bookmark_pref_names.h" | 56 #include "components/bookmarks/common/bookmark_pref_names.h" |
| 57 #include "components/grit/components_scaled_resources.h" | 57 #include "components/grit/components_scaled_resources.h" |
| 58 #import "components/omnibox/browser/omnibox_popup_model.h" | 58 #import "components/omnibox/browser/omnibox_popup_model.h" |
| 59 #include "components/omnibox/browser/vector_icons.h" |
| 59 #include "components/prefs/pref_service.h" | 60 #include "components/prefs/pref_service.h" |
| 60 #include "components/search_engines/template_url.h" | 61 #include "components/search_engines/template_url.h" |
| 61 #include "components/search_engines/template_url_service.h" | 62 #include "components/search_engines/template_url_service.h" |
| 63 #include "components/toolbar/vector_icons.h" |
| 62 #include "components/translate/core/browser/language_state.h" | 64 #include "components/translate/core/browser/language_state.h" |
| 63 #include "components/variations/variations_associated_data.h" | 65 #include "components/variations/variations_associated_data.h" |
| 64 #include "components/zoom/zoom_controller.h" | 66 #include "components/zoom/zoom_controller.h" |
| 65 #include "components/zoom/zoom_event_manager.h" | 67 #include "components/zoom/zoom_event_manager.h" |
| 66 #include "content/public/browser/web_contents.h" | 68 #include "content/public/browser/web_contents.h" |
| 67 #include "content/public/common/url_constants.h" | 69 #include "content/public/common/url_constants.h" |
| 68 #include "extensions/browser/extension_system.h" | 70 #include "extensions/browser/extension_system.h" |
| 69 #include "extensions/common/extension.h" | 71 #include "extensions/common/extension.h" |
| 70 #include "skia/ext/skia_utils_mac.h" | 72 #include "skia/ext/skia_utils_mac.h" |
| 71 #import "ui/base/cocoa/cocoa_base_utils.h" | 73 #import "ui/base/cocoa/cocoa_base_utils.h" |
| 72 #include "ui/base/l10n/l10n_util_mac.h" | 74 #include "ui/base/l10n/l10n_util_mac.h" |
| 73 #include "ui/base/material_design/material_design_controller.h" | 75 #include "ui/base/material_design/material_design_controller.h" |
| 74 #include "ui/gfx/color_palette.h" | 76 #include "ui/gfx/color_palette.h" |
| 75 #include "ui/gfx/color_utils.h" | 77 #include "ui/gfx/color_utils.h" |
| 76 #include "ui/gfx/image/image.h" | 78 #include "ui/gfx/image/image.h" |
| 77 #include "ui/gfx/image/image_skia_util_mac.h" | 79 #include "ui/gfx/image/image_skia_util_mac.h" |
| 78 #include "ui/gfx/paint_vector_icon.h" | 80 #include "ui/gfx/paint_vector_icon.h" |
| 79 #include "ui/gfx/vector_icons_public.h" | |
| 80 | 81 |
| 81 using content::WebContents; | 82 using content::WebContents; |
| 82 | 83 |
| 83 namespace { | 84 namespace { |
| 84 | 85 |
| 85 // Vertical space between the bottom edge of the location_bar and the first run | 86 // Vertical space between the bottom edge of the location_bar and the first run |
| 86 // bubble arrow point. | 87 // bubble arrow point. |
| 87 const static int kFirstRunBubbleYOffset = 1; | 88 const static int kFirstRunBubbleYOffset = 1; |
| 88 | 89 |
| 89 const int kDefaultIconSize = 16; | 90 const int kDefaultIconSize = 16; |
| (...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 | 600 |
| 600 OnChanged(); | 601 OnChanged(); |
| 601 } | 602 } |
| 602 | 603 |
| 603 void LocationBarViewMac::UpdateWithoutTabRestore() { | 604 void LocationBarViewMac::UpdateWithoutTabRestore() { |
| 604 Update(nullptr); | 605 Update(nullptr); |
| 605 } | 606 } |
| 606 | 607 |
| 607 void LocationBarViewMac::UpdateLocationIcon() { | 608 void LocationBarViewMac::UpdateLocationIcon() { |
| 608 SkColor vector_icon_color = GetLocationBarIconColor(); | 609 SkColor vector_icon_color = GetLocationBarIconColor(); |
| 609 gfx::VectorIconId vector_icon_id = | 610 const gfx::VectorIcon& vector_icon_id = ShouldShowEVBubble() |
| 610 ShouldShowEVBubble() ? gfx::VectorIconId::LOCATION_BAR_HTTPS_VALID | 611 ? toolbar::kHttpsValidIcon |
| 611 : omnibox_view_->GetVectorIcon(); | 612 : omnibox_view_->GetVectorIcon(); |
| 612 | 613 |
| 613 DCHECK(vector_icon_id != gfx::VectorIconId::VECTOR_ICON_NONE); | |
| 614 NSImage* image = NSImageFromImageSkiaWithColorSpace( | 614 NSImage* image = NSImageFromImageSkiaWithColorSpace( |
| 615 gfx::CreateVectorIcon(vector_icon_id, kDefaultIconSize, | 615 gfx::CreateVectorIcon(vector_icon_id, kDefaultIconSize, |
| 616 vector_icon_color), | 616 vector_icon_color), |
| 617 base::mac::GetSRGBColorSpace()); | 617 base::mac::GetSRGBColorSpace()); |
| 618 location_icon_decoration_->SetImage(image); | 618 location_icon_decoration_->SetImage(image); |
| 619 security_state_bubble_decoration_->SetImage(image); | 619 security_state_bubble_decoration_->SetImage(image); |
| 620 security_state_bubble_decoration_->SetLabelColor(vector_icon_color); | 620 security_state_bubble_decoration_->SetLabelColor(vector_icon_color); |
| 621 | 621 |
| 622 Layout(); | 622 Layout(); |
| 623 } | 623 } |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 707 profile())->GetTemplateURLForKeyword(keyword); | 707 profile())->GetTemplateURLForKeyword(keyword); |
| 708 if (template_url && | 708 if (template_url && |
| 709 (template_url->type() == TemplateURL::OMNIBOX_API_EXTENSION)) { | 709 (template_url->type() == TemplateURL::OMNIBOX_API_EXTENSION)) { |
| 710 return extensions::OmniboxAPI::Get(profile())-> | 710 return extensions::OmniboxAPI::Get(profile())-> |
| 711 GetOmniboxIcon(template_url->GetExtensionId()).AsNSImage(); | 711 GetOmniboxIcon(template_url->GetExtensionId()).AsNSImage(); |
| 712 } | 712 } |
| 713 | 713 |
| 714 SkColor icon_color = | 714 SkColor icon_color = |
| 715 IsLocationBarDark() ? kMaterialDarkVectorIconColor : gfx::kGoogleBlue700; | 715 IsLocationBarDark() ? kMaterialDarkVectorIconColor : gfx::kGoogleBlue700; |
| 716 return NSImageFromImageSkiaWithColorSpace( | 716 return NSImageFromImageSkiaWithColorSpace( |
| 717 gfx::CreateVectorIcon(gfx::VectorIconId::OMNIBOX_SEARCH, kDefaultIconSize, | 717 gfx::CreateVectorIcon(omnibox::kSearchIcon, kDefaultIconSize, icon_color), |
| 718 icon_color), | |
| 719 base::mac::GetSRGBColorSpace()); | 718 base::mac::GetSRGBColorSpace()); |
| 720 } | 719 } |
| 721 | 720 |
| 722 SkColor LocationBarViewMac::GetLocationBarIconColor() const { | 721 SkColor LocationBarViewMac::GetLocationBarIconColor() const { |
| 723 bool in_dark_mode = IsLocationBarDark(); | 722 bool in_dark_mode = IsLocationBarDark(); |
| 724 if (in_dark_mode) | 723 if (in_dark_mode) |
| 725 return kMaterialDarkVectorIconColor; | 724 return kMaterialDarkVectorIconColor; |
| 726 | 725 |
| 727 if (ShouldShowEVBubble()) | 726 if (ShouldShowEVBubble()) |
| 728 return gfx::kGoogleGreen700; | 727 return gfx::kGoogleGreen700; |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 945 OnDecorationsChanged(); | 944 OnDecorationsChanged(); |
| 946 } | 945 } |
| 947 | 946 |
| 948 std::vector<NSView*> LocationBarViewMac::GetDecorationAccessibilityViews() { | 947 std::vector<NSView*> LocationBarViewMac::GetDecorationAccessibilityViews() { |
| 949 std::vector<LocationBarDecoration*> decorations = GetDecorations(); | 948 std::vector<LocationBarDecoration*> decorations = GetDecorations(); |
| 950 std::vector<NSView*> views; | 949 std::vector<NSView*> views; |
| 951 for (auto* decoration : decorations) | 950 for (auto* decoration : decorations) |
| 952 views.push_back(decoration->GetAccessibilityView()); | 951 views.push_back(decoration->GetAccessibilityView()); |
| 953 return views; | 952 return views; |
| 954 } | 953 } |
| OLD | NEW |