| Index: chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm
|
| diff --git a/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm b/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm
|
| index 47387327fd660ee3db3fd4a5ed91aa564b724d46..ed593fabe1da5838999d3f71a3176296bbb39fac 100644
|
| --- a/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm
|
| +++ b/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm
|
| @@ -40,6 +40,7 @@
|
| #import "chrome/browser/ui/cocoa/location_bar/manage_passwords_decoration.h"
|
| #import "chrome/browser/ui/cocoa/location_bar/page_action_decoration.h"
|
| #import "chrome/browser/ui/cocoa/location_bar/save_credit_card_decoration.h"
|
| +#import "chrome/browser/ui/cocoa/location_bar/secure_verbose_bubble_decoration.h"
|
| #import "chrome/browser/ui/cocoa/location_bar/selected_keyword_decoration.h"
|
| #import "chrome/browser/ui/cocoa/location_bar/star_decoration.h"
|
| #import "chrome/browser/ui/cocoa/location_bar/translate_decoration.h"
|
| @@ -57,7 +58,6 @@
|
| #include "components/prefs/pref_service.h"
|
| #include "components/search_engines/template_url.h"
|
| #include "components/search_engines/template_url_service.h"
|
| -#include "components/security_state/security_state_model.h"
|
| #include "components/translate/core/browser/language_state.h"
|
| #include "components/zoom/zoom_controller.h"
|
| #include "components/zoom/zoom_event_manager.h"
|
| @@ -72,6 +72,7 @@
|
| #include "ui/base/material_design/material_design_controller.h"
|
| #include "ui/gfx/color_palette.h"
|
| #include "ui/gfx/color_utils.h"
|
| +#include "ui/gfx/geometry/cubic_bezier.h"
|
| #include "ui/gfx/image/image.h"
|
| #include "ui/gfx/image/image_skia_util_mac.h"
|
| #include "ui/gfx/paint_vector_icon.h"
|
| @@ -106,6 +107,9 @@ LocationBarViewMac::LocationBarViewMac(AutocompleteTextField* field,
|
| field_(field),
|
| location_icon_decoration_(new LocationIconDecoration(this)),
|
| selected_keyword_decoration_(new SelectedKeywordDecoration()),
|
| + secure_verbose_bubble_decoration_(
|
| + new SecureVerboseBubbleDecoration(location_icon_decoration_.get(),
|
| + this)),
|
| ev_bubble_decoration_(
|
| new EVBubbleDecoration(location_icon_decoration_.get())),
|
| save_credit_card_decoration_(
|
| @@ -392,7 +396,10 @@ NSPoint LocationBarViewMac::GetManagePasswordsBubblePoint() const {
|
| }
|
|
|
| NSPoint LocationBarViewMac::GetPageInfoBubblePoint() const {
|
| - if (ev_bubble_decoration_->IsVisible()) {
|
| + if (secure_verbose_bubble_decoration_->IsVisible()) {
|
| + return [field_
|
| + bubblePointForDecoration:secure_verbose_bubble_decoration_.get()];
|
| + } else if (ev_bubble_decoration_->IsVisible()) {
|
| return [field_ bubblePointForDecoration:ev_bubble_decoration_.get()];
|
| } else {
|
| return [field_ bubblePointForDecoration:location_icon_decoration_.get()];
|
| @@ -422,6 +429,7 @@ void LocationBarViewMac::Layout() {
|
| [cell clearDecorations];
|
| [cell addLeftDecoration:location_icon_decoration_.get()];
|
| [cell addLeftDecoration:selected_keyword_decoration_.get()];
|
| + [cell addLeftDecoration:secure_verbose_bubble_decoration_.get()];
|
| [cell addLeftDecoration:ev_bubble_decoration_.get()];
|
| [cell addRightDecoration:star_decoration_.get()];
|
| [cell addRightDecoration:translate_decoration_.get()];
|
| @@ -445,6 +453,7 @@ void LocationBarViewMac::Layout() {
|
| // By default only the location icon is visible.
|
| location_icon_decoration_->SetVisible(true);
|
| selected_keyword_decoration_->SetVisible(false);
|
| + secure_verbose_bubble_decoration_->SetVisible(false);
|
| ev_bubble_decoration_->SetVisible(false);
|
| keyword_hint_decoration_->SetVisible(false);
|
|
|
| @@ -468,6 +477,9 @@ void LocationBarViewMac::Layout() {
|
| // Design we need to set its color, which we cannot do until we know the
|
| // theme (by being installed in a browser window).
|
| selected_keyword_decoration_->SetImage(GetKeywordImage(keyword));
|
| + } else if (!keyword.empty() && is_keyword_hint) {
|
| + keyword_hint_decoration_->SetKeyword(short_name, is_extension_keyword);
|
| + keyword_hint_decoration_->SetVisible(true);
|
| } else if (ShouldShowEVBubble()) {
|
| // Switch from location icon to show the EV bubble instead.
|
| location_icon_decoration_->SetVisible(false);
|
| @@ -475,10 +487,13 @@ void LocationBarViewMac::Layout() {
|
|
|
| base::string16 label(GetToolbarModel()->GetEVCertName());
|
| ev_bubble_decoration_->SetFullLabel(base::SysUTF16ToNSString(label));
|
| - } else if (!keyword.empty() && is_keyword_hint) {
|
| - keyword_hint_decoration_->SetKeyword(short_name,
|
| - is_extension_keyword);
|
| - keyword_hint_decoration_->SetVisible(true);
|
| + } else if (ShouldShowSecureVerbose()) {
|
| + location_icon_decoration_->SetVisible(false);
|
| + secure_verbose_bubble_decoration_->SetVisible(true);
|
| +
|
| + base::string16 label(GetToolbarModel()->GetSecureVerboseText());
|
| + secure_verbose_bubble_decoration_->SetFullLabel(
|
| + base::SysUTF16ToNSString(label));
|
| }
|
|
|
| // These need to change anytime the layout changes.
|
| @@ -566,33 +581,12 @@ void LocationBarViewMac::UpdateWithoutTabRestore() {
|
| Update(nullptr);
|
| }
|
|
|
| +// TODO(spqchan): Animate the secure verbose chip. crbug.com/622529
|
| void LocationBarViewMac::UpdateLocationIcon() {
|
| - bool in_dark_mode = IsLocationBarDark();
|
| -
|
| - SkColor vector_icon_color = gfx::kPlaceholderColor;
|
| - gfx::VectorIconId vector_icon_id = gfx::VectorIconId::VECTOR_ICON_NONE;
|
| - if (ShouldShowEVBubble()) {
|
| - vector_icon_id = gfx::VectorIconId::LOCATION_BAR_HTTPS_VALID;
|
| - vector_icon_color = gfx::kGoogleGreen700;
|
| - } else {
|
| - vector_icon_id = omnibox_view_->GetVectorIcon();
|
| - security_state::SecurityStateModel::SecurityLevel security_level =
|
| - GetToolbarModel()->GetSecurityLevel(false);
|
| - if (security_level == security_state::SecurityStateModel::NONE) {
|
| - vector_icon_color = gfx::kChromeIconGrey;
|
| - } else {
|
| - NSColor* sRGBColor =
|
| - OmniboxViewMac::GetSecureTextColor(security_level, in_dark_mode);
|
| - NSColor* deviceColor =
|
| - [sRGBColor colorUsingColorSpace:[NSColorSpace deviceRGBColorSpace]];
|
| - vector_icon_color = skia::NSDeviceColorToSkColor(deviceColor);
|
| - }
|
| - }
|
| -
|
| - // If the theme is dark, then the color should always be
|
| - // kMaterialDarkVectorIconColor.
|
| - if (in_dark_mode)
|
| - vector_icon_color = kMaterialDarkVectorIconColor;
|
| + SkColor vector_icon_color = GetLocationBarIconColor();
|
| + gfx::VectorIconId vector_icon_id =
|
| + ShouldShowEVBubble() ? gfx::VectorIconId::LOCATION_BAR_HTTPS_VALID
|
| + : omnibox_view_->GetVectorIcon();
|
|
|
| DCHECK(vector_icon_id != gfx::VectorIconId::VECTOR_ICON_NONE);
|
| NSImage* image = NSImageFromImageSkiaWithColorSpace(
|
| @@ -601,7 +595,13 @@ void LocationBarViewMac::UpdateLocationIcon() {
|
| base::mac::GetSRGBColorSpace());
|
| location_icon_decoration_->SetImage(image);
|
| ev_bubble_decoration_->SetImage(image);
|
| + secure_verbose_bubble_decoration_->SetImage(image);
|
| + secure_verbose_bubble_decoration_->SetLabelColor(vector_icon_color);
|
| +
|
| Layout();
|
| +
|
| + if (ShouldShowSecureVerbose())
|
| + secure_verbose_bubble_decoration_->StartAnimation();
|
| }
|
|
|
| void LocationBarViewMac::UpdateColorsToMatchTheme() {
|
| @@ -636,7 +636,7 @@ void LocationBarViewMac::OnChanged() {
|
| const int resource_id = omnibox_view_->GetIcon();
|
| NSImage* image = OmniboxViewMac::ImageForResource(resource_id);
|
| location_icon_decoration_->SetImage(image);
|
| - ev_bubble_decoration_->SetImage(image);
|
| + secure_verbose_bubble_decoration_->SetImage(image);
|
| Layout();
|
| return;
|
| }
|
| @@ -664,6 +664,14 @@ bool LocationBarViewMac::ShouldShowEVBubble() const {
|
| security_state::SecurityStateModel::EV_SECURE);
|
| }
|
|
|
| +bool LocationBarViewMac::ShouldShowSecureVerbose() const {
|
| + return ui::MaterialDesignController::IsModeMaterial() &&
|
| + !omnibox_view_->IsEditingOrEmpty() &&
|
| + !omnibox_view_->model()->is_keyword_hint() && !ShouldShowEVBubble() &&
|
| + GetToolbarModel()->GetSecurityLevel(false) !=
|
| + security_state::SecurityStateModel::NONE;
|
| +}
|
| +
|
| bool LocationBarViewMac::IsLocationBarDark() const {
|
| return [[field_ window] inIncognitoModeWithSystemTheme];
|
| }
|
| @@ -689,6 +697,27 @@ NSImage* LocationBarViewMac::GetKeywordImage(const base::string16& keyword) {
|
| return OmniboxViewMac::ImageForResource(IDR_OMNIBOX_SEARCH);
|
| }
|
|
|
| +SkColor LocationBarViewMac::GetLocationBarIconColor() const {
|
| + bool in_dark_mode = IsLocationBarDark();
|
| + if (in_dark_mode)
|
| + return kMaterialDarkVectorIconColor;
|
| +
|
| + if (ShouldShowEVBubble())
|
| + return gfx::kGoogleGreen700;
|
| +
|
| + security_state::SecurityStateModel::SecurityLevel security_level =
|
| + GetToolbarModel()->GetSecurityLevel(false);
|
| +
|
| + if (security_level == security_state::SecurityStateModel::NONE)
|
| + return gfx::kChromeIconGrey;
|
| +
|
| + NSColor* sRGBColor =
|
| + OmniboxViewMac::GetSecureTextColor(security_level, in_dark_mode);
|
| + NSColor* deviceColor =
|
| + [sRGBColor colorUsingColorSpace:[NSColorSpace deviceRGBColorSpace]];
|
| + return skia::NSDeviceColorToSkColor(deviceColor);
|
| +}
|
| +
|
| void LocationBarViewMac::PostNotification(NSString* notification) {
|
| [[NSNotificationCenter defaultCenter] postNotificationName:notification
|
| object:[NSValue valueWithPointer:this]];
|
| @@ -839,6 +868,7 @@ std::vector<LocationBarDecoration*> LocationBarViewMac::GetDecorations() {
|
| // are page actions and the keyword hint.
|
| decorations.push_back(location_icon_decoration_.get());
|
| decorations.push_back(selected_keyword_decoration_.get());
|
| + decorations.push_back(secure_verbose_bubble_decoration_.get());
|
| decorations.push_back(ev_bubble_decoration_.get());
|
| decorations.push_back(save_credit_card_decoration_.get());
|
| decorations.push_back(star_decoration_.get());
|
|
|