summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_mac.h4
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_mac.mm41
-rw-r--r--chrome/browser/autocomplete/autocomplete_popup_view_mac.mm19
-rw-r--r--chrome/browser/cocoa/autocomplete_text_field_cell.mm4
-rw-r--r--chrome/browser/cocoa/location_bar_view_mac.mm7
5 files changed, 59 insertions, 16 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_mac.h b/chrome/browser/autocomplete/autocomplete_edit_view_mac.h
index a810465..069c6de4 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_mac.h
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_mac.h
@@ -102,6 +102,10 @@ class AutocompleteEditViewMac : public AutocompleteEditView,
// empty string if no appropriate data is found on |clipboard|.
static std::wstring GetClipboardText(Clipboard* clipboard);
+ // If |resource_id| has a PDF image which can be used, return it.
+ // Otherwise return the PNG image from the resource bundle.
+ static NSImage* ImageForResource(int resource_id);
+
private:
// Called when the user hits backspace in |field_|. Checks whether
// keyword search is being terminated. Returns true if the
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm b/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm
index ee502cb..ba19e51 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm
@@ -9,6 +9,7 @@
#include "app/clipboard/clipboard.h"
#include "app/clipboard/scoped_clipboard_writer.h"
#include "app/resource_bundle.h"
+#include "base/nsimage_cache_mac.h"
#include "base/string_util.h"
#include "base/sys_string_conversions.h"
#include "base/utf_string_conversions.h"
@@ -20,6 +21,7 @@
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/browser/toolbar_model.h"
#include "grit/generated_resources.h"
+#include "grit/theme_resources.h"
#include "net/base/escape.h"
// Focus-handling between |field_| and |model_| is a bit subtle.
@@ -119,6 +121,45 @@ NSRange ComponentToNSRange(const url_parse::Component& component) {
} // namespace
+NSImage* AutocompleteEditViewMac::ImageForResource(int resource_id) {
+ NSString* image_name = nil;
+
+ switch(resource_id) {
+ // From the autocomplete popup, or the star icon at the RHS of the
+ // text field.
+ case IDR_OMNIBOX_STAR : image_name = @"omnibox_star.pdf"; break;
+ case IDR_OMNIBOX_STAR_LIT : image_name = @"omnibox_star_lit.pdf"; break;
+
+ // Values from |AutocompleteMatch::TypeToIcon()|.
+ case IDR_OMNIBOX_SEARCH : image_name = @"omnibox_search.pdf"; break;
+ case IDR_OMNIBOX_HTTP : image_name = @"omnibox_http.pdf"; break;
+ case IDR_OMNIBOX_HISTORY : image_name = @"omnibox_history.pdf"; break;
+ case IDR_OMNIBOX_MORE : image_name = @"omnibox_more.pdf"; break;
+
+ // Values from |ToolbarModel::GetIcon()|.
+ case IDR_OMNIBOX_HTTPS_GREEN :
+ image_name = @"omnibox_https_green.pdf"; break;
+ case IDR_OMNIBOX_HTTPS_VALID :
+ image_name = @"omnibox_https_valid.pdf"; break;
+ case IDR_OMNIBOX_HTTPS_WARNING :
+ image_name = @"omnibox_https_warning.pdf"; break;
+ case IDR_OMNIBOX_HTTPS_INVALID :
+ image_name = @"omnibox_https_invalid.pdf"; break;
+ }
+
+ if (image_name) {
+ if (NSImage* image = nsimage_cache::ImageNamed(image_name)) {
+ return image;
+ } else {
+ DCHECK(image)
+ << "Missing image for " << base::SysNSStringToUTF8(image_name);
+ }
+ }
+
+ ResourceBundle& rb = ResourceBundle::GetSharedInstance();
+ return rb.GetNSImageNamed(resource_id);
+}
+
// TODO(shess): AutocompletePopupViewMac doesn't really need an
// NSTextField. It wants to know where the position the popup, what
// font to use, and it also needs to be able to attach the popup to
diff --git a/chrome/browser/autocomplete/autocomplete_popup_view_mac.mm b/chrome/browser/autocomplete/autocomplete_popup_view_mac.mm
index 6c6d173..e09da8c 100644
--- a/chrome/browser/autocomplete/autocomplete_popup_view_mac.mm
+++ b/chrome/browser/autocomplete/autocomplete_popup_view_mac.mm
@@ -79,14 +79,6 @@ static const NSColor* DescriptionTextColor() {
return [NSColor darkGrayColor];
}
-// Helper to fetch and retain an image from the resource bundle.
-NSImage* RetainedResourceImage(int resource_id) {
- ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- NSImage* image = rb.GetNSImageNamed(resource_id);
- DCHECK(image);
- return [image retain];
-}
-
} // namespace
// Helper for MatchText() to allow sharing code between the contents
@@ -347,8 +339,9 @@ void AutocompletePopupViewMac::UpdatePopupAppearance() {
for (size_t ii = 0; ii < rows; ++ii) {
AutocompleteButtonCell* cell = [matrix cellAtRow:ii column:0];
const AutocompleteMatch& match = model_->result().match_at(ii);
- [cell setImage:RetainedResourceImage(match.starred ?
- IDR_OMNIBOX_STAR : AutocompleteMatch::TypeToIcon(match.type))];
+ const int resource_id = match.starred ? IDR_OMNIBOX_STAR
+ : AutocompleteMatch::TypeToIcon(match.type);
+ [cell setImage:AutocompleteEditViewMac::ImageForResource(resource_id)];
[cell setAttributedTitle:MatchText(match, resultFont, r.size.width)];
}
@@ -469,7 +462,11 @@ void AutocompletePopupViewMac::OpenURLForRow(int row, bool force_background) {
imageRect.origin.y +=
floor((NSHeight(cellFrame) - NSHeight(imageRect)) / 2);
imageRect.origin.x += kLeftRightMargin;
- [self drawImage:image withFrame:imageRect inView:controlView];
+ [image setFlipped:[controlView isFlipped]];
+ [image drawInRect:imageRect
+ fromRect:NSZeroRect // Entire image
+ operation:NSCompositeSourceOver
+ fraction:1.0];
}
// Adjust the title position to be lined up under the field's text.
diff --git a/chrome/browser/cocoa/autocomplete_text_field_cell.mm b/chrome/browser/cocoa/autocomplete_text_field_cell.mm
index ae86541..ab9f7c8 100644
--- a/chrome/browser/cocoa/autocomplete_text_field_cell.mm
+++ b/chrome/browser/cocoa/autocomplete_text_field_cell.mm
@@ -183,8 +183,8 @@ NSAttributedString* AttributedStringForImage(NSImage* anImage,
width -= 2 * kEditorHorizontalInset;
// Get the magnifying glass to put at the front of the string.
- ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- NSImage* image = rb.GetNSImageNamed(IDR_OMNIBOX_SEARCH);
+ NSImage* image =
+ AutocompleteEditViewMac::ImageForResource(IDR_OMNIBOX_SEARCH);
const NSSize imageSize = [image size];
// Based on what fits, choose |fullString| with the image,
diff --git a/chrome/browser/cocoa/location_bar_view_mac.mm b/chrome/browser/cocoa/location_bar_view_mac.mm
index 721fc7a..37a55c2 100644
--- a/chrome/browser/cocoa/location_bar_view_mac.mm
+++ b/chrome/browser/cocoa/location_bar_view_mac.mm
@@ -488,7 +488,8 @@ void LocationBarViewMac::SetIcon(int resource_id) {
!edit_view_->model()->is_keyword_hint()) {
location_icon_view_.SetVisible(false);
} else {
- location_icon_view_.SetIcon(resource_id);
+ NSImage* image = AutocompleteEditViewMac::ImageForResource(resource_id);
+ location_icon_view_.SetImage(image);
location_icon_view_.SetVisible(true);
SetSecurityLabel();
}
@@ -658,11 +659,11 @@ LocationBarViewMac::StarIconView::StarIconView(CommandUpdater* command_updater)
void LocationBarViewMac::StarIconView::SetStarred(bool starred) {
if (starred) {
- SetIcon(IDR_OMNIBOX_STAR_LIT);
+ SetImage(AutocompleteEditViewMac::ImageForResource(IDR_OMNIBOX_STAR_LIT));
tooltip_.reset(
[l10n_util::GetNSStringWithFixup(IDS_TOOLTIP_STARRED) retain]);
} else {
- SetIcon(IDR_OMNIBOX_STAR);
+ SetImage(AutocompleteEditViewMac::ImageForResource(IDR_OMNIBOX_STAR));
tooltip_.reset(
[l10n_util::GetNSStringWithFixup(IDS_TOOLTIP_STAR) retain]);
}