Remove static caching of default favicon in CustomHomePagesTableModel

This fixes an assertion failure when trying to use this class on the Mac due to SkBitmap destruction happening during process exit handling.

BUG=None
TEST=Custom startup page list should still show default favicons.

Review URL: http://codereview.chromium.org/3028030

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@54014 0039d316-1c4b-4281-b951-d872f2087c98
parent 9658b007
......@@ -19,13 +19,12 @@
#include "grit/generated_resources.h"
#include "net/base/net_util.h"
// static
SkBitmap CustomHomePagesTableModel::default_favicon_;
CustomHomePagesTableModel::CustomHomePagesTableModel(Profile* profile)
: profile_(profile),
: default_favicon_(NULL),
profile_(profile),
observer_(NULL) {
InitClass();
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
default_favicon_ = rb.GetBitmapNamed(IDR_DEFAULT_FAVICON);
}
void CustomHomePagesTableModel::SetURLs(const std::vector<GURL>& urls) {
......@@ -109,7 +108,7 @@ std::wstring CustomHomePagesTableModel::GetText(int row, int column_id) {
SkBitmap CustomHomePagesTableModel::GetIcon(int row) {
DCHECK(row >= 0 && row < RowCount());
return entries_[row].icon.isNull() ? default_favicon_ : entries_[row].icon;
return entries_[row].icon.isNull() ? *default_favicon_ : entries_[row].icon;
}
std::wstring CustomHomePagesTableModel::GetTooltip(int row) {
......@@ -122,15 +121,6 @@ void CustomHomePagesTableModel::SetObserver(TableModelObserver* observer) {
observer_ = observer;
}
void CustomHomePagesTableModel::InitClass() {
static bool initialized = false;
if (!initialized) {
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
default_favicon_ = *rb.GetBitmapNamed(IDR_DEFAULT_FAVICON);
initialized = true;
}
}
void CustomHomePagesTableModel::LoadTitleAndFavIcon(Entry* entry) {
HistoryService* history_service =
profile_->GetHistoryService(Profile::EXPLICIT_ACCESS);
......
......@@ -71,8 +71,6 @@ class CustomHomePagesTableModel : public TableModel {
FaviconService::Handle fav_icon_handle;
};
static void InitClass();
// Loads the title and favicon for the specified entry.
void LoadTitleAndFavIcon(Entry* entry);
......@@ -109,7 +107,7 @@ class CustomHomePagesTableModel : public TableModel {
std::vector<Entry> entries_;
// Default icon to show when one can't be found for the URL.
static SkBitmap default_favicon_;
SkBitmap* default_favicon_;
// Profile used to load titles and icons.
Profile* profile_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment