summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa/table_row_nsimage_cache.h
diff options
context:
space:
mode:
authorthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-13 03:26:13 +0000
committerthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-13 03:26:13 +0000
commit15be81387f3ab40242d28f3ee53adc3d6a1fac1c (patch)
tree85ec956d20e07971d630aa1920eacdf73401347b /chrome/browser/cocoa/table_row_nsimage_cache.h
parent969a7b97029963ba6c6dd1456132d844160b5ad0 (diff)
downloadchromium_src-15be81387f3ab40242d28f3ee53adc3d6a1fac1c.zip
chromium_src-15be81387f3ab40242d28f3ee53adc3d6a1fac1c.tar.gz
chromium_src-15be81387f3ab40242d28f3ee53adc3d6a1fac1c.tar.bz2
Mac: Add favicons to task manager.
Pull NSImage cache out of search engine dialog into its own class, reuse that. Implement browser icon code in task_manager_resource_provider's browser resource provider. BUG=13156 TEST=Open task manager. You should see icons. Open search engine manager, should still show icons. Review URL: http://codereview.chromium.org/549021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36087 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/table_row_nsimage_cache.h')
-rw-r--r--chrome/browser/cocoa/table_row_nsimage_cache.h50
1 files changed, 50 insertions, 0 deletions
diff --git a/chrome/browser/cocoa/table_row_nsimage_cache.h b/chrome/browser/cocoa/table_row_nsimage_cache.h
new file mode 100644
index 0000000..04ca13e
--- /dev/null
+++ b/chrome/browser/cocoa/table_row_nsimage_cache.h
@@ -0,0 +1,50 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_COCOA_TABLE_ROW_NSIMAGE_CACHE_H_
+#define CHROME_BROWSER_COCOA_TABLE_ROW_NSIMAGE_CACHE_H_
+
+#import <Cocoa/Cocoa.h>
+
+#include "base/scoped_nsobject.h"
+#include "third_party/skia/include/core/SkBitmap.h"
+
+// There are several dialogs that display tabular data with one SkBitmap
+// per row. This class converts these SkBitmaps to NSImages on demand, and
+// caches the results.
+class TableRowNSImageCache {
+ public:
+ // Interface this cache expects for its table model.
+ class Table {
+ public:
+ // Returns the number of rows in the table.
+ virtual int RowCount() const = 0;
+
+ // Returns the icon of the |row|th row.
+ virtual SkBitmap GetIcon(int row) const = 0;
+ };
+
+ // |model| must outlive the cache.
+ explicit TableRowNSImageCache(Table* model);
+
+ // Lazily converts the image at the given row and caches it in |icon_images_|.
+ NSImage* GetImageForRow(int row);
+
+ // Call these functions every time the table changes, to update the cache.
+ void OnModelChanged();
+ void OnItemsChanged(int start, int length);
+ void OnItemsAdded(int start, int length);
+ void OnItemsRemoved(int start, int length);
+
+ private:
+ // The table model we query for row count and icons.
+ Table* model_; // weak
+
+ // Stores strong NSImage refs for icons. If an entry is NULL, it will be
+ // created in GetImageForRow().
+ scoped_nsobject<NSPointerArray> icon_images_;
+};
+
+#endif // CHROME_BROWSER_COCOA_TABLE_ROW_NSIMAGE_CACHE_H_
+