summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autocomplete
diff options
context:
space:
mode:
authorthomasvl@chromium.org <thomasvl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-09 20:59:32 +0000
committerthomasvl@chromium.org <thomasvl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-09 20:59:32 +0000
commit655345e0991a974109e0f2656f6e00afbe8d9e59 (patch)
tree7fcca7714b4957f9efed3496e863c4f15b48941a /chrome/browser/autocomplete
parent5ce8cbcbf65f801bc7f52cc035027d0eb907add5 (diff)
downloadchromium_src-655345e0991a974109e0f2656f6e00afbe8d9e59.zip
chromium_src-655345e0991a974109e0f2656f6e00afbe8d9e59.tar.gz
chromium_src-655345e0991a974109e0f2656f6e00afbe8d9e59.tar.bz2
Added an helper namespace that provides fetches images from the app bundle and caches them, line NSImage imageNamed: but lets us control the bundle that's checked.
Unittest for the helper. Updated the current places that use +[NSImage imageNamed:] to use our cache helper. BUG=none TEST=All the ui images still load. Review URL: http://codereview.chromium.org/149393 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20309 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autocomplete')
-rw-r--r--chrome/browser/autocomplete/autocomplete_popup_view_mac.mm19
1 files changed, 10 insertions, 9 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_popup_view_mac.mm b/chrome/browser/autocomplete/autocomplete_popup_view_mac.mm
index ca4c8ec..f2a33d8 100644
--- a/chrome/browser/autocomplete/autocomplete_popup_view_mac.mm
+++ b/chrome/browser/autocomplete/autocomplete_popup_view_mac.mm
@@ -8,6 +8,7 @@
#include "chrome/browser/autocomplete/autocomplete_edit.h"
#include "chrome/browser/autocomplete/autocomplete_edit_view_mac.h"
#include "chrome/browser/autocomplete/autocomplete_popup_model.h"
+#include "chrome/browser/cocoa/nsimage_cache.h"
namespace {
@@ -40,28 +41,28 @@ static const NSColor* DescriptionTextColor() {
// gtk code.
NSImage* MatchIcon(const AutocompleteMatch& match) {
if (match.starred) {
- return [NSImage imageNamed:@"o2_star.png"];
+ return nsimage_cache::ImageNamed(@"o2_star.png");
}
switch (match.type) {
case AutocompleteMatch::URL_WHAT_YOU_TYPED:
case AutocompleteMatch::NAVSUGGEST: {
- return [NSImage imageNamed:@"o2_globe.png"];
+ return nsimage_cache::ImageNamed(@"o2_globe.png");
}
case AutocompleteMatch::HISTORY_URL:
case AutocompleteMatch::HISTORY_TITLE:
case AutocompleteMatch::HISTORY_BODY:
case AutocompleteMatch::HISTORY_KEYWORD: {
- return [NSImage imageNamed:@"o2_history.png"];
+ return nsimage_cache::ImageNamed(@"o2_history.png");
}
case AutocompleteMatch::SEARCH_WHAT_YOU_TYPED:
case AutocompleteMatch::SEARCH_HISTORY:
case AutocompleteMatch::SEARCH_SUGGEST:
case AutocompleteMatch::SEARCH_OTHER_ENGINE: {
- return [NSImage imageNamed:@"o2_search.png"];
+ return nsimage_cache::ImageNamed(@"o2_search.png");
}
case AutocompleteMatch::OPEN_HISTORY_PAGE: {
- return [NSImage imageNamed:@"o2_more.png"];
+ return nsimage_cache::ImageNamed(@"o2_more.png");
}
default:
NOTREACHED();
@@ -141,11 +142,11 @@ NSAttributedString* AutocompletePopupViewMac::MatchText(
NSAttributedString* emDash =
[[[NSAttributedString alloc] initWithString:rawEmDash
attributes:attributes] autorelease];
-
+
NSAttributedString* description =
DecorateMatchedString(match.description, match.description_class,
DescriptionTextColor(), font);
-
+
[as appendAttributedString:emDash];
[as appendAttributedString:description];
}
@@ -277,7 +278,7 @@ void AutocompletePopupViewMac::UpdatePopupAppearance() {
// because the popup doesn't need any of the field-like aspects of
// field_. The edit view could expose helper methods for attaching
// the window to the field.
-
+
// Locate |field_| on the screen.
NSRect r = [field_ convertRect:[field_ bounds] toView:nil];
r.origin = [[field_ window] convertBaseToScreen:r.origin];
@@ -306,7 +307,7 @@ void AutocompletePopupViewMac::UpdatePopupAppearance() {
[[field_ window] addChildWindow:popup_ ordered:NSWindowAbove];
}
}
-
+
// This is only called by model in SetSelectedLine() after updating
// everything. Popup should already be visible.
void AutocompletePopupViewMac::PaintUpdatesNow() {