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

Unified Diff: chrome/browser/ui/omnibox/extension_action_util.cc

Issue 10834279: Give request-to-act badges a grey background, and increase spacing to make it fit. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Finish mac support; fix pkasting's comments Created 8 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/omnibox/extension_action_util.cc
diff --git a/chrome/browser/ui/omnibox/extension_action_util.cc b/chrome/browser/ui/omnibox/extension_action_util.cc
new file mode 100644
index 0000000000000000000000000000000000000000..3d46d2386d878f5499a09d915a73643b21d509a3
--- /dev/null
+++ b/chrome/browser/ui/omnibox/extension_action_util.cc
@@ -0,0 +1,52 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/omnibox/extension_action_util.h"
+
+#include "chrome/browser/themes/theme_service.h"
+#include "chrome/common/extensions/extension_action.h"
+#include "third_party/skia/include/core/SkPaint.h"
+#include "third_party/skia/include/effects/SkGradientShader.h"
+#include "ui/gfx/canvas.h"
+#include "ui/gfx/color_utils.h"
+#include "ui/gfx/rect.h"
+
+namespace extensions {
+
+void PaintExtensionActionBackground(const ExtensionAction& action,
+ int tab_id,
+ gfx::Canvas* canvas,
+ const gfx::Rect& bounds,
+ SkColor text_color,
+ SkColor background_color) {
+ if (action.WantsAttention(tab_id)) {
Peter Kasting 2012/09/11 22:27:47 Nit: Or early return so you can unindent rest of f
Jeffrey Yasskin 2012/09/12 20:29:34 Done.
+ SkPoint gradient_bounds[2] = { {SkIntToScalar(bounds.x()),
+ SkIntToScalar(bounds.y())},
+ {SkIntToScalar(bounds.x()),
+ SkIntToScalar(bounds.bottom())} };
+ SkColor gradient_colors[2] = {
+ color_utils::AlphaBlend(text_color, background_color, 0x13),
+ color_utils::AlphaBlend(text_color, background_color, 0x1d)
+ };
+ SkShader* gradient = SkGradientShader::CreateLinear(
+ gradient_bounds, gradient_colors, NULL, 2, SkShader::kClamp_TileMode);
+ SkPaint paint;
+ paint.setShader(gradient);
+ gradient->unref();
+ canvas->DrawRect(bounds, paint);
+
+ SkColor border_color =
+ color_utils::AlphaBlend(text_color, background_color, 0x55);
+ canvas->DrawLine(gfx::Point(bounds.x(), bounds.y()),
Peter Kasting 2012/09/11 22:27:47 Nit: First arg can be "bounds.origin()"
Jeffrey Yasskin 2012/09/11 23:05:28 I don't mind making this change, but it seemed mor
Peter Kasting 2012/09/11 23:25:41 That's OK. I'd prefer to keep the code more simpl
Jeffrey Yasskin 2012/09/12 20:29:34 Done.
+ gfx::Point(bounds.x(), bounds.bottom()),
+ border_color);
+ // "-1" because gfx::Rects are half-open, not including their right or
+ // bottom edges.
Peter Kasting 2012/09/11 22:27:47 So two adjacent badges that request attention get
Jeffrey Yasskin 2012/09/11 23:05:28 No, they get a single-thickness line between them.
+ canvas->DrawLine(gfx::Point(bounds.right() - 1, bounds.y()),
+ gfx::Point(bounds.right() - 1, bounds.bottom()),
+ border_color);
+ }
+}
+
+} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698