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

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

Issue 2906403002: Disable back button when stack is empty (Closed)
Patch Set: 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 failure_callback_(failure_callback) {} 99 failure_callback_(failure_callback) {}
100 100
101 UrlBarTexture::~UrlBarTexture() = default; 101 UrlBarTexture::~UrlBarTexture() = default;
102 102
103 void UrlBarTexture::SetURL(const GURL& gurl) { 103 void UrlBarTexture::SetURL(const GURL& gurl) {
104 if (gurl_ != gurl) 104 if (gurl_ != gurl)
105 set_dirty(); 105 set_dirty();
106 gurl_ = gurl; 106 gurl_ = gurl;
107 } 107 }
108 108
109 void UrlBarTexture::SetHistoryButtonsEnabled(bool can_go_back,
110 bool can_go_forward) {
111 // Note: We don't have a forward button in the URL bar.
cjgrant 2017/05/29 16:12:25 Comment disappears with the arg.
ymalik 2017/05/29 17:34:10 Done.
112 if (can_go_back != can_go_back_)
113 set_dirty();
114 can_go_back_ = can_go_back;
115 }
116
109 void UrlBarTexture::SetSecurityLevel(SecurityLevel level) { 117 void UrlBarTexture::SetSecurityLevel(SecurityLevel level) {
110 if (security_level_ != level) 118 if (security_level_ != level)
111 set_dirty(); 119 set_dirty();
112 security_level_ = level; 120 security_level_ = level;
113 } 121 }
114 122
115 float UrlBarTexture::ToPixels(float meters) const { 123 float UrlBarTexture::ToPixels(float meters) const {
116 return meters * size_.width() / kWidth; 124 return meters * size_.width() / kWidth;
117 } 125 }
118 126
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 177
170 // Make a gfx canvas to support utility drawing methods. 178 // Make a gfx canvas to support utility drawing methods.
171 cc::SkiaPaintCanvas paint_canvas(canvas); 179 cc::SkiaPaintCanvas paint_canvas(canvas);
172 gfx::Canvas gfx_canvas(&paint_canvas, 1.0f); 180 gfx::Canvas gfx_canvas(&paint_canvas, 1.0f);
173 181
174 // Back button area. 182 // Back button area.
175 SkRRect round_rect; 183 SkRRect round_rect;
176 SkVector rounded_corner = {kHeight / 2, kHeight / 2}; 184 SkVector rounded_corner = {kHeight / 2, kHeight / 2};
177 SkVector left_corners[4] = {rounded_corner, {0, 0}, {0, 0}, rounded_corner}; 185 SkVector left_corners[4] = {rounded_corner, {0, 0}, {0, 0}, rounded_corner};
178 round_rect.setRectRadii({0, 0, kHeight, kHeight}, left_corners); 186 round_rect.setRectRadii({0, 0, kHeight, kHeight}, left_corners);
179 SkColor color = 187 SkColor color = color_scheme().background;
180 hovered_ ? color_scheme().background_hover : color_scheme().background; 188 if (can_go_back_) {
cjgrant 2017/05/29 16:12:25 Can we kill the ternaries here? This would read w
ymalik 2017/05/29 17:34:10 Done.
ymalik 2017/05/29 17:34:10 Done.
181 color = pressed_ ? color_scheme().background_down : color; 189 color =
190 hovered_ ? color_scheme().background_hover : color_scheme().background;
191 color = pressed_ ? color_scheme().background_down : color;
192 }
182 SkPaint paint; 193 SkPaint paint;
183 paint.setColor(color); 194 paint.setColor(color);
184 canvas->drawRRect(round_rect, paint); 195 canvas->drawRRect(round_rect, paint);
185 196
186 // URL area. 197 // URL area.
187 paint.setColor(color_scheme().background); 198 paint.setColor(color_scheme().background);
188 SkVector right_corners[4] = {{0, 0}, rounded_corner, rounded_corner, {0, 0}}; 199 SkVector right_corners[4] = {{0, 0}, rounded_corner, rounded_corner, {0, 0}};
189 round_rect.setRectRadii({kHeight, 0, kWidth, kHeight}, right_corners); 200 round_rect.setRectRadii({kHeight, 0, kWidth, kHeight}, right_corners);
190 canvas->drawRRect(round_rect, paint); 201 canvas->drawRRect(round_rect, paint);
191 202
192 // Back button / URL separator vertical line. 203 // Back button / URL separator vertical line.
193 paint.setColor(color_scheme().separator); 204 paint.setColor(color_scheme().separator);
194 canvas->drawRect(SkRect::MakeXYWH(kHeight, 0, kSeparatorWidth, kHeight), 205 canvas->drawRect(SkRect::MakeXYWH(kHeight, 0, kSeparatorWidth, kHeight),
195 paint); 206 paint);
196 207
197 // Back button icon. 208 // Back button icon.
198 canvas->save(); 209 canvas->save();
199 canvas->translate(kHeight / 2 + kBackIconOffset, kHeight / 2); 210 canvas->translate(kHeight / 2 + kBackIconOffset, kHeight / 2);
200 canvas->translate(-kBackIconHeight / 2, -kBackIconHeight / 2); 211 canvas->translate(-kBackIconHeight / 2, -kBackIconHeight / 2);
201 int icon_default_height = GetDefaultSizeOfVectorIcon(ui::kBackArrowIcon); 212 int icon_default_height = GetDefaultSizeOfVectorIcon(ui::kBackArrowIcon);
202 float icon_scale = kBackIconHeight / icon_default_height; 213 float icon_scale = kBackIconHeight / icon_default_height;
203 canvas->scale(icon_scale, icon_scale); 214 canvas->scale(icon_scale, icon_scale);
204 PaintVectorIcon(&gfx_canvas, ui::kBackArrowIcon, color_scheme().foreground); 215 PaintVectorIcon(
216 &gfx_canvas, ui::kBackArrowIcon,
217 can_go_back_ ? color_scheme().foreground : color_scheme().deemphasized);
cjgrant 2017/05/29 16:12:25 deemphasized is a URL text color, right? Shouldn'
ymalik 2017/05/29 17:34:10 Yeah was just here as placeholder. Posted hoverboa
205 canvas->restore(); 218 canvas->restore();
206 219
207 // Site security state icon. 220 // Site security state icon.
208 if (!gurl_.is_empty()) { 221 if (!gurl_.is_empty()) {
209 canvas->save(); 222 canvas->save();
210 canvas->translate( 223 canvas->translate(
211 kBackButtonWidth + kSeparatorWidth + kSecurityFieldWidth / 2, 224 kBackButtonWidth + kSeparatorWidth + kSecurityFieldWidth / 2,
212 kHeight / 2); 225 kHeight / 2);
213 canvas->translate(-kSecurityIconHeight / 2, -kSecurityIconHeight / 2); 226 canvas->translate(-kSecurityIconHeight / 2, -kSecurityIconHeight / 2);
214 const gfx::VectorIcon& icon = getSecurityIcon(security_level_); 227 const gfx::VectorIcon& icon = getSecurityIcon(security_level_);
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 348
336 gfx::Size UrlBarTexture::GetPreferredTextureSize(int maximum_width) const { 349 gfx::Size UrlBarTexture::GetPreferredTextureSize(int maximum_width) const {
337 return gfx::Size(maximum_width, maximum_width * kHeight / kWidth); 350 return gfx::Size(maximum_width, maximum_width * kHeight / kWidth);
338 } 351 }
339 352
340 gfx::SizeF UrlBarTexture::GetDrawnSize() const { 353 gfx::SizeF UrlBarTexture::GetDrawnSize() const {
341 return size_; 354 return size_;
342 } 355 }
343 356
344 } // namespace vr_shell 357 } // namespace vr_shell
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698