OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "grit/theme_resources_standard.h" | 47 #include "grit/theme_resources_standard.h" |
48 #include "grit/ui_resources.h" | 48 #include "grit/ui_resources.h" |
49 #include "ui/base/gtk/gtk_hig_constants.h" | 49 #include "ui/base/gtk/gtk_hig_constants.h" |
50 #include "ui/base/l10n/l10n_util.h" | 50 #include "ui/base/l10n/l10n_util.h" |
51 #include "ui/base/resource/resource_bundle.h" | 51 #include "ui/base/resource/resource_bundle.h" |
52 #include "ui/base/x/active_window_watcher_x.h" | 52 #include "ui/base/x/active_window_watcher_x.h" |
53 #include "ui/gfx/gtk_util.h" | 53 #include "ui/gfx/gtk_util.h" |
54 #include "ui/gfx/image/image.h" | 54 #include "ui/gfx/image/image.h" |
55 #include "ui/gfx/skbitmap_operations.h" | 55 #include "ui/gfx/skbitmap_operations.h" |
56 | 56 |
| 57 using content::WebContents; |
| 58 |
57 namespace { | 59 namespace { |
58 | 60 |
59 // The space above the titlebars. | 61 // The space above the titlebars. |
60 const int kTitlebarHeight = 14; | 62 const int kTitlebarHeight = 14; |
61 | 63 |
62 // The thickness in pixels of the tab border. | 64 // The thickness in pixels of the tab border. |
63 const int kTabOuterThickness = 1; | 65 const int kTabOuterThickness = 1; |
64 | 66 |
65 // Amount to offset the tab images relative to the background. | 67 // Amount to offset the tab images relative to the background. |
66 const int kNormalVerticalOffset = kTitlebarHeight + kTabOuterThickness; | 68 const int kNormalVerticalOffset = kTitlebarHeight + kTabOuterThickness; |
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
628 // Shell windows don't show titles and icons for now. | 630 // Shell windows don't show titles and icons for now. |
629 break; | 631 break; |
630 } | 632 } |
631 case Browser::TYPE_PANEL: { | 633 case Browser::TYPE_PANEL: { |
632 break; | 634 break; |
633 } | 635 } |
634 } | 636 } |
635 } | 637 } |
636 } | 638 } |
637 | 639 |
638 void BrowserTitlebar::UpdateThrobber(TabContents* tab_contents) { | 640 void BrowserTitlebar::UpdateThrobber(WebContents* web_contents) { |
639 DCHECK(app_mode_favicon_); | 641 DCHECK(app_mode_favicon_); |
640 | 642 |
641 if (tab_contents && tab_contents->IsLoading()) { | 643 if (web_contents && web_contents->IsLoading()) { |
642 GdkPixbuf* icon_pixbuf = | 644 GdkPixbuf* icon_pixbuf = |
643 throbber_.GetNextFrame(tab_contents->IsWaitingForResponse()); | 645 throbber_.GetNextFrame(web_contents->IsWaitingForResponse()); |
644 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); |
645 } else { | 647 } else { |
646 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 648 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
647 | 649 |
648 // Note: we want to exclude the application popup window. | 650 // Note: we want to exclude the application popup window. |
649 if (browser_window_->browser()->is_app() && | 651 if (browser_window_->browser()->is_app() && |
650 browser_window_->browser()->is_type_popup()) { | 652 browser_window_->browser()->is_type_popup()) { |
651 SkBitmap icon = browser_window_->browser()->GetCurrentPageIcon(); | 653 SkBitmap icon = browser_window_->browser()->GetCurrentPageIcon(); |
652 if (icon.empty()) { | 654 if (icon.empty()) { |
653 // Fallback to the Chromium icon if the page has no icon. | 655 // Fallback to the Chromium icon if the page has no icon. |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
980 } | 982 } |
981 | 983 |
982 bool BrowserTitlebar::IsCommandIdChecked(int command_id) const { | 984 bool BrowserTitlebar::IsCommandIdChecked(int command_id) const { |
983 if (command_id == kShowWindowDecorationsCommand) { | 985 if (command_id == kShowWindowDecorationsCommand) { |
984 PrefService* prefs = browser_window_->browser()->profile()->GetPrefs(); | 986 PrefService* prefs = browser_window_->browser()->profile()->GetPrefs(); |
985 return !prefs->GetBoolean(prefs::kUseCustomChromeFrame); | 987 return !prefs->GetBoolean(prefs::kUseCustomChromeFrame); |
986 } | 988 } |
987 | 989 |
988 EncodingMenuController controller; | 990 EncodingMenuController controller; |
989 if (controller.DoesCommandBelongToEncodingMenu(command_id)) { | 991 if (controller.DoesCommandBelongToEncodingMenu(command_id)) { |
990 TabContents* tab_contents = | 992 WebContents* web_contents = |
991 browser_window_->browser()->GetSelectedTabContents(); | 993 browser_window_->browser()->GetSelectedWebContents(); |
992 if (tab_contents) { | 994 if (web_contents) { |
993 return controller.IsItemChecked(browser_window_->browser()->profile(), | 995 return controller.IsItemChecked(browser_window_->browser()->profile(), |
994 tab_contents->GetEncoding(), | 996 web_contents->GetEncoding(), |
995 command_id); | 997 command_id); |
996 } | 998 } |
997 return false; | 999 return false; |
998 } | 1000 } |
999 | 1001 |
1000 NOTREACHED(); | 1002 NOTREACHED(); |
1001 return false; | 1003 return false; |
1002 } | 1004 } |
1003 | 1005 |
1004 void BrowserTitlebar::ExecuteCommand(int command_id) { | 1006 void BrowserTitlebar::ExecuteCommand(int command_id) { |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1140 ui::SimpleMenuModel::Delegate* delegate) | 1142 ui::SimpleMenuModel::Delegate* delegate) |
1141 : SimpleMenuModel(delegate) { | 1143 : SimpleMenuModel(delegate) { |
1142 AddItemWithStringId(IDC_NEW_TAB, IDS_TAB_CXMENU_NEWTAB); | 1144 AddItemWithStringId(IDC_NEW_TAB, IDS_TAB_CXMENU_NEWTAB); |
1143 AddItemWithStringId(IDC_RESTORE_TAB, IDS_RESTORE_TAB); | 1145 AddItemWithStringId(IDC_RESTORE_TAB, IDS_RESTORE_TAB); |
1144 AddSeparator(); | 1146 AddSeparator(); |
1145 AddItemWithStringId(IDC_TASK_MANAGER, IDS_TASK_MANAGER); | 1147 AddItemWithStringId(IDC_TASK_MANAGER, IDS_TASK_MANAGER); |
1146 AddSeparator(); | 1148 AddSeparator(); |
1147 AddCheckItemWithStringId(kShowWindowDecorationsCommand, | 1149 AddCheckItemWithStringId(kShowWindowDecorationsCommand, |
1148 IDS_SHOW_WINDOW_DECORATIONS_MENU); | 1150 IDS_SHOW_WINDOW_DECORATIONS_MENU); |
1149 } | 1151 } |
OLD | NEW |