OLD | NEW |
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 "components/security_state/core/security_state.h" | 9 #include "components/security_state/core/security_state.h" |
10 #include "ui/gfx/canvas.h" | 10 #include "ui/gfx/canvas.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 return ui::kWarningIcon; | 56 return ui::kWarningIcon; |
57 } | 57 } |
58 } | 58 } |
59 | 59 |
60 } // namespace | 60 } // namespace |
61 | 61 |
62 UrlBarTexture::UrlBarTexture() : security_level_(SecurityLevel::DANGEROUS) {} | 62 UrlBarTexture::UrlBarTexture() : security_level_(SecurityLevel::DANGEROUS) {} |
63 | 63 |
64 UrlBarTexture::~UrlBarTexture() = default; | 64 UrlBarTexture::~UrlBarTexture() = default; |
65 | 65 |
66 void UrlBarTexture::SetHover(bool hover) { | |
67 hover_ = hover; | |
68 } | |
69 | |
70 void UrlBarTexture::SetURL(const GURL& gurl) { | 66 void UrlBarTexture::SetURL(const GURL& gurl) { |
71 gurl_ = gurl; | 67 gurl_ = gurl; |
72 } | 68 } |
73 | 69 |
74 void UrlBarTexture::SetSecurityLevel(int level) { | 70 void UrlBarTexture::SetSecurityLevel(int level) { |
75 security_level_ = level; | 71 security_level_ = level; |
76 } | 72 } |
77 | 73 |
78 float UrlBarTexture::ToPixels(float meters) const { | 74 float UrlBarTexture::ToPixels(float meters) const { |
79 return meters * size_.width() / kWidth; | 75 return meters * size_.width() / kWidth; |
(...skipping 11 matching lines...) Expand all Loading... |
91 gfx::Canvas gfx_canvas(&paint_canvas, 1.0f); | 87 gfx::Canvas gfx_canvas(&paint_canvas, 1.0f); |
92 | 88 |
93 canvas->drawColor(kTextureBackground); | 89 canvas->drawColor(kTextureBackground); |
94 | 90 |
95 // Back button area. | 91 // Back button area. |
96 SkRRect round_rect; | 92 SkRRect round_rect; |
97 SkVector rounded_corner = {kHeight / 2, kHeight / 2}; | 93 SkVector rounded_corner = {kHeight / 2, kHeight / 2}; |
98 SkVector left_corners[4] = {rounded_corner, {0, 0}, {0, 0}, rounded_corner}; | 94 SkVector left_corners[4] = {rounded_corner, {0, 0}, {0, 0}, rounded_corner}; |
99 round_rect.setRectRadii({0, 0, kHeight, kHeight}, left_corners); | 95 round_rect.setRectRadii({0, 0, kHeight, kHeight}, left_corners); |
100 SkPaint paint; | 96 SkPaint paint; |
101 paint.setColor(hover_ ? kBackgroundHover : kBackground); | 97 paint.setColor((GetDrawFlags() & FLAG_HOVER) ? kBackgroundHover |
| 98 : kBackground); |
102 canvas->drawRRect(round_rect, paint); | 99 canvas->drawRRect(round_rect, paint); |
103 | 100 |
104 // URL area. | 101 // URL area. |
105 paint.setColor(kBackground); | 102 paint.setColor(kBackground); |
106 SkVector right_corners[4] = {{0, 0}, rounded_corner, rounded_corner, {0, 0}}; | 103 SkVector right_corners[4] = {{0, 0}, rounded_corner, rounded_corner, {0, 0}}; |
107 round_rect.setRectRadii({kHeight, 0, kWidth, kHeight}, right_corners); | 104 round_rect.setRectRadii({kHeight, 0, kWidth, kHeight}, right_corners); |
108 canvas->drawRRect(round_rect, paint); | 105 canvas->drawRRect(round_rect, paint); |
109 | 106 |
110 // Back button / URL separator vertical line. | 107 // Back button / URL separator vertical line. |
111 paint.setColor(kSeparatorColor); | 108 paint.setColor(kSeparatorColor); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 | 151 |
155 gfx::Size UrlBarTexture::GetPreferredTextureSize(int maximum_width) const { | 152 gfx::Size UrlBarTexture::GetPreferredTextureSize(int maximum_width) const { |
156 return gfx::Size(maximum_width, maximum_width * kHeight / kWidth); | 153 return gfx::Size(maximum_width, maximum_width * kHeight / kWidth); |
157 } | 154 } |
158 | 155 |
159 gfx::SizeF UrlBarTexture::GetDrawnSize() const { | 156 gfx::SizeF UrlBarTexture::GetDrawnSize() const { |
160 return size_; | 157 return size_; |
161 } | 158 } |
162 | 159 |
163 } // namespace vr_shell | 160 } // namespace vr_shell |
OLD | NEW |