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

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 }
35
36 ExtensionActionIconFactory::~ExtensionActionIconFactory() {}
37
38 // extensions::IconImage::Observer overrides.
39 void ExtensionActionIconFactory::OnExtensionIconImageChanged(IconImage* image) {
40 observer_->OnIconUpdated();
41 }
42
43 gfx::ImageSkia ExtensionActionIconFactory::GetIcon(
44 const ExtensionIconSet* icon_set,
45 const gfx::Size& desired_size) {
46 // If icon set hasn't changed, return the present icon.
47 if (icon_.get() && last_icon_set_ == icon_set && last_size_ == desired_size) {
48 return icon_->image_skia();
49 }
50
51 // TODO(tbarzic): Cache old icon, so we don't have to reload it if gets
52 // requested again.
53 icon_.reset(
54 new IconImage(extension_, *icon_set, desired_size.width(),
55 GetDefaultIcon(), this));
56 last_icon_set_ = icon_set;
57 last_size_ = desired_size;
58
59 return icon_->image_skia();
60 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698