summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorrsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-05 19:21:41 +0000
committerrsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-05 19:21:41 +0000
commitf9cab10c8331d125c6bf31cc43b2a18c2fa2784c (patch)
tree1cf11ee77f4e8741767576171e5a6d6525a9ab09 /chrome/browser
parentaea5a7cf666f0c7077833fb33a255df21b9f9a00 (diff)
downloadchromium_src-f9cab10c8331d125c6bf31cc43b2a18c2fa2784c.zip
chromium_src-f9cab10c8331d125c6bf31cc43b2a18c2fa2784c.tar.gz
chromium_src-f9cab10c8331d125c6bf31cc43b2a18c2fa2784c.tar.bz2
Define gfx::NativeImage and add ResourceBundle::GetNativeImageNamed().
BUG=none TEST=compile Review URL: http://codereview.chromium.org/3597008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61545 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/page_info_model.cc14
-rw-r--r--chrome/browser/page_info_model.h31
2 files changed, 11 insertions, 34 deletions
diff --git a/chrome/browser/page_info_model.cc b/chrome/browser/page_info_model.cc
index 2b2e8da..c4e76eb 100644
--- a/chrome/browser/page_info_model.cc
+++ b/chrome/browser/page_info_model.cc
@@ -264,7 +264,7 @@ PageInfoModel::PageInfoModel(Profile* profile,
PageInfoModel::~PageInfoModel() {
#if defined(OS_MACOSX)
// Release the NSImages.
- for (std::vector<ImageType>::iterator it = icons_.begin();
+ for (std::vector<gfx::NativeImage>::iterator it = icons_.begin();
it != icons_.end(); ++it) {
mac_util::NSObjectRelease(*it);
}
@@ -280,7 +280,7 @@ PageInfoModel::SectionInfo PageInfoModel::GetSectionInfo(int index) {
return sections_[index];
}
-PageInfoModel::ImageType PageInfoModel::GetIconImage(SectionStateIcon icon_id) {
+gfx::NativeImage PageInfoModel::GetIconImage(SectionStateIcon icon_id) {
if (icon_id == ICON_NONE)
return NULL;
// TODO(rsesek): Remove once the window is replaced with the bubble.
@@ -359,17 +359,13 @@ void PageInfoModel::Init() {
icons_.push_back(GetBitmapNamed(IDR_PAGEINFO_INFO));
}
-PageInfoModel::ImageType PageInfoModel::GetBitmapNamed(int resource_id) {
+gfx::NativeImage PageInfoModel::GetBitmapNamed(int resource_id) {
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
+ gfx::NativeImage image = rb.GetNativeImageNamed(resource_id);
#if defined(OS_MACOSX)
// Unlike other platforms, the Mac ResourceBundle does not keep a shared image
// cache. These are released in the dtor.
- ImageType image = rb.GetNSImageNamed(resource_id);
mac_util::NSObjectRetain(image);
- return image;
-#elif defined(USE_X11) && !defined(TOOLKIT_VIEWS)
- return rb.GetPixbufNamed(resource_id);
-#else
- return rb.GetBitmapNamed(resource_id);
#endif
+ return image;
}
diff --git a/chrome/browser/page_info_model.h b/chrome/browser/page_info_model.h
index 04a7a2d..3e6b962 100644
--- a/chrome/browser/page_info_model.h
+++ b/chrome/browser/page_info_model.h
@@ -8,24 +8,15 @@
#include <vector>
+#include "gfx/native_widget_types.h"
#include "base/string16.h"
#include "chrome/browser/cancelable_request.h"
#include "chrome/browser/history/history.h"
#include "chrome/browser/tab_contents/navigation_entry.h"
#include "googleurl/src/gurl.h"
-#ifdef __OBJC__
-@class NSImage;
-#else
-class NSImage;
-#endif // __OBJC__
class PrefService;
class Profile;
-class SkBitmap;
-
-#if defined(USE_X11) && !defined(TOOLKIT_VIEWS)
-typedef struct _GdkPixbuf GdkPixbuf;
-#endif
// The model that provides the information that should be displayed in the page
// info dialog/bubble.
@@ -44,15 +35,6 @@ class PageInfoModel {
SECTION_INFO_FIRST_VISIT,
};
- // TODO(rsesek): Extract this information out to gfx::NativeImage.
-#if defined(OS_MACOSX)
- typedef NSImage* ImageType;
-#elif defined(USE_X11) && !defined(TOOLKIT_VIEWS)
- typedef GdkPixbuf* ImageType;
-#else
- typedef const SkBitmap* ImageType;
-#endif
-
enum SectionStateIcon {
// No icon.
ICON_NONE = -1,
@@ -109,7 +91,7 @@ class PageInfoModel {
SectionInfo GetSectionInfo(int index);
// Returns the native image type for an icon with the given id.
- ImageType GetIconImage(SectionStateIcon icon_id);
+ gfx::NativeImage GetIconImage(SectionStateIcon icon_id);
// Callback from history service with number of visits to url.
void OnGotVisitCountToHost(HistoryService::Handle handle,
@@ -126,17 +108,16 @@ class PageInfoModel {
// Shared initialization for default and testing constructor.
void Init();
- // Gets the native image resource of the given id from the ResourceBundle.
- // Mac only: image is owned by caller. On other platforms, the image is owned
- // by the shared ResourceBundle.
- ImageType GetBitmapNamed(int resource_id);
+ // Wrapper for ResourceBundle::GetNativeImage() so that Mac can retain its
+ // icons.
+ gfx::NativeImage GetBitmapNamed(int resource_id);
PageInfoModelObserver* observer_;
std::vector<SectionInfo> sections_;
// All possible icons that go next to the text descriptions to indicate state.
- std::vector<ImageType> icons_;
+ std::vector<gfx::NativeImage> icons_;
// Used to request number of visits.
CancelableRequestConsumer request_consumer_;