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

Side by Side Diff: chrome/common/extensions/extension_action.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: Add Views UI; clean up GTK Created 8 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/common/extensions/extension_action.h" 5 #include "chrome/common/extensions/extension_action.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "chrome/common/badge_util.h" 10 #include "chrome/common/badge_util.h"
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 // Color of badge text. 184 // Color of badge text.
185 SkColor text_color_; 185 SkColor text_color_;
186 // Color of the badge. 186 // Color of the badge.
187 SkColor background_color_; 187 SkColor background_color_;
188 188
189 DISALLOW_COPY_AND_ASSIGN(IconWithBadgeImageSource); 189 DISALLOW_COPY_AND_ASSIGN(IconWithBadgeImageSource);
190 }; 190 };
191 191
192 192
193 const int ExtensionAction::kDefaultTabId = -1; 193 const int ExtensionAction::kDefaultTabId = -1;
194 const SkColor ExtensionAction::kGetAttentionBorderColor =
Peter Kasting 2012/08/24 23:08:28 You need to get the correct colors from the themin
Jeffrey Yasskin 2012/08/29 00:37:50 Oh good. I'll figure out how to do this after send
195 SkColorSetRGB(0xAA, 0xAA, 0xAA);
196 const SkColor ExtensionAction::kGetAttentionBackgroundTopColor =
197 SkColorSetRGB(0xEC, 0xEC, 0xEC);
198 const SkColor ExtensionAction::kGetAttentionBackgroundBottomColor =
199 SkColorSetRGB(0xE2, 0xE2, 0xE2);
194 200
195 ExtensionAction::IconAnimation::IconAnimation( 201 ExtensionAction::IconAnimation::IconAnimation(
196 ui::AnimationDelegate* delegate) 202 ui::AnimationDelegate* delegate)
197 // 100ms animation at 50fps (so 5 animation frames in total). 203 // 100ms animation at 50fps (so 5 animation frames in total).
198 : ui::LinearAnimation(100, 50, delegate) {} 204 : ui::LinearAnimation(100, 50, delegate) {}
199 205
200 ExtensionAction::IconAnimation::~IconAnimation() {} 206 ExtensionAction::IconAnimation::~IconAnimation() {}
201 207
202 const SkBitmap& ExtensionAction::IconAnimation::Apply( 208 const SkBitmap& ExtensionAction::IconAnimation::Apply(
203 const SkBitmap& icon) const { 209 const SkBitmap& icon) const {
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 title_.erase(tab_id); 369 title_.erase(tab_id);
364 icon_.erase(tab_id); 370 icon_.erase(tab_id);
365 icon_index_.erase(tab_id); 371 icon_index_.erase(tab_id);
366 badge_text_.erase(tab_id); 372 badge_text_.erase(tab_id);
367 badge_text_color_.erase(tab_id); 373 badge_text_color_.erase(tab_id);
368 badge_background_color_.erase(tab_id); 374 badge_background_color_.erase(tab_id);
369 appearance_.erase(tab_id); 375 appearance_.erase(tab_id);
370 icon_animation_.erase(tab_id); 376 icon_animation_.erase(tab_id);
371 } 377 }
372 378
379 void ExtensionAction::PaintBackground(gfx::Canvas* canvas,
380 const gfx::Rect& bounds,
381 int tab_id) {
382 if (WantsAttention(tab_id)) {
383 SkPoint gradient_bounds[2] = { {SkIntToScalar(bounds.x()),
384 SkIntToScalar(bounds.y() + 1)},
Peter Kasting 2012/08/24 23:08:28 Nit: Once you've defined LocationBar::kVisibleEdge
Jeffrey Yasskin 2012/08/29 00:37:50 This isn't necessarily the thickness of the locati
385 {SkIntToScalar(bounds.x()),
386 SkIntToScalar(bounds.bottom() - 1)} };
387 SkColor gradient_colors[2] = { kGetAttentionBackgroundTopColor,
388 kGetAttentionBackgroundBottomColor };
389 SkShader* gradient = SkGradientShader::CreateLinear(
390 gradient_bounds, gradient_colors, NULL, 2, SkShader::kClamp_TileMode);
391 SkPaint paint;
392 paint.setShader(gradient);
393 gradient->unref();
394 gfx::Rect bg_rect(bounds.x() - 1, bounds.y(),
Peter Kasting 2012/08/24 23:08:28 Why do we draw outside our bounds? Shouldn't our
Jeffrey Yasskin 2012/08/29 00:37:50 I think this came from before I had the platform-s
395 bounds.width() + 1, bounds.height() - 1);
Peter Kasting 2012/08/24 23:08:28 What's this last -1 mean?
Jeffrey Yasskin 2012/08/29 00:37:50 This also came from before I got the platform-spec
396 canvas->DrawRect(bg_rect, paint);
397 canvas->DrawRect(bg_rect, kGetAttentionBorderColor);
398 }
399 }
400
373 void ExtensionAction::PaintBadge(gfx::Canvas* canvas, 401 void ExtensionAction::PaintBadge(gfx::Canvas* canvas,
374 const gfx::Rect& bounds, 402 const gfx::Rect& bounds,
375 int tab_id) { 403 int tab_id) {
376 ExtensionAction::DoPaintBadge( 404 ExtensionAction::DoPaintBadge(
377 canvas, 405 canvas,
378 bounds, 406 bounds,
379 GetBadgeText(tab_id), 407 GetBadgeText(tab_id),
380 GetBadgeTextColor(tab_id), 408 GetBadgeTextColor(tab_id),
381 GetBadgeBackgroundColor(tab_id), 409 GetBadgeBackgroundColor(tab_id),
382 GetValue(&icon_, tab_id).size().width()); 410 GetValue(&icon_, tab_id).size().width());
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 new AnimatedIconImageSource(icon, animation_wrapper->animation()), 549 new AnimatedIconImageSource(icon, animation_wrapper->animation()),
522 icon.size()); 550 icon.size());
523 } 551 }
524 552
525 void ExtensionAction::RunIconAnimation(int tab_id) { 553 void ExtensionAction::RunIconAnimation(int tab_id) {
526 IconAnimationWrapper* icon_animation = 554 IconAnimationWrapper* icon_animation =
527 new IconAnimationWrapper(); 555 new IconAnimationWrapper();
528 icon_animation_[tab_id] = icon_animation->AsWeakPtr(); 556 icon_animation_[tab_id] = icon_animation->AsWeakPtr();
529 icon_animation->animation()->Start(); 557 icon_animation->animation()->Start();
530 } 558 }
OLDNEW
« chrome/common/extensions/extension_action.h ('K') | « chrome/common/extensions/extension_action.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698