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

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

Issue 2914623003: [VrShell] Centralize color handling and enable close button on fullscreen (Closed)
Patch Set: update fullscreen colors, try to get them to show up on mode switch 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 return ui::kWarningIcon; 54 return ui::kWarningIcon;
55 } 55 }
56 } 56 }
57 57
58 // See LocationBarView::GetSecureTextColor(). 58 // See LocationBarView::GetSecureTextColor().
59 SkColor getSchemeColor(SecurityLevel level, const ColorScheme& color_scheme) { 59 SkColor getSchemeColor(SecurityLevel level, const ColorScheme& color_scheme) {
60 switch (level) { 60 switch (level) {
61 case SecurityLevel::NONE: 61 case SecurityLevel::NONE:
62 case SecurityLevel::HTTP_SHOW_WARNING: 62 case SecurityLevel::HTTP_SHOW_WARNING:
63 case SecurityLevel::SECURITY_WARNING: 63 case SecurityLevel::SECURITY_WARNING:
64 return color_scheme.deemphasized; 64 return color_scheme.text_deemphasized;
65 case SecurityLevel::SECURE: 65 case SecurityLevel::SECURE:
66 case SecurityLevel::EV_SECURE: 66 case SecurityLevel::EV_SECURE:
67 return color_scheme.secure; 67 return color_scheme.secure;
68 case SecurityLevel::DANGEROUS: 68 case SecurityLevel::DANGEROUS:
69 return color_scheme.insecure; 69 return color_scheme.insecure;
70 case SecurityLevel::SECURE_WITH_POLICY_INSTALLED_CERT: // ChromeOS only. 70 case SecurityLevel::SECURE_WITH_POLICY_INSTALLED_CERT: // ChromeOS only.
71 default: 71 default:
72 NOTREACHED(); 72 NOTREACHED();
73 return color_scheme.warning; 73 return color_scheme.warning;
74 } 74 }
75 } 75 }
76 76
77 void setEmphasis(vr_shell::RenderTextWrapper* render_text, 77 void setEmphasis(vr_shell::RenderTextWrapper* render_text,
78 bool emphasis, 78 bool emphasis,
79 const gfx::Range& range, 79 const gfx::Range& range,
80 const ColorScheme& color_scheme) { 80 const ColorScheme& color_scheme) {
81 SkColor color = 81 SkColor color =
82 emphasis ? color_scheme.emphasized : color_scheme.deemphasized; 82 emphasis ? color_scheme.text_emphasized : color_scheme.text_deemphasized;
83 if (range.IsValid()) { 83 if (range.IsValid()) {
84 render_text->ApplyColor(color, range); 84 render_text->ApplyColor(color, range);
85 } else { 85 } else {
86 render_text->SetColor(color); 86 render_text->SetColor(color);
87 } 87 }
88 } 88 }
89 89
90 gfx::PointF percentToMeters(const gfx::PointF& percent) { 90 gfx::PointF percentToMeters(const gfx::PointF& percent) {
91 return gfx::PointF(percent.x() * kWidth, percent.y() * kHeight); 91 return gfx::PointF(percent.x() * kWidth, percent.y() * kHeight);
92 } 92 }
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 175
176 // Make a gfx canvas to support utility drawing methods. 176 // Make a gfx canvas to support utility drawing methods.
177 cc::SkiaPaintCanvas paint_canvas(canvas); 177 cc::SkiaPaintCanvas paint_canvas(canvas);
178 gfx::Canvas gfx_canvas(&paint_canvas, 1.0f); 178 gfx::Canvas gfx_canvas(&paint_canvas, 1.0f);
179 179
180 // Back button area. 180 // Back button area.
181 SkRRect round_rect; 181 SkRRect round_rect;
182 SkVector rounded_corner = {kHeight / 2, kHeight / 2}; 182 SkVector rounded_corner = {kHeight / 2, kHeight / 2};
183 SkVector left_corners[4] = {rounded_corner, {0, 0}, {0, 0}, rounded_corner}; 183 SkVector left_corners[4] = {rounded_corner, {0, 0}, {0, 0}, rounded_corner};
184 round_rect.setRectRadii({0, 0, kHeight, kHeight}, left_corners); 184 round_rect.setRectRadii({0, 0, kHeight, kHeight}, left_corners);
185 SkColor color = color_scheme().background; 185 SkColor color = color_scheme().element_background;
186 if (can_go_back_) { 186 if (can_go_back_) {
187 if (pressed_) 187 if (pressed_)
188 color = color_scheme().background_down; 188 color = color_scheme().element_background_down;
189 else if (hovered_) 189 else if (hovered_)
190 color = color_scheme().background_hover; 190 color = color_scheme().element_background_hover;
191 } 191 }
192 SkPaint paint; 192 SkPaint paint;
193 paint.setColor(color); 193 paint.setColor(color);
194 canvas->drawRRect(round_rect, paint); 194 canvas->drawRRect(round_rect, paint);
195 195
196 // URL area. 196 // URL area.
197 paint.setColor(color_scheme().background); 197 paint.setColor(color_scheme().element_background);
198 SkVector right_corners[4] = {{0, 0}, rounded_corner, rounded_corner, {0, 0}}; 198 SkVector right_corners[4] = {{0, 0}, rounded_corner, rounded_corner, {0, 0}};
199 round_rect.setRectRadii({kHeight, 0, kWidth, kHeight}, right_corners); 199 round_rect.setRectRadii({kHeight, 0, kWidth, kHeight}, right_corners);
200 canvas->drawRRect(round_rect, paint); 200 canvas->drawRRect(round_rect, paint);
201 201
202 // Back button / URL separator vertical line. 202 // Back button / URL separator vertical line.
203 paint.setColor(color_scheme().separator); 203 paint.setColor(color_scheme().separator);
204 canvas->drawRect(SkRect::MakeXYWH(kHeight, 0, kSeparatorWidth, kHeight), 204 canvas->drawRect(SkRect::MakeXYWH(kHeight, 0, kSeparatorWidth, kHeight),
205 paint); 205 paint);
206 206
207 // Back button icon. 207 // Back button icon.
208 canvas->save(); 208 canvas->save();
209 canvas->translate(kHeight / 2 + kBackIconOffset, kHeight / 2); 209 canvas->translate(kHeight / 2 + kBackIconOffset, kHeight / 2);
210 canvas->translate(-kBackIconHeight / 2, -kBackIconHeight / 2); 210 canvas->translate(-kBackIconHeight / 2, -kBackIconHeight / 2);
211 int icon_default_height = GetDefaultSizeOfVectorIcon(ui::kBackArrowIcon); 211 int icon_default_height = GetDefaultSizeOfVectorIcon(ui::kBackArrowIcon);
212 float icon_scale = kBackIconHeight / icon_default_height; 212 float icon_scale = kBackIconHeight / icon_default_height;
213 canvas->scale(icon_scale, icon_scale); 213 canvas->scale(icon_scale, icon_scale);
214 PaintVectorIcon( 214 PaintVectorIcon(&gfx_canvas, ui::kBackArrowIcon,
215 &gfx_canvas, ui::kBackArrowIcon, 215 can_go_back_ ? color_scheme().element_foreground
216 can_go_back_ ? color_scheme().foreground : color_scheme().disabled); 216 : color_scheme().disabled);
217 canvas->restore(); 217 canvas->restore();
218 218
219 // Site security state icon. 219 // Site security state icon.
220 if (!gurl_.is_empty()) { 220 if (!gurl_.is_empty()) {
221 canvas->save(); 221 canvas->save();
222 canvas->translate( 222 canvas->translate(
223 kBackButtonWidth + kSeparatorWidth + kSecurityFieldWidth / 2, 223 kBackButtonWidth + kSeparatorWidth + kSecurityFieldWidth / 2,
224 kHeight / 2); 224 kHeight / 2);
225 canvas->translate(-kSecurityIconHeight / 2, -kSecurityIconHeight / 2); 225 canvas->translate(-kSecurityIconHeight / 2, -kSecurityIconHeight / 2);
226 const gfx::VectorIcon& icon = getSecurityIcon(security_level_); 226 const gfx::VectorIcon& icon = getSecurityIcon(security_level_);
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 360
361 gfx::Size UrlBarTexture::GetPreferredTextureSize(int maximum_width) const { 361 gfx::Size UrlBarTexture::GetPreferredTextureSize(int maximum_width) const {
362 return gfx::Size(maximum_width, maximum_width * kHeight / kWidth); 362 return gfx::Size(maximum_width, maximum_width * kHeight / kWidth);
363 } 363 }
364 364
365 gfx::SizeF UrlBarTexture::GetDrawnSize() const { 365 gfx::SizeF UrlBarTexture::GetDrawnSize() const {
366 return size_; 366 return size_;
367 } 367 }
368 368
369 } // namespace vr_shell 369 } // namespace vr_shell
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698