Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Side by Side Diff: chrome/browser/ui/gtk/browser_titlebar.cc

Issue 10834368: Convert mostly favicon related code from SkBitmap to ImageSkia and Image (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/gtk/browser_titlebar.h" 5 #include "chrome/browser/ui/gtk/browser_titlebar.h"
6 6
7 #include <gdk/gdkkeysyms.h> 7 #include <gdk/gdkkeysyms.h>
8 #include <gtk/gtk.h> 8 #include <gtk/gtk.h>
9 9
10 #include <string> 10 #include <string>
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 string16 title = browser_window_->browser()->GetWindowTitleForCurrentTab(); 594 string16 title = browser_window_->browser()->GetWindowTitleForCurrentTab();
595 gtk_label_set_text(GTK_LABEL(app_mode_title_), UTF16ToUTF8(title).c_str()); 595 gtk_label_set_text(GTK_LABEL(app_mode_title_), UTF16ToUTF8(title).c_str());
596 596
597 if (browser_window_->browser()->is_app()) { 597 if (browser_window_->browser()->is_app()) {
598 switch (browser_window_->browser()->type()) { 598 switch (browser_window_->browser()->type()) {
599 case Browser::TYPE_POPUP: { 599 case Browser::TYPE_POPUP: {
600 // Update the system app icon. We don't need to update the icon in the 600 // Update the system app icon. We don't need to update the icon in the
601 // top left of the custom frame, that will get updated when the 601 // top left of the custom frame, that will get updated when the
602 // throbber is updated. 602 // throbber is updated.
603 Profile* profile = browser_window_->browser()->profile(); 603 Profile* profile = browser_window_->browser()->profile();
604 SkBitmap icon = browser_window_->browser()->GetCurrentPageIcon(); 604 gfx::Image icon = browser_window_->browser()->GetCurrentPageIcon();
605 if (icon.empty()) { 605 if (icon.IsEmpty()) {
606 gtk_util::SetWindowIcon(window_, profile); 606 gtk_util::SetWindowIcon(window_, profile);
607 } else { 607 } else {
608 GdkPixbuf* icon_pixbuf = gfx::GdkPixbufFromSkBitmap(icon); 608 GdkPixbuf* icon_pixbuf = icon.ToGdkPixbuf();
609 gtk_util::SetWindowIcon(window_, profile, icon_pixbuf); 609 gtk_util::SetWindowIcon(window_, profile, icon_pixbuf);
610 g_object_unref(icon_pixbuf); 610 g_object_unref(icon_pixbuf);
Nico 2012/08/16 20:26:27 ToGdkPixbuf() returns an unref'd icon, so you need
611 } 611 }
612 break; 612 break;
613 } 613 }
614 case Browser::TYPE_TABBED: { 614 case Browser::TYPE_TABBED: {
615 NOTREACHED() << "We should never have a tabbed app window."; 615 NOTREACHED() << "We should never have a tabbed app window.";
616 break; 616 break;
617 } 617 }
618 case Browser::TYPE_PANEL: { 618 case Browser::TYPE_PANEL: {
619 NOTREACHED(); 619 NOTREACHED();
620 break; 620 break;
621 } 621 }
622 } 622 }
623 } 623 }
624 } 624 }
625 625
626 void BrowserTitlebar::UpdateThrobber(WebContents* web_contents) { 626 void BrowserTitlebar::UpdateThrobber(WebContents* web_contents) {
627 DCHECK(app_mode_favicon_); 627 DCHECK(app_mode_favicon_);
628 628
629 if (web_contents && web_contents->IsLoading()) { 629 if (web_contents && web_contents->IsLoading()) {
630 GdkPixbuf* icon_pixbuf = 630 GdkPixbuf* icon_pixbuf =
631 throbber_.GetNextFrame(web_contents->IsWaitingForResponse()); 631 throbber_.GetNextFrame(web_contents->IsWaitingForResponse());
632 gtk_image_set_from_pixbuf(GTK_IMAGE(app_mode_favicon_), icon_pixbuf); 632 gtk_image_set_from_pixbuf(GTK_IMAGE(app_mode_favicon_), icon_pixbuf);
633 } else { 633 } else {
634 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 634 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
635 635
636 // Note: we want to exclude the application popup/panel window. 636 // Note: we want to exclude the application popup/panel window.
637 if ((browser_window_->browser()->is_app() && 637 if ((browser_window_->browser()->is_app() &&
638 !browser_window_->browser()->is_type_tabbed())) { 638 !browser_window_->browser()->is_type_tabbed())) {
639 SkBitmap icon = browser_window_->browser()->GetCurrentPageIcon(); 639 gfx::Image icon = browser_window_->browser()->GetCurrentPageIcon();
640 if (icon.empty()) { 640 if (icon.IsEmpty()) {
641 // Fallback to the Chromium icon if the page has no icon. 641 // Fallback to the Chromium icon if the page has no icon.
642 gtk_image_set_from_pixbuf(GTK_IMAGE(app_mode_favicon_), 642 gtk_image_set_from_pixbuf(GTK_IMAGE(app_mode_favicon_),
643 rb.GetNativeImageNamed(IDR_PRODUCT_LOGO_16).ToGdkPixbuf()); 643 rb.GetNativeImageNamed(IDR_PRODUCT_LOGO_16).ToGdkPixbuf());
644 } else { 644 } else {
645 GdkPixbuf* icon_pixbuf = gfx::GdkPixbufFromSkBitmap(icon); 645 GdkPixbuf* icon_pixbuf = icon.ToGdkPixbuf();
646 gtk_image_set_from_pixbuf(GTK_IMAGE(app_mode_favicon_), icon_pixbuf); 646 gtk_image_set_from_pixbuf(GTK_IMAGE(app_mode_favicon_), icon_pixbuf);
647 g_object_unref(icon_pixbuf); 647 g_object_unref(icon_pixbuf);
Nico 2012/08/16 20:26:27 ditto
648 } 648 }
649 } else { 649 } else {
650 gtk_image_set_from_pixbuf(GTK_IMAGE(app_mode_favicon_), 650 gtk_image_set_from_pixbuf(GTK_IMAGE(app_mode_favicon_),
651 rb.GetNativeImageNamed(IDR_PRODUCT_LOGO_16).ToGdkPixbuf()); 651 rb.GetNativeImageNamed(IDR_PRODUCT_LOGO_16).ToGdkPixbuf());
652 } 652 }
653 throbber_.Reset(); 653 throbber_.Reset();
654 } 654 }
655 } 655 }
656 656
657 void BrowserTitlebar::UpdateTitlebarAlignment() { 657 void BrowserTitlebar::UpdateTitlebarAlignment() {
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
1051 ui::SimpleMenuModel::Delegate* delegate) 1051 ui::SimpleMenuModel::Delegate* delegate)
1052 : SimpleMenuModel(delegate) { 1052 : SimpleMenuModel(delegate) {
1053 AddItemWithStringId(IDC_NEW_TAB, IDS_TAB_CXMENU_NEWTAB); 1053 AddItemWithStringId(IDC_NEW_TAB, IDS_TAB_CXMENU_NEWTAB);
1054 AddItemWithStringId(IDC_RESTORE_TAB, IDS_RESTORE_TAB); 1054 AddItemWithStringId(IDC_RESTORE_TAB, IDS_RESTORE_TAB);
1055 AddSeparator(); 1055 AddSeparator();
1056 AddItemWithStringId(IDC_TASK_MANAGER, IDS_TASK_MANAGER); 1056 AddItemWithStringId(IDC_TASK_MANAGER, IDS_TASK_MANAGER);
1057 AddSeparator(); 1057 AddSeparator();
1058 AddCheckItemWithStringId(kShowWindowDecorationsCommand, 1058 AddCheckItemWithStringId(kShowWindowDecorationsCommand,
1059 IDS_SHOW_WINDOW_DECORATIONS_MENU); 1059 IDS_SHOW_WINDOW_DECORATIONS_MENU);
1060 } 1060 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698