Chromium Code Reviews| 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 4048f5830a7266896d33b219ab07557f0477c05a..ebe0038fb53075b84ff2158889e50907ca8c71de 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 |
| @@ -34,12 +34,12 @@ |
| #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.h" |
| #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h" |
| #import "chrome/browser/ui/cocoa/location_bar/content_setting_decoration.h" |
| -#import "chrome/browser/ui/cocoa/location_bar/ev_bubble_decoration.h" |
| #import "chrome/browser/ui/cocoa/location_bar/keyword_hint_decoration.h" |
| #import "chrome/browser/ui/cocoa/location_bar/location_icon_decoration.h" |
| #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 +57,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" |
| @@ -278,8 +277,9 @@ LocationBarViewMac::LocationBarViewMac(AutocompleteTextField* field, |
| field_(field), |
| location_icon_decoration_(new LocationIconDecoration(this)), |
| selected_keyword_decoration_(new SelectedKeywordDecoration()), |
| - ev_bubble_decoration_( |
| - new EVBubbleDecoration(location_icon_decoration_.get())), |
| + secure_verbose_bubble_decoration_( |
| + new SecureVerboseBubbleDecoration(location_icon_decoration_.get(), |
| + this)), |
| save_credit_card_decoration_( |
| new SaveCreditCardDecoration(command_updater)), |
| star_decoration_(new StarDecoration(command_updater)), |
| @@ -564,8 +564,9 @@ NSPoint LocationBarViewMac::GetManagePasswordsBubblePoint() const { |
| } |
| NSPoint LocationBarViewMac::GetPageInfoBubblePoint() const { |
| - if (ev_bubble_decoration_->IsVisible()) { |
| - return [field_ bubblePointForDecoration:ev_bubble_decoration_.get()]; |
| + if (secure_verbose_bubble_decoration_->IsVisible()) { |
| + return [field_ |
| + bubblePointForDecoration:secure_verbose_bubble_decoration_.get()]; |
| } else { |
| return [field_ bubblePointForDecoration:location_icon_decoration_.get()]; |
| } |
| @@ -591,7 +592,7 @@ void LocationBarViewMac::Layout() { |
| [cell clearDecorations]; |
| [cell addLeftDecoration:location_icon_decoration_.get()]; |
| [cell addLeftDecoration:selected_keyword_decoration_.get()]; |
| - [cell addLeftDecoration:ev_bubble_decoration_.get()]; |
| + [cell addLeftDecoration:secure_verbose_bubble_decoration_.get()]; |
| [cell addRightDecoration:star_decoration_.get()]; |
| [cell addRightDecoration:translate_decoration_.get()]; |
| [cell addRightDecoration:zoom_decoration_.get()]; |
| @@ -614,7 +615,7 @@ void LocationBarViewMac::Layout() { |
| // By default only the location icon is visible. |
| location_icon_decoration_->SetVisible(true); |
| selected_keyword_decoration_->SetVisible(false); |
| - ev_bubble_decoration_->SetVisible(false); |
| + secure_verbose_bubble_decoration_->SetVisible(false); |
| keyword_hint_decoration_->SetVisible(false); |
| // Get the keyword to use for keyword-search and hinting. |
| @@ -637,17 +638,19 @@ 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 (ShouldShowEVBubble()) { |
| - // Switch from location icon to show the EV bubble instead. |
| - location_icon_decoration_->SetVisible(false); |
| - ev_bubble_decoration_->SetVisible(true); |
| - |
| - 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_->SetKeyword(short_name, is_extension_keyword); |
| keyword_hint_decoration_->SetVisible(true); |
| + } else if (ShouldShowSecureVerbose()) { |
| + // Switch from location icon to show the SecureVerbose bubble instead. |
| + location_icon_decoration_->SetVisible(false); |
| + secure_verbose_bubble_decoration_->SetVisible(true); |
| + |
| + base::string16 label = ShouldShowEVBubble() |
| + ? GetToolbarModel()->GetEVCertName() |
| + : GetToolbarModel()->GetSecureVerboseText(); |
| + secure_verbose_bubble_decoration_->SetFullLabel( |
| + base::SysUTF16ToNSString(label)); |
| } |
| // These need to change anytime the layout changes. |
| @@ -736,40 +739,47 @@ void LocationBarViewMac::UpdateWithoutTabRestore() { |
| } |
| 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 = |
| [LocationBarImageRep imageForId:vector_icon_id color:vector_icon_color]; |
| - |
| location_icon_decoration_->SetImage(image); |
| - ev_bubble_decoration_->SetImage(image); |
| + secure_verbose_bubble_decoration_->SetImage(image); |
| + secure_verbose_bubble_decoration_->SetLabelColor( |
| + skia::SkColorToSRGBNSColor(vector_icon_color)); |
| + |
| Layout(); |
| + |
| + // If we are showing a new secure verbose, we will have to animate the |
| + // decoration. In order to determine if the secure verbose is new, we need |
| + // to check if the EV cert is different (if we're showing the EV bubble) or |
| + // if the security level has changed. |
| + security_state::SecurityStateModel::SecurityLevel current_security = |
| + GetToolbarModel()->GetSecurityLevel(false); |
| + |
| + if (ShouldShowSecureVerbose()) { |
| + bool should_start_animation = false; |
| + if (ShouldShowEVBubble()) { |
| + scoped_refptr<net::X509Certificate> updated_cert = |
| + GetToolbarModel()->GetCertificate(); |
| + if (!certificate_.get() || !certificate_->Equals(updated_cert.get())) { |
| + certificate_ = updated_cert; |
| + should_start_animation = true; |
| + } |
| + } else { |
| + certificate_ = scoped_refptr<net::X509Certificate>(); |
| + if (security_level_ != current_security) |
| + should_start_animation = true; |
| + } |
| + if (should_start_animation) |
| + secure_verbose_bubble_decoration_->StartAnimation(); |
| + } |
| + |
| + security_level_ = current_security; |
| } |
| void LocationBarViewMac::UpdateColorsToMatchTheme() { |
| @@ -804,7 +814,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; |
| } |
| @@ -832,6 +842,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() && |
| + GetToolbarModel()->GetSecurityLevel(false) != |
| + security_state::SecurityStateModel::NONE; |
| +} |
| + |
| bool LocationBarViewMac::IsLocationBarDark() const { |
| return [[field_ window] inIncognitoModeWithSystemTheme]; |
| } |
| @@ -857,6 +875,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]]; |
| @@ -950,7 +989,7 @@ void LocationBarViewMac::ShowFirstRunBubbleInternal() { |
| if (!field_ || ![field_ window]) |
| return; |
| - // The first run bubble's left edge should line up with the left edge of the |
| + // The first run bubble's left edge should line up with the left eƒdge of the |
|
upolat
2016/07/08 22:17:59
typo: edge?
spqchan
2016/07/11 17:57:08
Done.
|
| // omnibox. This is different from other bubbles, which line up at a point |
| // set by their top arrow. Because the BaseBubbleController adjusts the |
| // window origin left to account for the arrow spacing, the first run bubble |