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

Side by Side Diff: chrome/browser/extensions/extension_action_icon_factory.cc

Issue 10905005: Change browser/page action default icon defined in manifest to support hidpi. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/extensions/extension_action_icon_factory.h"
6
7 #include "base/memory/scoped_ptr.h"
8 #include "chrome/browser/extensions/extension_icon_image.h"
9 #include "chrome/common/extensions/extension.h"
10 #include "chrome/common/extensions/extension_icon_set.h"
11 #include "grit/theme_resources.h"
12 #include "ui/base/resource/resource_bundle.h"
13 #include "ui/gfx/image/image_skia.h"
14
15 using extensions::Extension;
16 using extensions::IconImage;
17
18 namespace {
19
20 gfx::ImageSkia GetDefaultIcon() {
21 return *ui::ResourceBundle::GetSharedInstance().GetImageNamed(
22 IDR_EXTENSIONS_FAVICON).ToImageSkia();
23 }
24
25 } // namespace
26
27 // extension::IconImage wrapper for extension action icons. We need this
28 // because ExtensionAction class cannot use extensions::IconImage directly.
29 ExtensionActionIconFactory::ExtensionActionIconFactory(
30 const Extension* extension, Observer* observer)
31 : extension_(extension),
32 observer_(observer),
33 last_icon_set_(NULL),
34 last_size_(0) {
35 }
36
37 ExtensionActionIconFactory::~ExtensionActionIconFactory() {}
38
39 // extensions::IconImage::Observer overrides.
40 void ExtensionActionIconFactory::OnExtensionIconImageChanged(IconImage* image) {
41 observer_->OnIconUpdated();
42 }
43
44 gfx::ImageSkia ExtensionActionIconFactory::GetIcon(
45 const ExtensionIconSet* icon_set,
46 int desired_size) {
47 // If icon set hasn't changed, return the present icon.
48 if (icon_.get() && last_icon_set_ == icon_set) {
49 DCHECK_EQ(last_size_, desired_size);
Jeffrey Yasskin 2012/09/13 00:23:36 I don't see a reason to DCHECK that the sizes matc
tbarzic 2012/09/13 02:01:01 Done.
50 return icon_->image_skia();
51 }
52
53 // TODO(tbarzic): Cache old icon, so we don't have to reload it if gets
54 // requested again.
55 icon_.reset(
56 new IconImage(extension_, *icon_set, desired_size, GetDefaultIcon(),
57 this));
58 last_icon_set_ = icon_set;
59 last_size_ = desired_size;
60
61 return icon_->image_skia();
62 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698