diff options
author | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-14 15:52:27 +0000 |
---|---|---|
committer | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-14 15:52:27 +0000 |
commit | c9e2a17bc8e0362a89fa0ceb50228eb29396c009 (patch) | |
tree | 94975f121b3376f486aa70d364cf2e8f6bac0264 /chrome | |
parent | 530cd6292136de5798bfd05c4ae960cba8e8b84b (diff) | |
download | chromium_src-c9e2a17bc8e0362a89fa0ceb50228eb29396c009.zip chromium_src-c9e2a17bc8e0362a89fa0ceb50228eb29396c009.tar.gz chromium_src-c9e2a17bc8e0362a89fa0ceb50228eb29396c009.tar.bz2 |
[Mac] Replace instances of IDR_DEFAULT_FAVICON with nav.pdf.
The PNG is a rasterized version of the PDF, so the colors are slightly
different. Some parts of the UI use the PDF and others use the PNG. This CL
reconciles that usage to always use the PDF for a consistent look.
BUG=27626
TEST=visual
Review URL: http://codereview.chromium.org/6812027
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81594 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
9 files changed, 74 insertions, 37 deletions
diff --git a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.mm b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.mm index 96a9c2b..b235502 100644 --- a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.mm +++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.mm @@ -4,6 +4,7 @@ #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" +#include "app/mac/nsimage_cache.h" #include "base/mac/mac_util.h" #include "base/metrics/histogram.h" #include "base/sys_string_conversions.h" @@ -242,7 +243,7 @@ void RecordAppLaunch(Profile* profile, GURL url) { ResourceBundle& rb = ResourceBundle::GetSharedInstance(); folderImage_.reset( [rb.GetNativeImageNamed(IDR_BOOKMARK_BAR_FOLDER) retain]); - defaultImage_.reset([rb.GetNativeImageNamed(IDR_DEFAULT_FAVICON) retain]); + defaultImage_.reset([app::mac::GetCachedImageWithName(@"nav.pdf") retain]); // Register for theme changes, bookmark button pulsing, ... NSNotificationCenter* defaultCenter = [NSNotificationCenter defaultCenter]; 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 e51478c..322036e 100644 --- a/chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell_unittest.mm +++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell_unittest.mm @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "app/mac/nsimage_cache.h" #include "base/memory/scoped_nsobject.h" #include "base/utf_string_conversions.h" #include "chrome/browser/bookmarks/bookmark_model.h" @@ -9,10 +10,8 @@ #import "chrome/browser/ui/cocoa/bookmarks/bookmark_menu.h" #include "chrome/browser/ui/cocoa/browser_test_helper.h" #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" -#include "grit/app_resources.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/platform_test.h" -#include "ui/base/resource/resource_bundle.h" #include "ui/gfx/image.h" // Simple class to remember how many mouseEntered: and mouseExited: @@ -66,9 +65,8 @@ TEST_F(BookmarkButtonCellTest, IconOnlySqueeze) { [view setCell:cell.get()]; [[test_window() contentView] addSubview:view]; - ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - scoped_nsobject<NSImage> image([rb.GetNativeImageNamed(IDR_DEFAULT_FAVICON) - retain]); + scoped_nsobject<NSImage> image( + [app::mac::GetCachedImageWithName(@"nav.pdf") retain]); EXPECT_TRUE(image.get()); NSRect r = NSMakeRect(0, 0, 100, 100); diff --git a/chrome/browser/ui/cocoa/history_menu_bridge.mm b/chrome/browser/ui/cocoa/history_menu_bridge.mm index c1ff61f..ef5be5f 100644 --- a/chrome/browser/ui/cocoa/history_menu_bridge.mm +++ b/chrome/browser/ui/cocoa/history_menu_bridge.mm @@ -4,6 +4,7 @@ #include "chrome/browser/ui/cocoa/history_menu_bridge.h" +#include "app/mac/nsimage_cache.h" #include "base/callback.h" #include "base/stl_util-inl.h" #include "base/string_number_conversions.h" @@ -91,7 +92,7 @@ HistoryMenuBridge::HistoryMenuBridge(Profile* profile) } ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - default_favicon_.reset([rb.GetNativeImageNamed(IDR_DEFAULT_FAVICON) retain]); + default_favicon_.reset([app::mac::GetCachedImageWithName(@"nav.pdf") retain]); // Set the static icons in the menu. NSMenuItem* item = [HistoryMenu() itemWithTag:IDC_SHOW_HISTORY]; diff --git a/chrome/browser/ui/cocoa/hung_renderer_controller.mm b/chrome/browser/ui/cocoa/hung_renderer_controller.mm index c217e70..0d4b341 100644 --- a/chrome/browser/ui/cocoa/hung_renderer_controller.mm +++ b/chrome/browser/ui/cocoa/hung_renderer_controller.mm @@ -6,6 +6,7 @@ #import <Cocoa/Cocoa.h> +#include "app/mac/nsimage_cache.h" #include "base/mac/mac_util.h" #include "base/process_util.h" #include "base/sys_string_conversions.h" @@ -18,6 +19,7 @@ #include "content/browser/renderer_host/render_process_host.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/tab_contents/tab_contents.h" +#import "chrome/browser/ui/cocoa/tab_contents/favicon_util.h" #include "content/common/result_codes.h" #include "grit/app_resources.h" #include "grit/chromium_strings.h" @@ -145,16 +147,7 @@ HungRendererController* g_instance = NULL; if (title.empty()) title = TabContentsWrapper::GetDefaultTitle(); [titles addObject:base::SysUTF16ToNSString(title)]; - - // TabContents can return a null SkBitmap if it has no favicon. If this - // happens, use the default favicon. - const SkBitmap& bitmap = it->tab_contents()->GetFavicon(); - if (!bitmap.isNull()) { - [favicons addObject:gfx::SkBitmapToNSImage(bitmap)]; - } else { - ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - [favicons addObject:rb.GetNativeImageNamed(IDR_DEFAULT_FAVICON)]; - } + [favicons addObject:mac::FaviconForTabContents(it->tab_contents())]; } } hungTitles_.reset([titles copy]); diff --git a/chrome/browser/ui/cocoa/tab_contents/favicon_util.h b/chrome/browser/ui/cocoa/tab_contents/favicon_util.h new file mode 100644 index 0000000..051ef8c --- /dev/null +++ b/chrome/browser/ui/cocoa/tab_contents/favicon_util.h @@ -0,0 +1,20 @@ +// 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. + +#ifndef CHROME_BROWSER_UI_COCOA_TAB_CONTENTS_FAVICON_UTIL_H_ +#define CHROME_BROWSER_UI_COCOA_TAB_CONTENTS_FAVICON_UTIL_H_ + +@class NSImage; +class TabContents; + +namespace mac { + +// Returns an autoreleased favicon for a given TabContents. If |contents| is +// NULL or there's no favicon for the NavigationEntry, this will return the +// default image. +NSImage* FaviconForTabContents(TabContents* contents); + +} // namespace mac + +#endif // CHROME_BROWSER_UI_COCOA_TAB_CONTENTS_FAVICON_UTIL_H_ diff --git a/chrome/browser/ui/cocoa/tab_contents/favicon_util.mm b/chrome/browser/ui/cocoa/tab_contents/favicon_util.mm new file mode 100644 index 0000000..390b8f9 --- /dev/null +++ b/chrome/browser/ui/cocoa/tab_contents/favicon_util.mm @@ -0,0 +1,29 @@ +// 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 "chrome/browser/ui/cocoa/tab_contents/favicon_util.h" + +#import <AppKit/AppKit.h> + +#include "app/mac/nsimage_cache.h" +#include "base/mac/mac_util.h" +#include "content/browser/tab_contents/tab_contents.h" +#include "skia/ext/skia_utils_mac.h" + +namespace mac { + +NSImage* FaviconForTabContents(TabContents* contents) { + // TabContents returns IDR_DEFAULT_FAVICON, which is a rasterized version of + // the Mac PDF. Use the PDF so the icon in the Omnibox matches the default + // favicon. + if (contents && contents->FaviconIsValid()) { + CGColorSpaceRef color_space = base::mac::GetSystemColorSpace(); + return gfx::SkBitmapToNSImageWithColorSpace(contents->GetFavicon(), + color_space); + } + + return app::mac::GetCachedImageWithName(@"nav.pdf"); +} + +} // namespace mac diff --git a/chrome/browser/ui/cocoa/tabpose_window.mm b/chrome/browser/ui/cocoa/tabpose_window.mm index 2626f72..d821c76 100644 --- a/chrome/browser/ui/cocoa/tabpose_window.mm +++ b/chrome/browser/ui/cocoa/tabpose_window.mm @@ -8,6 +8,7 @@ #include <algorithm> +#include "app/mac/nsimage_cache.h" #include "base/mac/mac_util.h" #include "base/mac/scoped_cftyperef.h" #include "base/memory/scoped_callback_factory.h" @@ -23,6 +24,7 @@ #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_constants.h" #import "chrome/browser/ui/cocoa/browser_window_controller.h" #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" +#import "chrome/browser/ui/cocoa/tab_contents/favicon_util.h" #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" #import "chrome/browser/ui/cocoa/tabs/tab_strip_model_observer_bridge.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" @@ -436,7 +438,7 @@ class Tile { NSRect GetFaviconStartRectRelativeTo(const Tile& tile) const; NSRect favicon_rect() const { return NSIntegralRect(favicon_rect_); } - SkBitmap favicon() const; + NSImage* favicon() const; // This changes |title_rect| and |favicon_rect| such that the favicon is on // the font's baseline and that the minimum distance between thumb rect and @@ -497,13 +499,13 @@ NSRect Tile::GetFaviconStartRectRelativeTo(const Tile& tile) const { return rect; } -SkBitmap Tile::favicon() const { +NSImage* Tile::favicon() const { if (contents_->extension_tab_helper()->is_app()) { - SkBitmap* icon = contents_->extension_tab_helper()->GetExtensionAppIcon(); - if (icon) - return *icon; + SkBitmap* bitmap = contents_->extension_tab_helper()->GetExtensionAppIcon(); + if (bitmap) + return gfx::SkBitmapToNSImage(*bitmap); } - return contents_->tab_contents()->GetFavicon(); + return mac::FaviconForTabContents(contents_->tab_contents()); } NSRect Tile::GetTitleStartRectRelativeTo(const Tile& tile) const { @@ -1076,17 +1078,8 @@ void AnimateCALayerOpacityFromTo( NSFont* font = [NSFont systemFontOfSize:tile.title_font_size()]; tile.set_font_metrics([font ascender], -[font descender]); - NSImage* nsFavicon = gfx::SkBitmapToNSImage(tile.favicon()); - // Either we don't have a valid favicon or there was some issue converting - // it from an SkBitmap. Either way, just show the default. - if (!nsFavicon) { - NSImage* defaultFavicon = - ResourceBundle::GetSharedInstance().GetNativeImageNamed( - IDR_DEFAULT_FAVICON); - nsFavicon = defaultFavicon; - } base::mac::ScopedCFTypeRef<CGImageRef> favicon( - base::mac::CopyNSImageToCGImage(nsFavicon)); + base::mac::CopyNSImageToCGImage(tile.favicon())); CALayer* faviconLayer = [CALayer layer]; if (showZoom) { diff --git a/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm b/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm index d9cb69b..93e3a13 100644 --- a/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm +++ b/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm @@ -33,6 +33,7 @@ #import "chrome/browser/ui/cocoa/constrained_window_mac.h" #import "chrome/browser/ui/cocoa/new_tab_button.h" #import "chrome/browser/ui/cocoa/profile_menu_button.h" +#import "chrome/browser/ui/cocoa/tab_contents/favicon_util.h" #import "chrome/browser/ui/cocoa/tabs/tab_controller.h" #import "chrome/browser/ui/cocoa/tabs/tab_strip_model_observer_bridge.h" #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h" @@ -366,8 +367,8 @@ class NotificationBridge : public NotificationObserver { // (see |-addSubviewToPermanentList:|) will be wiped out. permanentSubviews_.reset([[NSMutableArray alloc] init]); - ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - defaultFavicon_.reset([rb.GetNativeImageNamed(IDR_DEFAULT_FAVICON) retain]); + defaultFavicon_.reset( + [app::mac::GetCachedImageWithName(@"nav.pdf") retain]); [self setIndentForControls:[[self class] defaultIndentForControls]]; @@ -1355,8 +1356,7 @@ class NotificationBridge : public NotificationObserver { if (icon) image = gfx::SkBitmapToNSImageWithColorSpace(*icon, colorSpace); } else { - image = gfx::SkBitmapToNSImageWithColorSpace(contents->GetFavicon(), - colorSpace); + image = mac::FaviconForTabContents(contents); } // Either we don't have a valid favicon or there was some issue converting it diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 45c3502..7d12ee5 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -2420,6 +2420,8 @@ 'browser/ui/cocoa/styled_text_field.mm', 'browser/ui/cocoa/styled_text_field_cell.h', 'browser/ui/cocoa/styled_text_field_cell.mm', + 'browser/ui/cocoa/tab_contents/favicon_util.h', + 'browser/ui/cocoa/tab_contents/favicon_util.mm', 'browser/ui/cocoa/tab_contents/previewable_contents_controller.h', 'browser/ui/cocoa/tab_contents/previewable_contents_controller.mm', 'browser/ui/cocoa/tab_contents/sad_tab_controller.h', |