Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/panels/panel_browser_titlebar_gtk.h" | 5 #include "chrome/browser/ui/panels/panel_browser_titlebar_gtk.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
| 9 #include "chrome/browser/ui/gtk/custom_button.h" | 9 #include "chrome/browser/ui/gtk/custom_button.h" |
| 10 #include "chrome/browser/ui/gtk/gtk_theme_service.h" | 10 #include "chrome/browser/ui/gtk/gtk_theme_service.h" |
| 11 #include "chrome/browser/ui/gtk/gtk_util.h" | 11 #include "chrome/browser/ui/gtk/gtk_util.h" |
| 12 #include "chrome/browser/ui/gtk/gtk_theme_service.h" | 12 #include "chrome/browser/ui/gtk/gtk_theme_service.h" |
| 13 #include "chrome/browser/ui/panels/panel.h" | 13 #include "chrome/browser/ui/panels/panel.h" |
| 14 #include "chrome/browser/ui/panels/panel_browser_window_gtk.h" | 14 #include "chrome/browser/ui/panels/panel_browser_window_gtk.h" |
| 15 #include "chrome/common/chrome_notification_types.h" | 15 #include "chrome/common/chrome_notification_types.h" |
| 16 #include "content/public/browser/notification_service.h" | 16 #include "content/public/browser/notification_service.h" |
| 17 #include "content/public/browser/web_contents.h" | 17 #include "content/public/browser/web_contents.h" |
| 18 #include "grit/generated_resources.h" | 18 #include "grit/generated_resources.h" |
| 19 #include "grit/theme_resources.h" | 19 #include "grit/theme_resources.h" |
| 20 #include "third_party/skia/include/core/SkBitmap.h" | |
| 21 #include "ui/base/gtk/gtk_compat.h" | 20 #include "ui/base/gtk/gtk_compat.h" |
| 22 #include "ui/base/l10n/l10n_util.h" | 21 #include "ui/base/l10n/l10n_util.h" |
| 23 #include "ui/base/resource/resource_bundle.h" | 22 #include "ui/base/resource/resource_bundle.h" |
| 23 #include "ui/gfx/image/image.h" | |
| 24 #include "ui/gfx/skia_utils_gtk.h" | 24 #include "ui/gfx/skia_utils_gtk.h" |
| 25 | 25 |
| 26 namespace { | 26 namespace { |
| 27 | 27 |
| 28 // Padding around the titlebar. | 28 // Padding around the titlebar. |
| 29 const int kPanelTitlebarPaddingTop = 7; | 29 const int kPanelTitlebarPaddingTop = 7; |
| 30 const int kPanelTitlebarPaddingBottom = 7; | 30 const int kPanelTitlebarPaddingBottom = 7; |
| 31 const int kPanelTitlebarPaddingLeft = 4; | 31 const int kPanelTitlebarPaddingLeft = 4; |
| 32 const int kPanelTitlebarPaddingRight = 8; | 32 const int kPanelTitlebarPaddingRight = 8; |
| 33 | 33 |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 228 | 228 |
| 229 void PanelBrowserTitlebarGtk::UpdateThrobber( | 229 void PanelBrowserTitlebarGtk::UpdateThrobber( |
| 230 content::WebContents* web_contents) { | 230 content::WebContents* web_contents) { |
| 231 if (web_contents && web_contents->IsLoading()) { | 231 if (web_contents && web_contents->IsLoading()) { |
| 232 GdkPixbuf* icon_pixbuf = | 232 GdkPixbuf* icon_pixbuf = |
| 233 throbber_.GetNextFrame(web_contents->IsWaitingForResponse()); | 233 throbber_.GetNextFrame(web_contents->IsWaitingForResponse()); |
| 234 gtk_image_set_from_pixbuf(GTK_IMAGE(icon_), icon_pixbuf); | 234 gtk_image_set_from_pixbuf(GTK_IMAGE(icon_), icon_pixbuf); |
| 235 } else { | 235 } else { |
| 236 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 236 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 237 | 237 |
| 238 SkBitmap icon = browser_window_->panel()->GetCurrentPageIcon(); | 238 gfx::Image icon = browser_window_->panel()->GetCurrentPageIcon(); |
| 239 if (icon.empty()) { | 239 if (icon.IsEmpty()) { |
| 240 // Fallback to the Chromium icon if the page has no icon. | 240 // Fallback to the Chromium icon if the page has no icon. |
| 241 gtk_image_set_from_pixbuf(GTK_IMAGE(icon_), | 241 gtk_image_set_from_pixbuf(GTK_IMAGE(icon_), |
| 242 rb.GetNativeImageNamed(IDR_PRODUCT_LOGO_16).ToGdkPixbuf()); | 242 rb.GetNativeImageNamed(IDR_PRODUCT_LOGO_16).ToGdkPixbuf()); |
| 243 } else { | 243 } else { |
| 244 GdkPixbuf* icon_pixbuf = gfx::GdkPixbufFromSkBitmap(icon); | 244 GdkPixbuf* icon_pixbuf = icon.ToGdkPixbuf(); |
| 245 gtk_image_set_from_pixbuf(GTK_IMAGE(icon_), icon_pixbuf); | 245 gtk_image_set_from_pixbuf(GTK_IMAGE(icon_), icon_pixbuf); |
| 246 g_object_unref(icon_pixbuf); | 246 g_object_unref(icon_pixbuf); |
|
Robert Sesek
2012/08/10 19:37:29
The ToX functions return a weak reference, so this
jennb
2012/08/11 04:20:05
Thanks for pointing this out. Maybe this explains
| |
| 247 } | 247 } |
| 248 | 248 |
| 249 throbber_.Reset(); | 249 throbber_.Reset(); |
| 250 } | 250 } |
| 251 } | 251 } |
| 252 | 252 |
| 253 void PanelBrowserTitlebarGtk::ShowContextMenu(GdkEventButton* event) { | 253 void PanelBrowserTitlebarGtk::ShowContextMenu(GdkEventButton* event) { |
| 254 // Panel does not show any context menu. | 254 // Panel does not show any context menu. |
| 255 } | 255 } |
| 256 | 256 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 352 } | 352 } |
| 353 | 353 |
| 354 void PanelBrowserTitlebarGtk::set_window(GtkWindow* window) { | 354 void PanelBrowserTitlebarGtk::set_window(GtkWindow* window) { |
| 355 window_ = window; | 355 window_ = window; |
| 356 } | 356 } |
| 357 | 357 |
| 358 AvatarMenuButtonGtk* PanelBrowserTitlebarGtk::avatar_button() const { | 358 AvatarMenuButtonGtk* PanelBrowserTitlebarGtk::avatar_button() const { |
| 359 // Not supported in panel. | 359 // Not supported in panel. |
| 360 return NULL; | 360 return NULL; |
| 361 } | 361 } |
| OLD | NEW |