diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-08 19:01:02 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-08 19:01:02 +0000 |
commit | 0f38ceaebbc66b29fb3297516f74f9c8379d902f (patch) | |
tree | 8af215d4a01c60a2d3a5fe0aa55fd35cab05a744 /chrome/browser/icon_manager.cc | |
parent | eac83f0d14be2fed85edf2ffad934dd1309819e7 (diff) | |
download | chromium_src-0f38ceaebbc66b29fb3297516f74f9c8379d902f.zip chromium_src-0f38ceaebbc66b29fb3297516f74f9c8379d902f.tar.gz chromium_src-0f38ceaebbc66b29fb3297516f74f9c8379d902f.tar.bz2 |
Stub implementation of linux, mac icon loader/manager.
Define a platform specific type IconGroupID which helps with caching multiple requests for the same icon. Previously we just used the file path (or the extension), but on POSIX we use mime types rather than extensions.
Review URL: http://codereview.chromium.org/113120
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15665 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/icon_manager.cc')
-rw-r--r-- | chrome/browser/icon_manager.cc | 32 |
1 files changed, 10 insertions, 22 deletions
diff --git a/chrome/browser/icon_manager.cc b/chrome/browser/icon_manager.cc index 827e0b1..f2a0cef 100644 --- a/chrome/browser/icon_manager.cc +++ b/chrome/browser/icon_manager.cc @@ -19,14 +19,8 @@ IconManager::~IconManager() { SkBitmap* IconManager::LookupIcon(const FilePath& file_name, IconLoader::IconSize size) { - FilePath path = file_name; - FilePath::StringType extension = file_util::GetFileExtensionFromPath(path); -#if defined(OS_WIN) - if (extension != L"exe" && extension != L"dll" && extension != L"ico") - path = FilePath(L'.' + extension); -#endif - - IconMap::iterator it = icon_cache_.find(CacheKey(path, size)); + IconGroupID group = GetGroupIDFromFilepath(file_name); + IconMap::iterator it = icon_cache_.find(CacheKey(group, size)); if (it != icon_cache_.end()) return it->second; @@ -38,20 +32,14 @@ IconManager::Handle IconManager::LoadIcon( IconLoader::IconSize size, CancelableRequestConsumerBase* consumer, IconRequestCallback* callback) { - FilePath path = file_name; - FilePath::StringType extension = file_util::GetFileExtensionFromPath(path); -#if defined(OS_WIN) - if (extension != L"exe" && extension != L"dll" && extension != L"ico") - path = FilePath(L'.' + extension); -#endif - + IconGroupID group = GetGroupIDFromFilepath(file_name); IconRequest* request = new IconRequest(callback); AddRequest(request, consumer); - IconLoader* loader = IconLoader::Create(path, size, this); + IconLoader* loader = new IconLoader(group, size, this); loader->AddRef(); loader->Start(); - ClientRequest client_request = { request, path, size }; + ClientRequest client_request = { request, group, size }; requests_[loader] = client_request; return request->handle(); } @@ -77,7 +65,7 @@ bool IconManager::OnBitmapLoaded(IconLoader* source, SkBitmap* result) { // Cache the bitmap. Watch out: |result| or the cached bitmap may be NULL to // indicate a current or past failure. - CacheKey key(client_request.file_name, client_request.size); + CacheKey key(client_request.group, client_request.size); IconMap::iterator it = icon_cache_.find(key); if (it != icon_cache_.end() && result && it->second) { it->second->swap(*result); @@ -96,14 +84,14 @@ bool IconManager::OnBitmapLoaded(IconLoader* source, SkBitmap* result) { return true; // Indicates we took ownership of result. } -IconManager::CacheKey::CacheKey(const FilePath& file_name, +IconManager::CacheKey::CacheKey(const IconGroupID& group, IconLoader::IconSize size) - : file_name(file_name), + : group(group), size(size) { } bool IconManager::CacheKey::operator<(const CacheKey &other) const { - if (file_name != other.file_name) - return file_name < other.file_name; + if (group != other.group) + return group < other.group; return size < other.size; } |