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

Side by Side Diff: chrome/common/extensions/extension_action.cc

Issue 10703090: Turn pageAction.show -> browserAction.sensibleThing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: views (incomplete) Created 8 years, 5 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
« no previous file with comments | « chrome/common/extensions/extension_action.h ('k') | chrome/common/extensions/icon_transform.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
11 #include "googleurl/src/gurl.h" 11 #include "googleurl/src/gurl.h"
12 #include "grit/ui_resources.h" 12 #include "grit/ui_resources.h"
13 #include "third_party/skia/include/core/SkBitmap.h" 13 #include "third_party/skia/include/core/SkBitmap.h"
14 #include "third_party/skia/include/core/SkCanvas.h"
15 #include "third_party/skia/include/core/SkDevice.h"
16 #include "third_party/skia/include/core/SkPaint.h"
17 #include "third_party/skia/include/effects/SkGradientShader.h" 14 #include "third_party/skia/include/effects/SkGradientShader.h"
18 #include "ui/base/animation/animation_delegate.h" 15 #include "ui/base/animation/animation_delegate.h"
19 #include "ui/base/resource/resource_bundle.h" 16 #include "ui/base/resource/resource_bundle.h"
20 #include "ui/gfx/canvas.h" 17 #include "ui/gfx/canvas.h"
21 #include "ui/gfx/rect.h" 18 #include "ui/gfx/rect.h"
22 19
23 namespace { 20 namespace {
24 21
25 // Different platforms need slightly different constants to look good. 22 // Different platforms need slightly different constants to look good.
26 #if defined(OS_LINUX) && !defined(TOOLKIT_VIEWS) 23 #if defined(OS_LINUX) && !defined(TOOLKIT_VIEWS)
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 90
94 ExtensionAction::IconAnimation::IconAnimation( 91 ExtensionAction::IconAnimation::IconAnimation(
95 ui::AnimationDelegate* delegate) 92 ui::AnimationDelegate* delegate)
96 // 100ms animation at 50fps (so 5 animation frames in total). 93 // 100ms animation at 50fps (so 5 animation frames in total).
97 : ui::LinearAnimation(100, 50, delegate) {} 94 : ui::LinearAnimation(100, 50, delegate) {}
98 95
99 ExtensionAction::IconAnimation::~IconAnimation() {} 96 ExtensionAction::IconAnimation::~IconAnimation() {}
100 97
101 const SkBitmap& ExtensionAction::IconAnimation::Apply( 98 const SkBitmap& ExtensionAction::IconAnimation::Apply(
102 const SkBitmap& icon) const { 99 const SkBitmap& icon) const {
103 DCHECK_GT(icon.width(), 0); 100 return icon_transform_.set_alpha(CurrentValueBetween(0, 255))
104 DCHECK_GT(icon.height(), 0); 101 .RenderIcon(icon);
105
106 if (!device_.get() ||
107 (device_->width() != icon.width()) ||
108 (device_->height() != icon.height())) {
109 device_.reset(new SkDevice(
110 SkBitmap::kARGB_8888_Config, icon.width(), icon.height(), true));
111 }
112
113 SkCanvas canvas(device_.get());
114 canvas.clear(SK_ColorWHITE);
115 SkPaint paint;
116 paint.setAlpha(CurrentValueBetween(0, 255));
117 canvas.drawBitmap(icon, 0, 0, &paint);
118 return device_->accessBitmap(false);
119 } 102 }
120 103
121 void ExtensionAction::IconAnimation::AddObserver( 104 void ExtensionAction::IconAnimation::AddObserver(
122 ExtensionAction::IconAnimation::Observer* observer) { 105 ExtensionAction::IconAnimation::Observer* observer) {
123 observers_.AddObserver(observer); 106 observers_.AddObserver(observer);
124 } 107 }
125 108
126 void ExtensionAction::IconAnimation::RemoveObserver( 109 void ExtensionAction::IconAnimation::RemoveObserver(
127 ExtensionAction::IconAnimation::Observer* observer) { 110 ExtensionAction::IconAnimation::Observer* observer) {
128 observers_.RemoveObserver(observer); 111 observers_.RemoveObserver(observer);
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 return (it != icon_animation_.end()) ? it->second->animation()->AsWeakPtr() 297 return (it != icon_animation_.end()) ? it->second->animation()->AsWeakPtr()
315 : base::WeakPtr<IconAnimation>(); 298 : base::WeakPtr<IconAnimation>();
316 } 299 }
317 300
318 void ExtensionAction::RunIconAnimation(int tab_id) { 301 void ExtensionAction::RunIconAnimation(int tab_id) {
319 IconAnimationWrapper* icon_animation = 302 IconAnimationWrapper* icon_animation =
320 new IconAnimationWrapper(this, tab_id); 303 new IconAnimationWrapper(this, tab_id);
321 icon_animation_[tab_id] = make_linked_ptr(icon_animation); 304 icon_animation_[tab_id] = make_linked_ptr(icon_animation);
322 icon_animation->animation()->Start(); 305 icon_animation->animation()->Start();
323 } 306 }
307
308 const SkBitmap& ExtensionAction::RenderIconVisibility(const SkBitmap& icon,
309 int tab_id) const {
310 if (GetIsVisible(tab_id))
311 return icon;
312 return icon_transform_.set_alpha(63)
313 .RenderIcon(icon);
314 }
OLDNEW
« no previous file with comments | « chrome/common/extensions/extension_action.h ('k') | chrome/common/extensions/icon_transform.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698