diff options
author | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-02 19:08:44 +0000 |
---|---|---|
committer | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-02 19:08:44 +0000 |
commit | 7fef9717afc4570883a9207fb8ea70f295685488 (patch) | |
tree | 232d97320ae035c7cad778335e6b32c1ce1907db /chrome/browser/page_info_model.h | |
parent | 4c7003dc599960bb569dd586e3065f755879deb4 (diff) | |
download | chromium_src-7fef9717afc4570883a9207fb8ea70f295685488.zip chromium_src-7fef9717afc4570883a9207fb8ea70f295685488.tar.gz chromium_src-7fef9717afc4570883a9207fb8ea70f295685488.tar.bz2 |
Refactor the code for loading icons into the PageInfoModel.
This code is basically duplicated twice on each platform. This consolidates all
that into PageInfoModel::GetIconImage() and renames the SectionInfo.state to icon_id.
BUG=none
TEST=Page info windows and bubbles work as they did before across all platforms.
Review URL: http://codereview.chromium.org/3560004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61308 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/page_info_model.h')
-rw-r--r-- | chrome/browser/page_info_model.h | 54 |
1 files changed, 46 insertions, 8 deletions
diff --git a/chrome/browser/page_info_model.h b/chrome/browser/page_info_model.h index 77ba614..04a7a2d 100644 --- a/chrome/browser/page_info_model.h +++ b/chrome/browser/page_info_model.h @@ -14,8 +14,18 @@ #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. @@ -34,23 +44,37 @@ class PageInfoModel { SECTION_INFO_FIRST_VISIT, }; - enum SectionInfoState { - SECTION_STATE_OK = 0, + // 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, + // State is OK. + ICON_STATE_OK, // For example, if state is OK but contains mixed content. - SECTION_STATE_WARNING_MINOR, + ICON_STATE_WARNING_MINOR, // For example, if content was served over HTTP. - SECTION_STATE_WARNING_MAJOR, + ICON_STATE_WARNING_MAJOR, // For example, unverified identity over HTTPS. - SECTION_STATE_ERROR, + ICON_STATE_ERROR, + // An information icon. + ICON_STATE_INFO }; struct SectionInfo { - SectionInfo(SectionInfoState state, + SectionInfo(SectionStateIcon icon_id, const string16& title, const string16& headline, const string16& description, SectionInfoType type) - : state(state), + : icon_id(icon_id), title(title), headline(headline), description(description), @@ -58,7 +82,7 @@ class PageInfoModel { } // The overall state of the connection (error, warning, ok). - SectionInfoState state; + SectionStateIcon icon_id; // The title of the section. string16 title; @@ -84,6 +108,9 @@ class PageInfoModel { int GetSectionCount(); SectionInfo GetSectionInfo(int index); + // Returns the native image type for an icon with the given id. + ImageType GetIconImage(SectionStateIcon icon_id); + // Callback from history service with number of visits to url. void OnGotVisitCountToHost(HistoryService::Handle handle, bool found_visits, @@ -96,10 +123,21 @@ class PageInfoModel { // Testing constructor. DO NOT USE. 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); + PageInfoModelObserver* observer_; std::vector<SectionInfo> sections_; + // All possible icons that go next to the text descriptions to indicate state. + std::vector<ImageType> icons_; + // Used to request number of visits. CancelableRequestConsumer request_consumer_; |