Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1059)

Side by Side Diff: chrome/browser/android/vr_shell/textures/url_bar_texture.cc

Issue 2913633002: [vr] Clicking on the security icon should prompt the user to bail out of VR (Closed)
Patch Set: address amp's comments Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/android/vr_shell/textures/url_bar_texture.h" 5 #include "chrome/browser/android/vr_shell/textures/url_bar_texture.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "cc/paint/skia_paint_canvas.h" 8 #include "cc/paint/skia_paint_canvas.h"
9 #include "chrome/browser/android/vr_shell/color_scheme.h" 9 #include "chrome/browser/android/vr_shell/color_scheme.h"
10 #include "chrome/browser/android/vr_shell/textures/render_text_wrapper.h" 10 #include "chrome/browser/android/vr_shell/textures/render_text_wrapper.h"
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 return rect.Contains(meters) && !HitsTransparentRegion(meters, true); 128 return rect.Contains(meters) && !HitsTransparentRegion(meters, true);
129 } 129 }
130 130
131 bool UrlBarTexture::HitsUrlBar(const gfx::PointF& position) const { 131 bool UrlBarTexture::HitsUrlBar(const gfx::PointF& position) const {
132 const gfx::PointF& meters = percentToMeters(position); 132 const gfx::PointF& meters = percentToMeters(position);
133 gfx::RectF rect(gfx::PointF(kBackButtonWidth, 0), 133 gfx::RectF rect(gfx::PointF(kBackButtonWidth, 0),
134 gfx::SizeF(kWidth - kBackButtonWidth, kHeight)); 134 gfx::SizeF(kWidth - kBackButtonWidth, kHeight));
135 return rect.Contains(meters) && !HitsTransparentRegion(meters, false); 135 return rect.Contains(meters) && !HitsTransparentRegion(meters, false);
136 } 136 }
137 137
138 gfx::PointF UrlBarTexture::security_icon_position_meters() const {
cjgrant 2017/06/05 17:33:53 This isn't a simple getter. Shouldn't it be Secur
ymalik 2017/06/05 20:02:42 You're right. Done.
139 float x = kBackButtonWidth + kSeparatorWidth + kSecurityFieldWidth / 2 -
140 kSecurityIconHeight / 2;
141 float y = kHeight / 2 - kSecurityIconHeight / 2;
142 return gfx::PointF(x, y);
143 }
144
145 bool UrlBarTexture::HitsSecurityIcon(const gfx::PointF& position) const {
146 const gfx::PointF& meters = percentToMeters(position);
147 gfx::RectF rect(security_icon_position_meters(),
148 gfx::SizeF(kSecurityIconHeight, kSecurityIconHeight));
149 return rect.Contains(meters);
cjgrant 2017/06/05 17:33:53 Maybe drop the 'meters' intermediate? Would actua
ymalik 2017/06/05 20:02:41 Agreed. Done.
150 }
151
138 bool UrlBarTexture::HitsTransparentRegion(const gfx::PointF& meters, 152 bool UrlBarTexture::HitsTransparentRegion(const gfx::PointF& meters,
139 bool left) const { 153 bool left) const {
140 const float radius = kHeight / 2.0f; 154 const float radius = kHeight / 2.0f;
141 gfx::PointF circle_center(left ? radius : kWidth - radius, radius); 155 gfx::PointF circle_center(left ? radius : kWidth - radius, radius);
142 if (!left && meters.x() < circle_center.x()) 156 if (!left && meters.x() < circle_center.x())
143 return false; 157 return false;
144 if (left && meters.x() > circle_center.x()) 158 if (left && meters.x() > circle_center.x())
145 return false; 159 return false;
146 return (meters - circle_center).LengthSquared() > radius * radius; 160 return (meters - circle_center).LengthSquared() > radius * radius;
147 } 161 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 float icon_scale = kBackIconHeight / icon_default_height; 226 float icon_scale = kBackIconHeight / icon_default_height;
213 canvas->scale(icon_scale, icon_scale); 227 canvas->scale(icon_scale, icon_scale);
214 PaintVectorIcon( 228 PaintVectorIcon(
215 &gfx_canvas, ui::kBackArrowIcon, 229 &gfx_canvas, ui::kBackArrowIcon,
216 can_go_back_ ? color_scheme().foreground : color_scheme().disabled); 230 can_go_back_ ? color_scheme().foreground : color_scheme().disabled);
217 canvas->restore(); 231 canvas->restore();
218 232
219 // Site security state icon. 233 // Site security state icon.
220 if (!gurl_.is_empty()) { 234 if (!gurl_.is_empty()) {
221 canvas->save(); 235 canvas->save();
222 canvas->translate( 236 gfx::PointF icon_position = security_icon_position_meters();
223 kBackButtonWidth + kSeparatorWidth + kSecurityFieldWidth / 2, 237 canvas->translate(icon_position.x(), icon_position.y());
224 kHeight / 2);
225 canvas->translate(-kSecurityIconHeight / 2, -kSecurityIconHeight / 2);
226 const gfx::VectorIcon& icon = getSecurityIcon(security_level_); 238 const gfx::VectorIcon& icon = getSecurityIcon(security_level_);
227 icon_default_height = GetDefaultSizeOfVectorIcon(icon); 239 icon_default_height = GetDefaultSizeOfVectorIcon(icon);
228 icon_scale = kSecurityIconHeight / icon_default_height; 240 icon_scale = kSecurityIconHeight / icon_default_height;
229 SkColor icon_color = getSchemeColor(security_level_, color_scheme()); 241 SkColor icon_color = getSchemeColor(security_level_, color_scheme());
230 canvas->scale(icon_scale, icon_scale); 242 canvas->scale(icon_scale, icon_scale);
231 PaintVectorIcon(&gfx_canvas, icon, icon_color); 243 PaintVectorIcon(&gfx_canvas, icon, icon_color);
232 canvas->restore(); 244 canvas->restore();
233 } 245 }
234 246
235 canvas->restore(); 247 canvas->restore();
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 372
361 gfx::Size UrlBarTexture::GetPreferredTextureSize(int maximum_width) const { 373 gfx::Size UrlBarTexture::GetPreferredTextureSize(int maximum_width) const {
362 return gfx::Size(maximum_width, maximum_width * kHeight / kWidth); 374 return gfx::Size(maximum_width, maximum_width * kHeight / kWidth);
363 } 375 }
364 376
365 gfx::SizeF UrlBarTexture::GetDrawnSize() const { 377 gfx::SizeF UrlBarTexture::GetDrawnSize() const {
366 return size_; 378 return size_;
367 } 379 }
368 380
369 } // namespace vr_shell 381 } // namespace vr_shell
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698