diff options
author | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-30 00:42:31 +0000 |
---|---|---|
committer | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-30 00:42:31 +0000 |
commit | 74acd4f21a4d07ca0133eea3ffcde3927d8ba778 (patch) | |
tree | 373331a20dbdc08b366f5283ad23eee49829781f | |
parent | c62206736bb74c6af9524cdff9f6789bdfac9fd6 (diff) | |
download | chromium_src-74acd4f21a4d07ca0133eea3ffcde3927d8ba778.zip chromium_src-74acd4f21a4d07ca0133eea3ffcde3927d8ba778.tar.gz chromium_src-74acd4f21a4d07ca0133eea3ffcde3927d8ba778.tar.bz2 |
mac: Delete GetCachedImageWithName(), it's no longer used.
We used to load some images (mostly pdfs) from the app bundle instead
of from a pak file. We now load everything* from pak files, so this
is no longer necessary.
*: We still load 4 pdf files from the bundle via nib files, see issue 111101.
BUG=138772
TBR=avi
Review URL: https://codereview.chromium.org/12096047
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@179484 0039d316-1c4b-4281-b951-d872f2087c98
19 files changed, 0 insertions, 192 deletions
diff --git a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.mm b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.mm index 267a940..4a19e65 100644 --- a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.mm +++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.mm @@ -58,7 +58,6 @@ #include "ui/base/l10n/l10n_util_mac.h" #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/image/image.h" -#include "ui/gfx/mac/nsimage_cache.h" using content::OpenURLParams; using content::Referrer; diff --git a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_button_cell_unittest.mm b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_button_cell_unittest.mm index b14a850..5884de4 100644 --- a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_button_cell_unittest.mm +++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_button_cell_unittest.mm @@ -7,7 +7,6 @@ #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" #include "grit/ui_resources.h" #include "ui/base/resource/resource_bundle.h" -#include "ui/gfx/mac/nsimage_cache.h" namespace { diff --git a/chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.mm b/chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.mm index d1880c7..7667860 100644 --- a/chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.mm +++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.mm @@ -14,7 +14,6 @@ #include "grit/ui_resources.h" #include "ui/base/l10n/l10n_util_mac.h" #include "ui/base/resource/resource_bundle.h" -#include "ui/gfx/mac/nsimage_cache.h" using content::UserMetricsAction; diff --git a/chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell_unittest.mm b/chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell_unittest.mm index 18c5c52..34d6e0e 100644 --- a/chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell_unittest.mm +++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell_unittest.mm @@ -15,7 +15,6 @@ #include "testing/platform_test.h" #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/image/image.h" -#include "ui/gfx/mac/nsimage_cache.h" // Simple class to remember how many mouseEntered: and mouseExited: // calls it gets. Only used by BookmarkMouseForwarding but placed diff --git a/chrome/browser/ui/cocoa/bookmarks/bookmark_drag_drop.mm b/chrome/browser/ui/cocoa/bookmarks/bookmark_drag_drop.mm index a57be9c..6ae660b 100644 --- a/chrome/browser/ui/cocoa/bookmarks/bookmark_drag_drop.mm +++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_drag_drop.mm @@ -22,7 +22,6 @@ #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" #include "grit/ui_resources.h" #include "ui/base/resource/resource_bundle.h" -#include "ui/gfx/mac/nsimage_cache.h" #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" namespace chrome { diff --git a/chrome/browser/ui/cocoa/bookmarks/bookmark_menu_bridge.mm b/chrome/browser/ui/cocoa/bookmarks/bookmark_menu_bridge.mm index 61108b2..eb4bb58 100644 --- a/chrome/browser/ui/cocoa/bookmarks/bookmark_menu_bridge.mm +++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_menu_bridge.mm @@ -20,7 +20,6 @@ #include "ui/base/l10n/l10n_util.h" #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/image/image.h" -#include "ui/gfx/mac/nsimage_cache.h" BookmarkMenuBridge::BookmarkMenuBridge(Profile* profile, NSMenu* menu) : menuIsValid_(false), diff --git a/chrome/browser/ui/cocoa/browser/avatar_button_controller.mm b/chrome/browser/ui/cocoa/browser/avatar_button_controller.mm index 2c19371..32b8e41 100644 --- a/chrome/browser/ui/cocoa/browser/avatar_button_controller.mm +++ b/chrome/browser/ui/cocoa/browser/avatar_button_controller.mm @@ -27,7 +27,6 @@ #include "ui/base/resource/resource_bundle.h" #include "ui/base/l10n/l10n_util_mac.h" #include "ui/gfx/image/image.h" -#include "ui/gfx/mac/nsimage_cache.h" #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" @interface AvatarButtonController (Private) diff --git a/chrome/browser/ui/cocoa/extensions/browser_actions_controller.mm b/chrome/browser/ui/cocoa/extensions/browser_actions_controller.mm index e32ff54..6b99c20 100644 --- a/chrome/browser/ui/cocoa/extensions/browser_actions_controller.mm +++ b/chrome/browser/ui/cocoa/extensions/browser_actions_controller.mm @@ -33,7 +33,6 @@ #include "content/public/browser/notification_source.h" #include "grit/theme_resources.h" #import "third_party/GTM/AppKit/GTMNSAnimation+Duration.h" -#include "ui/gfx/mac/nsimage_cache.h" using extensions::Extension; using extensions::ExtensionList; diff --git a/chrome/browser/ui/cocoa/history_menu_bridge.mm b/chrome/browser/ui/cocoa/history_menu_bridge.mm index 7f8eb85..ac1d1bf 100644 --- a/chrome/browser/ui/cocoa/history_menu_bridge.mm +++ b/chrome/browser/ui/cocoa/history_menu_bridge.mm @@ -33,7 +33,6 @@ #include "ui/gfx/codec/png_codec.h" #include "ui/gfx/favicon_size.h" #include "ui/gfx/image/image.h" -#include "ui/gfx/mac/nsimage_cache.h" namespace { diff --git a/chrome/browser/ui/cocoa/notifications/balloon_controller.mm b/chrome/browser/ui/cocoa/notifications/balloon_controller.mm index b377b3d..69feed6 100644 --- a/chrome/browser/ui/cocoa/notifications/balloon_controller.mm +++ b/chrome/browser/ui/cocoa/notifications/balloon_controller.mm @@ -24,7 +24,6 @@ #include "grit/theme_resources.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/resource/resource_bundle.h" -#include "ui/gfx/mac/nsimage_cache.h" namespace { diff --git a/chrome/browser/ui/cocoa/nsimage_cache_unittest.mm b/chrome/browser/ui/cocoa/nsimage_cache_unittest.mm deleted file mode 100644 index de8f647..0000000 --- a/chrome/browser/ui/cocoa/nsimage_cache_unittest.mm +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (c) 2011 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. - -#import <Cocoa/Cocoa.h> - -#include "base/file_path.h" -#include "base/mac/mac_util.h" -#include "base/path_service.h" -#include "chrome/common/chrome_constants.h" -#include "testing/gtest/include/gtest/gtest.h" -#include "testing/platform_test.h" -#include "ui/gfx/mac/nsimage_cache.h" - -// This tests nsimage_cache, which lives in base/. The unit test is in -// chrome/ because it depends on having a built-up Chrome present. - -namespace { - -class NSImageCacheTest : public PlatformTest { - public: -}; - -TEST_F(NSImageCacheTest, LookupFound) { - EXPECT_TRUE(gfx::GetCachedImageWithName(@"product_logo_32.png") != nil) - << "Failed to find the toolbar image?"; -} - -TEST_F(NSImageCacheTest, LookupCached) { - EXPECT_EQ(gfx::GetCachedImageWithName(@"product_logo_32.png"), - gfx::GetCachedImageWithName(@"product_logo_32.png")) - << "Didn't get the same NSImage back?"; -} - -TEST_F(NSImageCacheTest, LookupMiss) { - EXPECT_TRUE(gfx::GetCachedImageWithName(@"should_not.exist") == nil) - << "There shouldn't be an image with this name?"; -} - -TEST_F(NSImageCacheTest, LookupFoundAndClear) { - NSImage *first = gfx::GetCachedImageWithName(@"product_logo_32.png"); - // Hang on to the first image so that the second one doesn't get allocated - // in the same location by (bad) luck. - [[first retain] autorelease]; - EXPECT_TRUE(first != nil) - << "Failed to find the toolbar image?"; - gfx::ClearCachedImages(); - NSImage *second = gfx::GetCachedImageWithName(@"product_logo_32.png"); - EXPECT_TRUE(second != nil) - << "Failed to find the toolbar image...again?"; - EXPECT_NE(second, first) - << "how'd we get the same image after a cache clear?"; -} - -TEST_F(NSImageCacheTest, AutoTemplating) { - NSImage *templateImage = - gfx::GetCachedImageWithName(@"find_next_Template.pdf"); - EXPECT_TRUE([templateImage isTemplate] == YES) - << "Image ending in 'Template' should be marked as being a template"; - NSImage *nonTemplateImage = - gfx::GetCachedImageWithName(@"aliasCursor.png"); - EXPECT_FALSE([nonTemplateImage isTemplate] == YES) - << "Image not ending in 'Template' should not be marked as being a " - "template"; -} - -} // namespace diff --git a/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm b/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm index ba83452..3eed218 100644 --- a/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm +++ b/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm @@ -25,7 +25,6 @@ #import "third_party/mozilla/NSPasteboard+Utils.h" #include "ui/base/clipboard/clipboard.h" #include "ui/base/resource/resource_bundle.h" -#include "ui/gfx/mac/nsimage_cache.h" #include "ui/gfx/rect.h" using content::WebContents; diff --git a/chrome/browser/ui/cocoa/panels/panel_titlebar_view_cocoa.mm b/chrome/browser/ui/cocoa/panels/panel_titlebar_view_cocoa.mm index e85ba96..7dd5f9d 100644 --- a/chrome/browser/ui/cocoa/panels/panel_titlebar_view_cocoa.mm +++ b/chrome/browser/ui/cocoa/panels/panel_titlebar_view_cocoa.mm @@ -21,7 +21,6 @@ #import "third_party/GTM/AppKit/GTMNSColor+Luminance.h" #include "ui/base/l10n/l10n_util_mac.h" #include "ui/base/resource/resource_bundle.h" -#include "ui/gfx/mac/nsimage_cache.h" #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" #include "ui/gfx/image/image.h" diff --git a/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm b/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm index 2477943..07c9224 100644 --- a/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm +++ b/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm @@ -70,7 +70,6 @@ #include "ui/base/resource/resource_bundle.h" #include "ui/base/theme_provider.h" #include "ui/gfx/image/image.h" -#include "ui/gfx/mac/nsimage_cache.h" using content::OpenURLParams; using content::Referrer; diff --git a/chrome/chrome_tests_unit.gypi b/chrome/chrome_tests_unit.gypi index d72a536..484e80c 100644 --- a/chrome/chrome_tests_unit.gypi +++ b/chrome/chrome_tests_unit.gypi @@ -1298,7 +1298,6 @@ 'browser/ui/cocoa/menu_button_unittest.mm', 'browser/ui/cocoa/menu_controller_unittest.mm', 'browser/ui/cocoa/notifications/balloon_controller_unittest.mm', - 'browser/ui/cocoa/nsimage_cache_unittest.mm', 'browser/ui/cocoa/nsmenuitem_additions_unittest.mm', 'browser/ui/cocoa/nsview_additions_unittest.mm', 'browser/ui/cocoa/omnibox/omnibox_popup_view_mac_unittest.mm', diff --git a/content/browser/web_contents/web_drag_source_mac.mm b/content/browser/web_contents/web_drag_source_mac.mm index f386e57..b59be11 100644 --- a/content/browser/web_contents/web_drag_source_mac.mm +++ b/content/browser/web_contents/web_drag_source_mac.mm @@ -31,7 +31,6 @@ #include "ui/base/clipboard/custom_data_helper.h" #include "ui/base/dragdrop/cocoa_dnd_util.h" #include "ui/gfx/image/image.h" -#include "ui/gfx/mac/nsimage_cache.h" #include "webkit/glue/webdropdata.h" using base::SysNSStringToUTF8; diff --git a/ui/gfx/mac/nsimage_cache.h b/ui/gfx/mac/nsimage_cache.h deleted file mode 100644 index e43781f..0000000 --- a/ui/gfx/mac/nsimage_cache.h +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (c) 2012 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 UI_GFX_MAC_NSIMAGE_CACHE_H_ -#define UI_GFX_MAC_NSIMAGE_CACHE_H_ - -#include "ui/base/ui_export.h" - -#ifdef __OBJC__ -@class NSImage; -@class NSString; -#else -class NSImage; -class NSString; -#endif - -namespace gfx { - -// Returns an autoreleased image from the framework bundle -// (base::mac::FrameworkBundle()) with the given name, and keeps it in memory so -// future fetches are fast. -// NOTE: -// - This should only be called on the main thread. -// - The caller should retain the image if they want to keep it around, as -// the cache could have limit on size/lifetime, etc. -UI_EXPORT NSImage* GetCachedImageWithName(NSString* name); - -// Clears the image cache. -UI_EXPORT void ClearCachedImages(void); - -} // namespace gfx - -#endif // UI_GFX_MAC_NSIMAGE_CACHE_H_ diff --git a/ui/gfx/mac/nsimage_cache.mm b/ui/gfx/mac/nsimage_cache.mm deleted file mode 100644 index 997a548..0000000 --- a/ui/gfx/mac/nsimage_cache.mm +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright (c) 2011 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. - -#include "ui/gfx/mac/nsimage_cache.h" - -#import <AppKit/AppKit.h> - -#include "base/logging.h" -#include "base/mac/bundle_locations.h" -#include "base/mac/mac_util.h" - -// When C++ exceptions are disabled, the C++ library defines |try| and -// |catch| so as to allow exception-expecting C++ code to build properly when -// language support for exceptions is not present. These macros interfere -// with the use of |@try| and |@catch| in Objective-C files such as this one. -// Undefine these macros here, after everything has been #included, since -// there will be no C++ uses and only Objective-C uses from this point on. -#undef try -#undef catch - -namespace gfx { - -static NSMutableDictionary* image_cache = nil; - -NSImage* GetCachedImageWithName(NSString* name) { - DCHECK(name); - - // NOTE: to make this thread safe, we'd have to sync on the cache and - // also force all the bundle calls on the main thread. - - if (!image_cache) { - image_cache = [[NSMutableDictionary alloc] init]; - DCHECK(image_cache); - } - - NSImage* result = [image_cache objectForKey:name]; - if (!result) { - DVLOG_IF(1, [[name pathExtension] length] == 0) << "Suggest including the " - "extension in the image name"; - - NSString* path = [base::mac::FrameworkBundle() pathForImageResource:name]; - if (path) { - @try { - result = [[[NSImage alloc] initWithContentsOfFile:path] autorelease]; - if (result) { - // Auto-template images with names ending in "Template". - NSString* extensionlessName = [name stringByDeletingPathExtension]; - if ([extensionlessName hasSuffix:@"Template"]) - [result setTemplate:YES]; - - [image_cache setObject:result forKey:name]; - } - } - @catch (id err) { - DLOG(ERROR) << "Failed to load the image for name '" - << [name UTF8String] << "' from path '" << [path UTF8String] - << "', error: " << [[err description] UTF8String]; - result = nil; - } - } - } - - // TODO: if we ever limit the cache size, this should retain & autorelease - // the image. - return result; -} - -void ClearCachedImages(void) { - // NOTE: to make this thread safe, we'd have to sync on the cache. - [image_cache removeAllObjects]; -} - -} // namespace gfx @@ -405,8 +405,6 @@ 'gfx/insets_f.h', 'gfx/interpolated_transform.cc', 'gfx/interpolated_transform.h', - 'gfx/mac/nsimage_cache.h', - 'gfx/mac/nsimage_cache.mm', 'gfx/mac/scoped_ns_disable_screen_updates.h', 'gfx/native_widget_types.h', 'gfx/pango_util.cc', |