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

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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 #include "chrome/common/pref_names.h" 47 #include "chrome/common/pref_names.h"
48 #include "content/public/browser/notification_service.h" 48 #include "content/public/browser/notification_service.h"
49 #include "content/public/browser/web_contents.h" 49 #include "content/public/browser/web_contents.h"
50 #include "grit/generated_resources.h" 50 #include "grit/generated_resources.h"
51 #include "grit/theme_resources.h" 51 #include "grit/theme_resources.h"
52 #include "grit/ui_resources.h" 52 #include "grit/ui_resources.h"
53 #include "ui/base/gtk/gtk_hig_constants.h" 53 #include "ui/base/gtk/gtk_hig_constants.h"
54 #include "ui/base/l10n/l10n_util.h" 54 #include "ui/base/l10n/l10n_util.h"
55 #include "ui/base/resource/resource_bundle.h" 55 #include "ui/base/resource/resource_bundle.h"
56 #include "ui/base/x/active_window_watcher_x.h" 56 #include "ui/base/x/active_window_watcher_x.h"
57 #include "ui/gfx/gtk_util.h"
58 #include "ui/gfx/image/image.h" 57 #include "ui/gfx/image/image.h"
59 58
60 using content::WebContents; 59 using content::WebContents;
61 60
62 namespace { 61 namespace {
63 62
64 // The space above the titlebars. 63 // The space above the titlebars.
65 const int kTitlebarHeight = 14; 64 const int kTitlebarHeight = 14;
66 65
67 // The thickness in pixels of the tab border. 66 // The thickness in pixels of the tab border.
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 string16 title = browser_window_->browser()->GetWindowTitleForCurrentTab(); 593 string16 title = browser_window_->browser()->GetWindowTitleForCurrentTab();
595 gtk_label_set_text(GTK_LABEL(app_mode_title_), UTF16ToUTF8(title).c_str()); 594 gtk_label_set_text(GTK_LABEL(app_mode_title_), UTF16ToUTF8(title).c_str());
596 595
597 if (browser_window_->browser()->is_app()) { 596 if (browser_window_->browser()->is_app()) {
598 switch (browser_window_->browser()->type()) { 597 switch (browser_window_->browser()->type()) {
599 case Browser::TYPE_POPUP: { 598 case Browser::TYPE_POPUP: {
600 // Update the system app icon. We don't need to update the icon in the 599 // 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 600 // top left of the custom frame, that will get updated when the
602 // throbber is updated. 601 // throbber is updated.
603 Profile* profile = browser_window_->browser()->profile(); 602 Profile* profile = browser_window_->browser()->profile();
604 SkBitmap icon = browser_window_->browser()->GetCurrentPageIcon(); 603 gfx::Image icon = browser_window_->browser()->GetCurrentPageIcon();
605 if (icon.empty()) { 604 if (icon.IsEmpty()) {
606 gtk_util::SetWindowIcon(window_, profile); 605 gtk_util::SetWindowIcon(window_, profile);
607 } else { 606 } else {
608 GdkPixbuf* icon_pixbuf = gfx::GdkPixbufFromSkBitmap(icon); 607 GdkPixbuf* icon_pixbuf = icon.ToGdkPixbuf();
Nico 2012/08/16 21:35:06 nit: no need for the local variable
609 gtk_util::SetWindowIcon(window_, profile, icon_pixbuf); 608 gtk_util::SetWindowIcon(window_, profile, icon_pixbuf);
610 g_object_unref(icon_pixbuf);
611 } 609 }
612 break; 610 break;
613 } 611 }
614 case Browser::TYPE_TABBED: { 612 case Browser::TYPE_TABBED: {
615 NOTREACHED() << "We should never have a tabbed app window."; 613 NOTREACHED() << "We should never have a tabbed app window.";
616 break; 614 break;
617 } 615 }
618 case Browser::TYPE_PANEL: { 616 case Browser::TYPE_PANEL: {
619 NOTREACHED(); 617 NOTREACHED();
620 break; 618 break;
621 } 619 }
622 } 620 }
623 } 621 }
624 } 622 }
625 623
626 void BrowserTitlebar::UpdateThrobber(WebContents* web_contents) { 624 void BrowserTitlebar::UpdateThrobber(WebContents* web_contents) {
627 DCHECK(app_mode_favicon_); 625 DCHECK(app_mode_favicon_);
628 626
629 if (web_contents && web_contents->IsLoading()) { 627 if (web_contents && web_contents->IsLoading()) {
630 GdkPixbuf* icon_pixbuf = 628 GdkPixbuf* icon_pixbuf =
631 throbber_.GetNextFrame(web_contents->IsWaitingForResponse()); 629 throbber_.GetNextFrame(web_contents->IsWaitingForResponse());
632 gtk_image_set_from_pixbuf(GTK_IMAGE(app_mode_favicon_), icon_pixbuf); 630 gtk_image_set_from_pixbuf(GTK_IMAGE(app_mode_favicon_), icon_pixbuf);
633 } else { 631 } else {
634 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 632 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
635 633
636 // Note: we want to exclude the application popup/panel window. 634 // Note: we want to exclude the application popup/panel window.
637 if ((browser_window_->browser()->is_app() && 635 if ((browser_window_->browser()->is_app() &&
638 !browser_window_->browser()->is_type_tabbed())) { 636 !browser_window_->browser()->is_type_tabbed())) {
639 SkBitmap icon = browser_window_->browser()->GetCurrentPageIcon(); 637 gfx::Image icon = browser_window_->browser()->GetCurrentPageIcon();
640 if (icon.empty()) { 638 if (icon.IsEmpty()) {
641 // Fallback to the Chromium icon if the page has no icon. 639 // Fallback to the Chromium icon if the page has no icon.
642 gtk_image_set_from_pixbuf(GTK_IMAGE(app_mode_favicon_), 640 gtk_image_set_from_pixbuf(GTK_IMAGE(app_mode_favicon_),
643 rb.GetNativeImageNamed(IDR_PRODUCT_LOGO_16).ToGdkPixbuf()); 641 rb.GetNativeImageNamed(IDR_PRODUCT_LOGO_16).ToGdkPixbuf());
644 } else { 642 } else {
645 GdkPixbuf* icon_pixbuf = gfx::GdkPixbufFromSkBitmap(icon); 643 GdkPixbuf* icon_pixbuf = icon.ToGdkPixbuf();
646 gtk_image_set_from_pixbuf(GTK_IMAGE(app_mode_favicon_), icon_pixbuf); 644 gtk_image_set_from_pixbuf(GTK_IMAGE(app_mode_favicon_), icon_pixbuf);
Nico 2012/08/16 21:35:06 likewise
647 g_object_unref(icon_pixbuf);
648 } 645 }
649 } else { 646 } else {
650 gtk_image_set_from_pixbuf(GTK_IMAGE(app_mode_favicon_), 647 gtk_image_set_from_pixbuf(GTK_IMAGE(app_mode_favicon_),
651 rb.GetNativeImageNamed(IDR_PRODUCT_LOGO_16).ToGdkPixbuf()); 648 rb.GetNativeImageNamed(IDR_PRODUCT_LOGO_16).ToGdkPixbuf());
652 } 649 }
653 throbber_.Reset(); 650 throbber_.Reset();
654 } 651 }
655 } 652 }
656 653
657 void BrowserTitlebar::UpdateTitlebarAlignment() { 654 void BrowserTitlebar::UpdateTitlebarAlignment() {
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
1051 ui::SimpleMenuModel::Delegate* delegate) 1048 ui::SimpleMenuModel::Delegate* delegate)
1052 : SimpleMenuModel(delegate) { 1049 : SimpleMenuModel(delegate) {
1053 AddItemWithStringId(IDC_NEW_TAB, IDS_TAB_CXMENU_NEWTAB); 1050 AddItemWithStringId(IDC_NEW_TAB, IDS_TAB_CXMENU_NEWTAB);
1054 AddItemWithStringId(IDC_RESTORE_TAB, IDS_RESTORE_TAB); 1051 AddItemWithStringId(IDC_RESTORE_TAB, IDS_RESTORE_TAB);
1055 AddSeparator(); 1052 AddSeparator();
1056 AddItemWithStringId(IDC_TASK_MANAGER, IDS_TASK_MANAGER); 1053 AddItemWithStringId(IDC_TASK_MANAGER, IDS_TASK_MANAGER);
1057 AddSeparator(); 1054 AddSeparator();
1058 AddCheckItemWithStringId(kShowWindowDecorationsCommand, 1055 AddCheckItemWithStringId(kShowWindowDecorationsCommand,
1059 IDS_SHOW_WINDOW_DECORATIONS_MENU); 1056 IDS_SHOW_WINDOW_DECORATIONS_MENU);
1060 } 1057 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698