summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-10 20:11:23 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-10 20:11:23 +0000
commit4692966bece55451e05a794ae064f3a3d16e2aa2 (patch)
tree090eb686373349d10b1c6f82c492c59845bfb7f9
parent10b5d641e5b1149e5383aafdecd6447adce56031 (diff)
downloadchromium_src-4692966bece55451e05a794ae064f3a3d16e2aa2.zip
chromium_src-4692966bece55451e05a794ae064f3a3d16e2aa2.tar.gz
chromium_src-4692966bece55451e05a794ae064f3a3d16e2aa2.tar.bz2
Use system default favicon in tab strip when using GTK theme.
Review URL: http://codereview.chromium.org/164266 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22947 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--app/gfx/canvas.h4
-rw-r--r--app/gfx/canvas_linux.cc6
-rw-r--r--chrome/browser/gtk/tabs/tab_renderer_gtk.cc41
-rw-r--r--chrome/browser/gtk/tabs/tab_renderer_gtk.h4
4 files changed, 42 insertions, 13 deletions
diff --git a/app/gfx/canvas.h b/app/gfx/canvas.h
index 4b5f575..4cb8695 100644
--- a/app/gfx/canvas.h
+++ b/app/gfx/canvas.h
@@ -16,6 +16,7 @@
#if defined(OS_LINUX)
typedef struct _cairo cairo_t;
+typedef struct _GdkPixbuf GdkPixbuf;
#endif
namespace gfx {
@@ -186,6 +187,9 @@ class Canvas : public skia::PlatformCanvas {
// invoked anytime you plan on drawing directly to the cairo context. Be
// sure and set the matrix back to the identity when done.
void ApplySkiaMatrixToCairoContext(cairo_t* cr);
+
+ // Draw the pixbuf in its natural size at (x, y).
+ void DrawGdkPixbuf(GdkPixbuf* pixbuf, int x, int y);
#endif
// Compute the size required to draw some text with the provided font.
diff --git a/app/gfx/canvas_linux.cc b/app/gfx/canvas_linux.cc
index 155221c..c42df59 100644
--- a/app/gfx/canvas_linux.cc
+++ b/app/gfx/canvas_linux.cc
@@ -234,4 +234,10 @@ void Canvas::DrawStringInt(const std::wstring& text,
// NOTE: beginPlatformPaint returned its surface, we shouldn't destroy it.
}
+void Canvas::DrawGdkPixbuf(GdkPixbuf* pixbuf, int x, int y) {
+ cairo_t* cr = beginPlatformPaint();
+ gdk_cairo_set_source_pixbuf(cr, pixbuf, x, y);
+ cairo_paint(cr);
+}
+
} // namespace gfx
diff --git a/chrome/browser/gtk/tabs/tab_renderer_gtk.cc b/chrome/browser/gtk/tabs/tab_renderer_gtk.cc
index f0c228f..3110b8d 100644
--- a/chrome/browser/gtk/tabs/tab_renderer_gtk.cc
+++ b/chrome/browser/gtk/tabs/tab_renderer_gtk.cc
@@ -11,8 +11,9 @@
#include "app/l10n_util.h"
#include "app/resource_bundle.h"
#include "chrome/browser/browser.h"
-#include "chrome/browser/browser_theme_provider.h"
+#include "chrome/browser/gtk/bookmark_utils_gtk.h"
#include "chrome/browser/gtk/custom_button.h"
+#include "chrome/browser/gtk/gtk_theme_provider.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/common/gtk_util.h"
@@ -253,19 +254,29 @@ TabRendererGtk::~TabRendererGtk() {
void TabRendererGtk::UpdateData(TabContents* contents, bool loading_only) {
DCHECK(contents);
+
+ theme_provider_ = GtkThemeProvider::GetFrom(contents->profile());
+
if (!loading_only) {
data_.title = contents->GetTitle();
data_.off_the_record = contents->profile()->IsOffTheRecord();
data_.crashed = contents->is_crashed();
data_.favicon = contents->GetFavIcon();
+ // This is kind of a hacky way to determine whether our icon is the default
+ // favicon. But the plumbing that would be necessary to do it right would
+ // be a good bit of work and would sully code for other platforms which
+ // don't care to custom-theme the favicon. Hopefully the default favicon
+ // will eventually be chromium-themable and this code will go away.
+ data_.is_default_favicon =
+ (data_.favicon.pixelRef() ==
+ ResourceBundle::GetSharedInstance().GetBitmapNamed(
+ IDR_DEFAULT_FAVICON)->pixelRef());
}
// Loading state also involves whether we show the favicon, since that's where
// we display the throbber.
data_.loading = contents->is_loading();
data_.show_icon = contents->ShouldDisplayFavIcon();
-
- theme_provider_ = contents->profile()->GetThemeProvider();
}
void TabRendererGtk::UpdateFromModel() {
@@ -644,15 +655,21 @@ void TabRendererGtk::PaintIcon(gfx::Canvas* canvas) {
true);
} else {
if (!data_.favicon.isNull()) {
- // TODO(pkasting): Use code in tab_icon_view.cc:PaintIcon() (or switch
- // to using that class to render the favicon).
- canvas->DrawBitmapInt(data_.favicon, 0, 0,
- data_.favicon.width(),
- data_.favicon.height(),
- favicon_bounds_.x(),
- favicon_bounds_.y() + fav_icon_hiding_offset_,
- kFavIconSize, kFavIconSize,
- true);
+ if (data_.is_default_favicon && theme_provider_->UseGtkTheme()) {
+ GdkPixbuf* favicon = bookmark_utils::GetDefaultFavicon(true);
+ canvas->DrawGdkPixbuf(favicon, favicon_bounds_.x(),
+ favicon_bounds_.y() + fav_icon_hiding_offset_);
+ } else {
+ // TODO(pkasting): Use code in tab_icon_view.cc:PaintIcon() (or switch
+ // to using that class to render the favicon).
+ canvas->DrawBitmapInt(data_.favicon, 0, 0,
+ data_.favicon.width(),
+ data_.favicon.height(),
+ favicon_bounds_.x(),
+ favicon_bounds_.y() + fav_icon_hiding_offset_,
+ kFavIconSize, kFavIconSize,
+ true);
+ }
}
}
canvas->restore();
diff --git a/chrome/browser/gtk/tabs/tab_renderer_gtk.h b/chrome/browser/gtk/tabs/tab_renderer_gtk.h
index ba141f1..c9a19d8 100644
--- a/chrome/browser/gtk/tabs/tab_renderer_gtk.h
+++ b/chrome/browser/gtk/tabs/tab_renderer_gtk.h
@@ -24,6 +24,7 @@ class Size;
} // namespace gfx
class CustomDrawButton;
+class GtkThemeProvider;
class TabContents;
class ThemeProvider;
@@ -194,6 +195,7 @@ class TabRendererGtk : public AnimationDelegate {
// corresponding objects in the underlying model.
struct TabData {
SkBitmap favicon;
+ bool is_default_favicon;
string16 title;
bool loading;
bool crashed;
@@ -342,7 +344,7 @@ class TabRendererGtk : public AnimationDelegate {
// The offset used to paint the tab theme images.
int background_offset_x_;
- ThemeProvider* theme_provider_;
+ GtkThemeProvider* theme_provider_;
// The close button.
scoped_ptr<CustomDrawButton> close_button_;