| 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/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 Loading... |
| 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 Loading... |
| 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 gtk_util::SetWindowIcon(window_, profile, icon.ToGdkPixbuf()); |
| 609 gtk_util::SetWindowIcon(window_, profile, icon_pixbuf); | |
| 610 g_object_unref(icon_pixbuf); | |
| 611 } | 608 } |
| 612 break; | 609 break; |
| 613 } | 610 } |
| 614 case Browser::TYPE_TABBED: { | 611 case Browser::TYPE_TABBED: { |
| 615 NOTREACHED() << "We should never have a tabbed app window."; | 612 NOTREACHED() << "We should never have a tabbed app window."; |
| 616 break; | 613 break; |
| 617 } | 614 } |
| 618 case Browser::TYPE_PANEL: { | 615 case Browser::TYPE_PANEL: { |
| 619 NOTREACHED(); | 616 NOTREACHED(); |
| 620 break; | 617 break; |
| 621 } | 618 } |
| 622 } | 619 } |
| 623 } | 620 } |
| 624 } | 621 } |
| 625 | 622 |
| 626 void BrowserTitlebar::UpdateThrobber(WebContents* web_contents) { | 623 void BrowserTitlebar::UpdateThrobber(WebContents* web_contents) { |
| 627 DCHECK(app_mode_favicon_); | 624 DCHECK(app_mode_favicon_); |
| 628 | 625 |
| 629 if (web_contents && web_contents->IsLoading()) { | 626 if (web_contents && web_contents->IsLoading()) { |
| 630 GdkPixbuf* icon_pixbuf = | 627 GdkPixbuf* icon_pixbuf = |
| 631 throbber_.GetNextFrame(web_contents->IsWaitingForResponse()); | 628 throbber_.GetNextFrame(web_contents->IsWaitingForResponse()); |
| 632 gtk_image_set_from_pixbuf(GTK_IMAGE(app_mode_favicon_), icon_pixbuf); | 629 gtk_image_set_from_pixbuf(GTK_IMAGE(app_mode_favicon_), icon_pixbuf); |
| 633 } else { | 630 } else { |
| 634 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 631 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 635 | 632 |
| 636 // Note: we want to exclude the application popup/panel window. | 633 // Note: we want to exclude the application popup/panel window. |
| 637 if ((browser_window_->browser()->is_app() && | 634 if ((browser_window_->browser()->is_app() && |
| 638 !browser_window_->browser()->is_type_tabbed())) { | 635 !browser_window_->browser()->is_type_tabbed())) { |
| 639 SkBitmap icon = browser_window_->browser()->GetCurrentPageIcon(); | 636 gfx::Image icon = browser_window_->browser()->GetCurrentPageIcon(); |
| 640 if (icon.empty()) { | 637 if (icon.IsEmpty()) { |
| 641 // Fallback to the Chromium icon if the page has no icon. | 638 // Fallback to the Chromium icon if the page has no icon. |
| 642 gtk_image_set_from_pixbuf(GTK_IMAGE(app_mode_favicon_), | 639 gtk_image_set_from_pixbuf(GTK_IMAGE(app_mode_favicon_), |
| 643 rb.GetNativeImageNamed(IDR_PRODUCT_LOGO_16).ToGdkPixbuf()); | 640 rb.GetNativeImageNamed(IDR_PRODUCT_LOGO_16).ToGdkPixbuf()); |
| 644 } else { | 641 } else { |
| 645 GdkPixbuf* icon_pixbuf = gfx::GdkPixbufFromSkBitmap(icon); | 642 gtk_image_set_from_pixbuf(GTK_IMAGE(app_mode_favicon_), |
| 646 gtk_image_set_from_pixbuf(GTK_IMAGE(app_mode_favicon_), icon_pixbuf); | 643 icon.ToGdkPixbuf()); |
| 647 g_object_unref(icon_pixbuf); | |
| 648 } | 644 } |
| 649 } else { | 645 } else { |
| 650 gtk_image_set_from_pixbuf(GTK_IMAGE(app_mode_favicon_), | 646 gtk_image_set_from_pixbuf(GTK_IMAGE(app_mode_favicon_), |
| 651 rb.GetNativeImageNamed(IDR_PRODUCT_LOGO_16).ToGdkPixbuf()); | 647 rb.GetNativeImageNamed(IDR_PRODUCT_LOGO_16).ToGdkPixbuf()); |
| 652 } | 648 } |
| 653 throbber_.Reset(); | 649 throbber_.Reset(); |
| 654 } | 650 } |
| 655 } | 651 } |
| 656 | 652 |
| 657 void BrowserTitlebar::UpdateTitlebarAlignment() { | 653 void BrowserTitlebar::UpdateTitlebarAlignment() { |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1051 ui::SimpleMenuModel::Delegate* delegate) | 1047 ui::SimpleMenuModel::Delegate* delegate) |
| 1052 : SimpleMenuModel(delegate) { | 1048 : SimpleMenuModel(delegate) { |
| 1053 AddItemWithStringId(IDC_NEW_TAB, IDS_TAB_CXMENU_NEWTAB); | 1049 AddItemWithStringId(IDC_NEW_TAB, IDS_TAB_CXMENU_NEWTAB); |
| 1054 AddItemWithStringId(IDC_RESTORE_TAB, IDS_RESTORE_TAB); | 1050 AddItemWithStringId(IDC_RESTORE_TAB, IDS_RESTORE_TAB); |
| 1055 AddSeparator(); | 1051 AddSeparator(); |
| 1056 AddItemWithStringId(IDC_TASK_MANAGER, IDS_TASK_MANAGER); | 1052 AddItemWithStringId(IDC_TASK_MANAGER, IDS_TASK_MANAGER); |
| 1057 AddSeparator(); | 1053 AddSeparator(); |
| 1058 AddCheckItemWithStringId(kShowWindowDecorationsCommand, | 1054 AddCheckItemWithStringId(kShowWindowDecorationsCommand, |
| 1059 IDS_SHOW_WINDOW_DECORATIONS_MENU); | 1055 IDS_SHOW_WINDOW_DECORATIONS_MENU); |
| 1060 } | 1056 } |
| OLD | NEW |