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

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: rebase 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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 return rect.Contains(meters) && !HitsTransparentRegion(meters, true); 135 return rect.Contains(meters) && !HitsTransparentRegion(meters, true);
136 } 136 }
137 137
138 bool UrlBarTexture::HitsUrlBar(const gfx::PointF& position) const { 138 bool UrlBarTexture::HitsUrlBar(const gfx::PointF& position) const {
139 const gfx::PointF& meters = percentToMeters(position); 139 const gfx::PointF& meters = percentToMeters(position);
140 gfx::RectF rect(gfx::PointF(kBackButtonWidth, 0), 140 gfx::RectF rect(gfx::PointF(kBackButtonWidth, 0),
141 gfx::SizeF(kWidth - kBackButtonWidth, kHeight)); 141 gfx::SizeF(kWidth - kBackButtonWidth, kHeight));
142 return rect.Contains(meters) && !HitsTransparentRegion(meters, false); 142 return rect.Contains(meters) && !HitsTransparentRegion(meters, false);
143 } 143 }
144 144
145 gfx::PointF UrlBarTexture::SecurityIconPositionMeters() const {
146 float x = kBackButtonWidth + kSeparatorWidth + kSecurityFieldWidth / 2 -
147 kSecurityIconHeight / 2;
148 float y = kHeight / 2 - kSecurityIconHeight / 2;
149 return gfx::PointF(x, y);
150 }
151
152 bool UrlBarTexture::HitsSecurityIcon(const gfx::PointF& position) const {
153 gfx::RectF rect(SecurityIconPositionMeters(),
154 gfx::SizeF(kSecurityIconHeight, kSecurityIconHeight));
155 return rect.Contains(percentToMeters(position));
156 }
157
145 bool UrlBarTexture::HitsTransparentRegion(const gfx::PointF& meters, 158 bool UrlBarTexture::HitsTransparentRegion(const gfx::PointF& meters,
146 bool left) const { 159 bool left) const {
147 const float radius = kHeight / 2.0f; 160 const float radius = kHeight / 2.0f;
148 gfx::PointF circle_center(left ? radius : kWidth - radius, radius); 161 gfx::PointF circle_center(left ? radius : kWidth - radius, radius);
149 if (!left && meters.x() < circle_center.x()) 162 if (!left && meters.x() < circle_center.x())
150 return false; 163 return false;
151 if (left && meters.x() > circle_center.x()) 164 if (left && meters.x() > circle_center.x())
152 return false; 165 return false;
153 return (meters - circle_center).LengthSquared() > radius * radius; 166 return (meters - circle_center).LengthSquared() > radius * radius;
154 } 167 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 float icon_scale = kBackIconHeight / icon_default_height; 228 float icon_scale = kBackIconHeight / icon_default_height;
216 canvas->scale(icon_scale, icon_scale); 229 canvas->scale(icon_scale, icon_scale);
217 PaintVectorIcon(&gfx_canvas, ui::kBackArrowIcon, 230 PaintVectorIcon(&gfx_canvas, ui::kBackArrowIcon,
218 can_go_back_ ? color_scheme().element_foreground 231 can_go_back_ ? color_scheme().element_foreground
219 : color_scheme().disabled); 232 : color_scheme().disabled);
220 canvas->restore(); 233 canvas->restore();
221 234
222 // Site security state icon. 235 // Site security state icon.
223 if (!gurl_.is_empty()) { 236 if (!gurl_.is_empty()) {
224 canvas->save(); 237 canvas->save();
225 canvas->translate( 238 gfx::PointF icon_position = SecurityIconPositionMeters();
226 kBackButtonWidth + kSeparatorWidth + kSecurityFieldWidth / 2, 239 canvas->translate(icon_position.x(), icon_position.y());
227 kHeight / 2);
228 canvas->translate(-kSecurityIconHeight / 2, -kSecurityIconHeight / 2);
229 const gfx::VectorIcon& icon = getSecurityIcon(security_level_); 240 const gfx::VectorIcon& icon = getSecurityIcon(security_level_);
230 icon_default_height = GetDefaultSizeOfVectorIcon(icon); 241 icon_default_height = GetDefaultSizeOfVectorIcon(icon);
231 icon_scale = kSecurityIconHeight / icon_default_height; 242 icon_scale = kSecurityIconHeight / icon_default_height;
232 SkColor icon_color = getSchemeColor(security_level_, color_scheme()); 243 SkColor icon_color = getSchemeColor(security_level_, color_scheme());
233 canvas->scale(icon_scale, icon_scale); 244 canvas->scale(icon_scale, icon_scale);
234 PaintVectorIcon(&gfx_canvas, icon, icon_color); 245 PaintVectorIcon(&gfx_canvas, icon, icon_color);
235 canvas->restore(); 246 canvas->restore();
236 } 247 }
237 248
238 canvas->restore(); 249 canvas->restore();
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 374
364 gfx::Size UrlBarTexture::GetPreferredTextureSize(int maximum_width) const { 375 gfx::Size UrlBarTexture::GetPreferredTextureSize(int maximum_width) const {
365 return gfx::Size(maximum_width, maximum_width * kHeight / kWidth); 376 return gfx::Size(maximum_width, maximum_width * kHeight / kWidth);
366 } 377 }
367 378
368 gfx::SizeF UrlBarTexture::GetDrawnSize() const { 379 gfx::SizeF UrlBarTexture::GetDrawnSize() const {
369 return size_; 380 return size_;
370 } 381 }
371 382
372 } // namespace vr_shell 383 } // namespace vr_shell
OLDNEW
« no previous file with comments | « chrome/browser/android/vr_shell/textures/url_bar_texture.h ('k') | chrome/browser/android/vr_shell/ui_elements/exit_prompt.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698