Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7656)

Unified Diff: chrome/common/extensions/extension.h

Issue 2867008: Show extension icons next to their top-level context menu items.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/tab_contents/render_view_context_menu.cc ('k') | chrome/common/extensions/extension.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/extension.h
===================================================================
--- chrome/common/extensions/extension.h (revision 50770)
+++ chrome/common/extensions/extension.h (working copy)
@@ -17,6 +17,7 @@
#include "chrome/common/extensions/extension_extent.h"
#include "chrome/common/extensions/user_script.h"
#include "chrome/common/extensions/url_pattern.h"
+#include "gfx/size.h"
#include "googleurl/src/gurl.h"
#include "testing/gtest/include/gtest/gtest_prod.h"
#include "third_party/skia/include/core/SkBitmap.h"
@@ -354,15 +355,30 @@
void set_being_upgraded(bool value) { being_upgraded_ = value; }
// Image cache related methods. These are only valid on the UI thread and
- // not maintained by this class. See ImageLoadingTracker for usage.
+ // not maintained by this class. See ImageLoadingTracker for usage. The
+ // |original_size| parameter should be the size of the image at |source|
+ // before any scaling may have been done to produce the pixels in |image|.
void SetCachedImage(const ExtensionResource& source,
- const SkBitmap& image);
- bool HasCachedImage(const ExtensionResource& source);
- SkBitmap GetCachedImage(const ExtensionResource& source);
+ const SkBitmap& image,
+ const gfx::Size& original_size);
+ bool HasCachedImage(const ExtensionResource& source,
+ const gfx::Size& max_size);
+ SkBitmap GetCachedImage(const ExtensionResource& source,
+ const gfx::Size& max_size);
private:
- typedef std::map<FilePath, SkBitmap> ImageCache;
+ // We keep a cache of images loaded from extension resources based on their
+ // path and a string representation of a size that may have been used to
+ // scale it (or the empty string if the image is at its original size).
+ typedef std::pair<FilePath, std::string> ImageCacheKey;
+ typedef std::map<ImageCacheKey, SkBitmap> ImageCache;
+ // Helper function for implementing HasCachedImage/GetCachedImage. A return
+ // value of NULL means there is no matching image cached (we allow caching an
+ // empty SkBitmap).
+ SkBitmap* GetCachedImageImpl(const ExtensionResource& source,
+ const gfx::Size& max_size);
+
// Helper method that loads a UserScript object from a
// dictionary in the content_script list of the manifest.
bool LoadUserScriptHelper(const DictionaryValue* content_script,
@@ -525,8 +541,7 @@
int launch_width_;
int launch_height_;
- // Cached images for this extension. This maps from the relative_path of the
- // resource to the cached image.
+ // Cached images for this extension.
ImageCache image_cache_;
// The omnibox keyword for this extension, or empty if there is none.
« no previous file with comments | « chrome/browser/tab_contents/render_view_context_menu.cc ('k') | chrome/common/extensions/extension.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698