Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" | 5 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/browser/ssl/chrome_security_state_model_client.h" | 8 #include "chrome/browser/ssl/chrome_security_state_model_client.h" |
| 9 #include "chrome/browser/ui/view_ids.h" | 9 #include "chrome/browser/ui/view_ids.h" |
| 10 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 10 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 11 #include "chrome/browser/ui/views/website_settings/website_settings_popup_view.h " | 11 #include "chrome/browser/ui/views/website_settings/website_settings_popup_view.h " |
| 12 #include "chrome/grit/generated_resources.h" | 12 #include "chrome/grit/generated_resources.h" |
| 13 #include "chrome/grit/theme_resources.h" | 13 #include "chrome/grit/theme_resources.h" |
| 14 #include "components/grit/components_scaled_resources.h" | 14 #include "components/grit/components_scaled_resources.h" |
| 15 #include "components/omnibox/browser/omnibox_edit_model.h" | 15 #include "components/omnibox/browser/omnibox_edit_model.h" |
| 16 #include "content/public/browser/navigation_controller.h" | 16 #include "content/public/browser/navigation_controller.h" |
| 17 #include "content/public/browser/navigation_entry.h" | 17 #include "content/public/browser/navigation_entry.h" |
| 18 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
| 19 #include "ui/base/l10n/l10n_util.h" | 19 #include "ui/base/l10n/l10n_util.h" |
| 20 #include "ui/base/material_design/material_design_controller.h" | |
| 21 #include "ui/gfx/color_palette.h" | 20 #include "ui/gfx/color_palette.h" |
| 22 #include "ui/views/controls/label.h" | 21 #include "ui/views/controls/label.h" |
| 23 #include "ui/views/painter.h" | 22 #include "ui/views/painter.h" |
| 24 | 23 |
| 25 using content::NavigationEntry; | 24 using content::NavigationEntry; |
| 26 using content::WebContents; | 25 using content::WebContents; |
| 27 | 26 |
| 28 LocationIconView::LocationIconView(const gfx::FontList& font_list, | 27 LocationIconView::LocationIconView(const gfx::FontList& font_list, |
| 29 SkColor parent_background_color, | |
| 30 LocationBarView* location_bar) | 28 LocationBarView* location_bar) |
| 31 : IconLabelBubbleView(IDR_OMNIBOX_HTTPS_INVALID, | 29 : IconLabelBubbleView(font_list, true), |
| 32 font_list, | |
| 33 parent_background_color, | |
| 34 true), | |
| 35 suppress_mouse_released_action_(false), | 30 suppress_mouse_released_action_(false), |
| 36 location_bar_(location_bar), | 31 location_bar_(location_bar), |
| 37 animation_(this) { | 32 animation_(this) { |
| 38 set_id(VIEW_ID_LOCATION_ICON); | 33 set_id(VIEW_ID_LOCATION_ICON); |
| 39 | 34 |
| 40 #if defined(OS_MACOSX) | 35 #if defined(OS_MACOSX) |
| 41 SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY); | 36 SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY); |
| 42 #else | 37 #else |
| 43 SetFocusBehavior(FocusBehavior::ALWAYS); | 38 SetFocusBehavior(FocusBehavior::ALWAYS); |
| 44 #endif | 39 #endif |
| 45 | 40 |
| 46 SetBackground(false); | |
| 47 animation_.SetSlideDuration(kOpenTimeMS); | 41 animation_.SetSlideDuration(kOpenTimeMS); |
| 48 } | 42 } |
| 49 | 43 |
| 50 LocationIconView::~LocationIconView() { | 44 LocationIconView::~LocationIconView() { |
| 51 } | 45 } |
| 52 | 46 |
| 53 gfx::Size LocationIconView::GetMinimumSize() const { | 47 gfx::Size LocationIconView::GetMinimumSize() const { |
| 54 return GetMinimumSizeForPreferredSize(GetPreferredSize()); | 48 return GetMinimumSizeForPreferredSize(GetPreferredSize()); |
| 55 } | 49 } |
| 56 | 50 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 98 } | 92 } |
| 99 | 93 |
| 100 bool LocationIconView::GetTooltipText(const gfx::Point& p, | 94 bool LocationIconView::GetTooltipText(const gfx::Point& p, |
| 101 base::string16* tooltip) const { | 95 base::string16* tooltip) const { |
| 102 if (show_tooltip_) | 96 if (show_tooltip_) |
| 103 *tooltip = l10n_util::GetStringUTF16(IDS_TOOLTIP_LOCATION_ICON); | 97 *tooltip = l10n_util::GetStringUTF16(IDS_TOOLTIP_LOCATION_ICON); |
| 104 return show_tooltip_; | 98 return show_tooltip_; |
| 105 } | 99 } |
| 106 | 100 |
| 107 SkColor LocationIconView::GetTextColor() const { | 101 SkColor LocationIconView::GetTextColor() const { |
| 102 NOTIMPLEMENTED() << " HITTING THIS"; | |
|
Peter Kasting
2016/09/19 23:46:46
Um.
Should we ever reach here? Maybe the right t
Evan Stade
2016/09/20 17:37:04
oops
yes we need this function still. We don't ne
| |
| 108 return location_bar_->GetColor(LocationBarView::SECURITY_CHIP_TEXT); | 103 return location_bar_->GetColor(LocationBarView::SECURITY_CHIP_TEXT); |
| 109 } | 104 } |
| 110 | 105 |
| 111 SkColor LocationIconView::GetBorderColor() const { | 106 SkColor LocationIconView::GetBorderColor() const { |
| 112 return GetTextColor(); | 107 return GetTextColor(); |
| 113 } | 108 } |
| 114 | 109 |
| 115 bool LocationIconView::OnActivate(const ui::Event& event) { | 110 bool LocationIconView::OnActivate(const ui::Event& event) { |
| 116 WebContents* contents = location_bar_->GetWebContents(); | 111 WebContents* contents = location_bar_->GetWebContents(); |
| 117 if (!contents) | 112 if (!contents) |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 132 return true; | 127 return true; |
| 133 } | 128 } |
| 134 | 129 |
| 135 gfx::Size LocationIconView::GetMinimumSizeForLabelText( | 130 gfx::Size LocationIconView::GetMinimumSizeForLabelText( |
| 136 const base::string16& text) const { | 131 const base::string16& text) const { |
| 137 views::Label label(text, font_list()); | 132 views::Label label(text, font_list()); |
| 138 return GetMinimumSizeForPreferredSize( | 133 return GetMinimumSizeForPreferredSize( |
| 139 GetSizeForLabelWidth(label.GetPreferredSize().width())); | 134 GetSizeForLabelWidth(label.GetPreferredSize().width())); |
| 140 } | 135 } |
| 141 | 136 |
| 142 void LocationIconView::SetBackground(bool should_show_ev) { | |
| 143 static const int kEvBackgroundImages[] = IMAGE_GRID(IDR_OMNIBOX_EV_BUBBLE); | |
| 144 if (should_show_ev) | |
| 145 SetBackgroundImageGrid(kEvBackgroundImages); | |
| 146 else | |
| 147 UnsetBackgroundImageGrid(); | |
| 148 } | |
| 149 | |
| 150 void LocationIconView::SetSecurityState(bool should_show, bool should_animate) { | 137 void LocationIconView::SetSecurityState(bool should_show, bool should_animate) { |
| 151 if (!should_animate) { | 138 if (!should_animate) { |
| 152 animation_.Reset(should_show); | 139 animation_.Reset(should_show); |
| 153 } else if (should_show) { | 140 } else if (should_show) { |
| 154 animation_.Show(); | 141 animation_.Show(); |
| 155 } else { | 142 } else { |
| 156 animation_.Hide(); | 143 animation_.Hide(); |
| 157 } | 144 } |
| 145 // The label text color may have changed. | |
| 146 OnNativeThemeChanged(GetNativeTheme()); | |
|
Peter Kasting
2016/09/19 23:46:46
Is this a bugfix?
Evan Stade
2016/09/20 17:37:04
no. It worked before because this line was in SetB
| |
| 158 } | 147 } |
| 159 | 148 |
| 160 double LocationIconView::WidthMultiplier() const { | 149 double LocationIconView::WidthMultiplier() const { |
| 161 return animation_.GetCurrentValue(); | 150 return animation_.GetCurrentValue(); |
| 162 } | 151 } |
| 163 | 152 |
| 164 void LocationIconView::AnimationProgressed(const gfx::Animation*) { | 153 void LocationIconView::AnimationProgressed(const gfx::Animation*) { |
| 165 location_bar_->Layout(); | 154 location_bar_->Layout(); |
| 166 location_bar_->SchedulePaint(); | 155 location_bar_->SchedulePaint(); |
| 167 } | 156 } |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 179 return size; | 168 return size; |
| 180 } | 169 } |
| 181 | 170 |
| 182 void LocationIconView::OnClickOrTap(const ui::LocatedEvent& event) { | 171 void LocationIconView::OnClickOrTap(const ui::LocatedEvent& event) { |
| 183 // Do not show page info if the user has been editing the location bar or the | 172 // Do not show page info if the user has been editing the location bar or the |
| 184 // location bar is at the NTP. | 173 // location bar is at the NTP. |
| 185 if (location_bar_->GetOmniboxView()->IsEditingOrEmpty()) | 174 if (location_bar_->GetOmniboxView()->IsEditingOrEmpty()) |
| 186 return; | 175 return; |
| 187 ProcessLocatedEvent(event); | 176 ProcessLocatedEvent(event); |
| 188 } | 177 } |
| OLD | NEW |