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 "components/omnibox/browser/omnibox_edit_model.h" | 13 #include "components/omnibox/browser/omnibox_edit_model.h" |
14 #include "content/public/browser/navigation_controller.h" | 14 #include "content/public/browser/navigation_controller.h" |
15 #include "content/public/browser/navigation_entry.h" | 15 #include "content/public/browser/navigation_entry.h" |
16 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
17 #include "grit/components_scaled_resources.h" | 17 #include "grit/components_scaled_resources.h" |
18 #include "grit/theme_resources.h" | 18 #include "grit/theme_resources.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" | 20 #include "ui/base/material_design/material_design_controller.h" |
21 #include "ui/gfx/color_palette.h" | 21 #include "ui/gfx/color_palette.h" |
22 #include "ui/views/controls/label.h" | 22 #include "ui/views/controls/label.h" |
23 #include "ui/views/painter.h" | 23 #include "ui/views/painter.h" |
24 | 24 |
25 using content::NavigationController; | |
26 using content::NavigationEntry; | 25 using content::NavigationEntry; |
27 using content::WebContents; | 26 using content::WebContents; |
28 | 27 |
29 LocationIconView::LocationIconView(const gfx::FontList& font_list, | 28 LocationIconView::LocationIconView(const gfx::FontList& font_list, |
30 SkColor parent_background_color, | 29 SkColor parent_background_color, |
31 LocationBarView* location_bar) | 30 LocationBarView* location_bar) |
32 : IconLabelBubbleView(IDR_OMNIBOX_HTTPS_INVALID, | 31 : IconLabelBubbleView(IDR_OMNIBOX_HTTPS_INVALID, |
33 font_list, | 32 font_list, |
34 parent_background_color, | 33 parent_background_color, |
35 true), | 34 true), |
36 suppress_mouse_released_action_(false), | 35 suppress_mouse_released_action_(false), |
37 location_bar_(location_bar) { | 36 location_bar_(location_bar), |
37 animation_(this) { | |
38 set_id(VIEW_ID_LOCATION_ICON); | 38 set_id(VIEW_ID_LOCATION_ICON); |
39 | 39 |
40 #if defined(OS_MACOSX) | 40 #if defined(OS_MACOSX) |
41 SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY); | 41 SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY); |
42 #else | 42 #else |
43 SetFocusBehavior(FocusBehavior::ALWAYS); | 43 SetFocusBehavior(FocusBehavior::ALWAYS); |
44 #endif | 44 #endif |
45 | 45 |
46 SetBackground(false); | 46 SetBackground(false); |
47 animation_.SetSlideDuration(kOpenTimeMS); | |
47 } | 48 } |
48 | 49 |
49 LocationIconView::~LocationIconView() { | 50 LocationIconView::~LocationIconView() { |
50 } | 51 } |
51 | 52 |
52 bool LocationIconView::OnMousePressed(const ui::MouseEvent& event) { | 53 bool LocationIconView::OnMousePressed(const ui::MouseEvent& event) { |
53 if (event.IsOnlyMiddleMouseButton() && | 54 if (event.IsOnlyMiddleMouseButton() && |
54 ui::Clipboard::IsSupportedClipboardType(ui::CLIPBOARD_TYPE_SELECTION)) { | 55 ui::Clipboard::IsSupportedClipboardType(ui::CLIPBOARD_TYPE_SELECTION)) { |
55 base::string16 text; | 56 base::string16 text; |
56 ui::Clipboard::GetForCurrentThread()->ReadText( | 57 ui::Clipboard::GetForCurrentThread()->ReadText( |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
117 } | 118 } |
118 | 119 |
119 gfx::Size LocationIconView::GetMinimumSizeForLabelText( | 120 gfx::Size LocationIconView::GetMinimumSizeForLabelText( |
120 const base::string16& text) const { | 121 const base::string16& text) const { |
121 views::Label label(text, font_list()); | 122 views::Label label(text, font_list()); |
122 return GetMinimumSizeForPreferredSize( | 123 return GetMinimumSizeForPreferredSize( |
123 GetSizeForLabelWidth(label.GetPreferredSize().width())); | 124 GetSizeForLabelWidth(label.GetPreferredSize().width())); |
124 } | 125 } |
125 | 126 |
126 SkColor LocationIconView::GetTextColor() const { | 127 SkColor LocationIconView::GetTextColor() const { |
127 return location_bar_->GetColor(LocationBarView::EV_BUBBLE_TEXT_AND_BORDER); | 128 return location_bar_->GetColor( |
129 LocationBarView::SECURITY_CHIP_TEXT_AND_BORDER); | |
128 } | 130 } |
129 | 131 |
130 SkColor LocationIconView::GetBorderColor() const { | 132 SkColor LocationIconView::GetBorderColor() const { |
131 return GetTextColor(); | 133 return GetTextColor(); |
132 } | 134 } |
133 | 135 |
134 bool LocationIconView::OnActivate(const ui::Event& event) { | 136 bool LocationIconView::OnActivate(const ui::Event& event) { |
135 WebContents* contents = location_bar_->GetWebContents(); | 137 WebContents* contents = location_bar_->GetWebContents(); |
136 if (!contents) | 138 if (!contents) |
137 return false; | 139 return false; |
(...skipping 21 matching lines...) Expand all Loading... | |
159 return size; | 161 return size; |
160 } | 162 } |
161 | 163 |
162 void LocationIconView::SetBackground(bool should_show_ev) { | 164 void LocationIconView::SetBackground(bool should_show_ev) { |
163 static const int kEvBackgroundImages[] = IMAGE_GRID(IDR_OMNIBOX_EV_BUBBLE); | 165 static const int kEvBackgroundImages[] = IMAGE_GRID(IDR_OMNIBOX_EV_BUBBLE); |
164 if (should_show_ev) | 166 if (should_show_ev) |
165 SetBackgroundImageGrid(kEvBackgroundImages); | 167 SetBackgroundImageGrid(kEvBackgroundImages); |
166 else | 168 else |
167 UnsetBackgroundImageGrid(); | 169 UnsetBackgroundImageGrid(); |
168 } | 170 } |
171 | |
172 void LocationIconView::AnimateSecurityChip() { | |
Peter Kasting
2016/08/20 01:16:43
Nit: .cc definition order must match .h declaratio
Kevin Bailey
2016/08/22 15:58:56
I'm confused. It appears to match to me.
Peter Kasting
2016/08/22 22:58:09
The issue is primarily with the existing methods i
Kevin Bailey
2016/08/23 15:17:13
The issue is entirely with the existing methods. I
| |
173 animation_.Show(); | |
174 } | |
175 | |
176 void LocationIconView::ShowSecurityChip() { | |
177 animation_.Reset(1); | |
178 } | |
179 | |
180 void LocationIconView::HideSecurityChip() { | |
181 animation_.Reset(0); | |
182 } | |
183 | |
184 bool LocationIconView::IsAnimatingSecurityChip() { | |
185 return animation_.is_animating() && animation_.GetCurrentValue() < 1; | |
Peter Kasting
2016/08/20 01:16:43
Why is the second clause necessary?
Kevin Bailey
2016/08/22 15:58:56
It isn't; I thought 'is_animating' was staying tru
| |
186 } | |
187 | |
188 void LocationIconView::AnimationProgressed(const gfx::Animation*) { | |
189 location_bar_->Layout(); | |
190 location_bar_->SchedulePaint(); | |
191 } | |
192 | |
193 double LocationIconView::WidthMultiplier() const { | |
194 return animation_.GetCurrentValue(); | |
195 } | |
OLD | NEW |