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/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 26 matching lines...) Expand all Loading... | |
| 37 #endif | 37 #endif |
| 38 #include "chrome/browser/ui/gtk/gtk_theme_service.h" | 38 #include "chrome/browser/ui/gtk/gtk_theme_service.h" |
| 39 #include "chrome/browser/ui/gtk/gtk_util.h" | 39 #include "chrome/browser/ui/gtk/gtk_util.h" |
| 40 #include "chrome/browser/ui/gtk/menu_gtk.h" | 40 #include "chrome/browser/ui/gtk/menu_gtk.h" |
| 41 #include "chrome/browser/ui/gtk/nine_box.h" | 41 #include "chrome/browser/ui/gtk/nine_box.h" |
| 42 #include "chrome/browser/ui/gtk/tabs/tab_strip_gtk.h" | 42 #include "chrome/browser/ui/gtk/tabs/tab_strip_gtk.h" |
| 43 #include "chrome/browser/ui/gtk/unity_service.h" | 43 #include "chrome/browser/ui/gtk/unity_service.h" |
| 44 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 44 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 45 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h" | 45 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h" |
| 46 #include "chrome/browser/ui/toolbar/wrench_menu_model.h" | 46 #include "chrome/browser/ui/toolbar/wrench_menu_model.h" |
| 47 #include "chrome/browser/ui/web_applications/hosted_app_tab_helper.h" | |
| 47 #include "chrome/common/chrome_switches.h" | 48 #include "chrome/common/chrome_switches.h" |
| 48 #include "chrome/common/pref_names.h" | 49 #include "chrome/common/pref_names.h" |
| 49 #include "content/public/browser/notification_service.h" | 50 #include "content/public/browser/notification_service.h" |
| 50 #include "content/public/browser/web_contents.h" | 51 #include "content/public/browser/web_contents.h" |
| 51 #include "grit/generated_resources.h" | 52 #include "grit/generated_resources.h" |
| 52 #include "grit/theme_resources.h" | 53 #include "grit/theme_resources.h" |
| 53 #include "grit/ui_resources.h" | 54 #include "grit/ui_resources.h" |
| 54 #include "ui/base/gtk/gtk_hig_constants.h" | 55 #include "ui/base/gtk/gtk_hig_constants.h" |
| 55 #include "ui/base/l10n/l10n_util.h" | 56 #include "ui/base/l10n/l10n_util.h" |
| 56 #include "ui/base/resource/resource_bundle.h" | 57 #include "ui/base/resource/resource_bundle.h" |
| (...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 607 string16 title = browser_window_->browser()->GetWindowTitleForCurrentTab(); | 608 string16 title = browser_window_->browser()->GetWindowTitleForCurrentTab(); |
| 608 gtk_label_set_text(GTK_LABEL(app_mode_title_), UTF16ToUTF8(title).c_str()); | 609 gtk_label_set_text(GTK_LABEL(app_mode_title_), UTF16ToUTF8(title).c_str()); |
| 609 | 610 |
| 610 if (browser_window_->browser()->is_app()) { | 611 if (browser_window_->browser()->is_app()) { |
| 611 switch (browser_window_->browser()->type()) { | 612 switch (browser_window_->browser()->type()) { |
| 612 case Browser::TYPE_POPUP: { | 613 case Browser::TYPE_POPUP: { |
| 613 // Update the system app icon. We don't need to update the icon in the | 614 // Update the system app icon. We don't need to update the icon in the |
| 614 // top left of the custom frame, that will get updated when the | 615 // top left of the custom frame, that will get updated when the |
| 615 // throbber is updated. | 616 // throbber is updated. |
| 616 Profile* profile = browser_window_->browser()->profile(); | 617 Profile* profile = browser_window_->browser()->profile(); |
| 617 gfx::Image icon = browser_window_->browser()->GetCurrentPageIcon(); | 618 WebContents* web_contents = browser_window_->browser()-> |
|
tapted
2013/11/17 23:28:50
This is a lot of boilerplate, that's repeated belo
| |
| 618 if (icon.IsEmpty()) { | 619 tab_strip_model()->GetActiveWebContents(); |
| 620 HostedAppTabHelper* hosted_app_tab_helper = | |
| 621 web_contents ? HostedAppTabHelper::FromWebContents(web_contents) | |
| 622 : NULL; | |
| 623 const gfx::Image* icon = hosted_app_tab_helper | |
| 624 ? hosted_app_tab_helper->image_family().GetBest( | |
| 625 IconUtil::kMediumIconSize, IconUtil::kMediumIconSize) | |
| 626 : NULL; | |
| 627 if (!icon || icon->IsEmpty()) { | |
| 619 gtk_util::SetWindowIcon(window_, profile); | 628 gtk_util::SetWindowIcon(window_, profile); |
| 620 } else { | 629 } else { |
| 621 gtk_util::SetWindowIcon(window_, profile, icon.ToGdkPixbuf()); | 630 gtk_util::SetWindowIcon(window_, profile, icon->ToGdkPixbuf()); |
| 622 } | 631 } |
| 623 break; | 632 break; |
| 624 } | 633 } |
| 625 case Browser::TYPE_TABBED: { | 634 case Browser::TYPE_TABBED: { |
| 626 NOTREACHED() << "We should never have a tabbed app window."; | 635 NOTREACHED() << "We should never have a tabbed app window."; |
| 627 break; | 636 break; |
| 628 } | 637 } |
| 629 } | 638 } |
| 630 } | 639 } |
| 631 } | 640 } |
| 632 | 641 |
| 633 void BrowserTitlebar::UpdateThrobber(WebContents* web_contents) { | 642 void BrowserTitlebar::UpdateThrobber(WebContents* web_contents) { |
| 634 DCHECK(app_mode_favicon_); | 643 DCHECK(app_mode_favicon_); |
| 635 | 644 |
| 636 if (web_contents && web_contents->IsLoading()) { | 645 if (web_contents && web_contents->IsLoading()) { |
| 637 GdkPixbuf* icon_pixbuf = | 646 GdkPixbuf* icon_pixbuf = |
| 638 throbber_.GetNextFrame(web_contents->IsWaitingForResponse()); | 647 throbber_.GetNextFrame(web_contents->IsWaitingForResponse()); |
| 639 gtk_image_set_from_pixbuf(GTK_IMAGE(app_mode_favicon_), icon_pixbuf); | 648 gtk_image_set_from_pixbuf(GTK_IMAGE(app_mode_favicon_), icon_pixbuf); |
| 640 } else { | 649 } else { |
| 641 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 650 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 642 | 651 |
| 643 // Note: we want to exclude the application popup/panel window. | 652 // Note: we want to exclude the application popup/panel window. |
| 644 if ((browser_window_->browser()->is_app() && | 653 if ((browser_window_->browser()->is_app() && |
| 645 !browser_window_->browser()->is_type_tabbed()) || | 654 !browser_window_->browser()->is_type_tabbed()) || |
| 646 browser_window_->browser()->is_type_popup()) { | 655 browser_window_->browser()->is_type_popup()) { |
| 647 gfx::Image icon = browser_window_->browser()->GetCurrentPageIcon(); | 656 WebContents* web_contents = browser_window_->browser()-> |
| 648 if (icon.IsEmpty()) { | 657 tab_strip_model()->GetActiveWebContents(); |
| 658 HostedAppTabHelper* hosted_app_tab_helper = | |
| 659 web_contents ? HostedAppTabHelper::FromWebContents(web_contents) | |
| 660 : NULL; | |
| 661 const gfx::Image* icon = hosted_app_tab_helper | |
| 662 ? hosted_app_tab_helper->image_family().GetBest( | |
| 663 IconUtil::kMediumIconSize, IconUtil::kMediumIconSize) | |
| 664 : NULL; | |
| 665 if (!icon || icon->IsEmpty()) { | |
| 649 // Fallback to the Chromium icon if the page has no icon. | 666 // Fallback to the Chromium icon if the page has no icon. |
| 650 gtk_image_set_from_pixbuf(GTK_IMAGE(app_mode_favicon_), | 667 gtk_image_set_from_pixbuf(GTK_IMAGE(app_mode_favicon_), |
| 651 rb.GetNativeImageNamed(IDR_PRODUCT_LOGO_16).ToGdkPixbuf()); | 668 rb.GetNativeImageNamed(IDR_PRODUCT_LOGO_16).ToGdkPixbuf()); |
| 652 } else { | 669 } else { |
| 653 gtk_image_set_from_pixbuf(GTK_IMAGE(app_mode_favicon_), | 670 gtk_image_set_from_pixbuf(GTK_IMAGE(app_mode_favicon_), |
| 654 icon.ToGdkPixbuf()); | 671 icon->ToGdkPixbuf()); |
| 655 } | 672 } |
| 656 } else { | 673 } else { |
| 657 gtk_image_set_from_pixbuf(GTK_IMAGE(app_mode_favicon_), | 674 gtk_image_set_from_pixbuf(GTK_IMAGE(app_mode_favicon_), |
| 658 rb.GetNativeImageNamed(IDR_PRODUCT_LOGO_16).ToGdkPixbuf()); | 675 rb.GetNativeImageNamed(IDR_PRODUCT_LOGO_16).ToGdkPixbuf()); |
| 659 } | 676 } |
| 660 throbber_.Reset(); | 677 throbber_.Reset(); |
| 661 } | 678 } |
| 662 } | 679 } |
| 663 | 680 |
| 664 void BrowserTitlebar::UpdateTitlebarAlignment() { | 681 void BrowserTitlebar::UpdateTitlebarAlignment() { |
| (...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1096 ui::SimpleMenuModel::Delegate* delegate) | 1113 ui::SimpleMenuModel::Delegate* delegate) |
| 1097 : SimpleMenuModel(delegate) { | 1114 : SimpleMenuModel(delegate) { |
| 1098 AddItemWithStringId(IDC_NEW_TAB, IDS_TAB_CXMENU_NEWTAB); | 1115 AddItemWithStringId(IDC_NEW_TAB, IDS_TAB_CXMENU_NEWTAB); |
| 1099 AddItemWithStringId(IDC_RESTORE_TAB, IDS_RESTORE_TAB); | 1116 AddItemWithStringId(IDC_RESTORE_TAB, IDS_RESTORE_TAB); |
| 1100 AddSeparator(ui::NORMAL_SEPARATOR); | 1117 AddSeparator(ui::NORMAL_SEPARATOR); |
| 1101 AddItemWithStringId(IDC_TASK_MANAGER, IDS_TASK_MANAGER); | 1118 AddItemWithStringId(IDC_TASK_MANAGER, IDS_TASK_MANAGER); |
| 1102 AddSeparator(ui::NORMAL_SEPARATOR); | 1119 AddSeparator(ui::NORMAL_SEPARATOR); |
| 1103 AddCheckItemWithStringId(kShowWindowDecorationsCommand, | 1120 AddCheckItemWithStringId(kShowWindowDecorationsCommand, |
| 1104 IDS_SHOW_WINDOW_DECORATIONS_MENU); | 1121 IDS_SHOW_WINDOW_DECORATIONS_MENU); |
| 1105 } | 1122 } |
| OLD | NEW |