OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/location_bar_view_gtk.h" | 5 #include "chrome/browser/ui/gtk/location_bar_view_gtk.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "chrome/browser/alternate_nav_url_fetcher.h" | 23 #include "chrome/browser/alternate_nav_url_fetcher.h" |
24 #include "chrome/browser/command_updater.h" | 24 #include "chrome/browser/command_updater.h" |
25 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 25 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
26 #include "chrome/browser/defaults.h" | 26 #include "chrome/browser/defaults.h" |
27 #include "chrome/browser/extensions/api/commands/command_service.h" | 27 #include "chrome/browser/extensions/api/commands/command_service.h" |
28 #include "chrome/browser/extensions/api/commands/command_service_factory.h" | 28 #include "chrome/browser/extensions/api/commands/command_service_factory.h" |
29 #include "chrome/browser/extensions/extension_action.h" | 29 #include "chrome/browser/extensions/extension_action.h" |
30 #include "chrome/browser/extensions/extension_service.h" | 30 #include "chrome/browser/extensions/extension_service.h" |
31 #include "chrome/browser/extensions/extension_tab_util.h" | 31 #include "chrome/browser/extensions/extension_tab_util.h" |
32 #include "chrome/browser/extensions/location_bar_controller.h" | 32 #include "chrome/browser/extensions/location_bar_controller.h" |
| 33 #include "chrome/browser/extensions/script_bubble_controller.h" |
33 #include "chrome/browser/extensions/tab_helper.h" | 34 #include "chrome/browser/extensions/tab_helper.h" |
34 #include "chrome/browser/favicon/favicon_tab_helper.h" | 35 #include "chrome/browser/favicon/favicon_tab_helper.h" |
35 #include "chrome/browser/prefs/pref_service.h" | 36 #include "chrome/browser/prefs/pref_service.h" |
36 #include "chrome/browser/profiles/profile.h" | 37 #include "chrome/browser/profiles/profile.h" |
37 #include "chrome/browser/search_engines/template_url.h" | 38 #include "chrome/browser/search_engines/template_url.h" |
38 #include "chrome/browser/search_engines/template_url_service.h" | 39 #include "chrome/browser/search_engines/template_url_service.h" |
39 #include "chrome/browser/search_engines/template_url_service_factory.h" | 40 #include "chrome/browser/search_engines/template_url_service_factory.h" |
40 #include "chrome/browser/ui/browser.h" | 41 #include "chrome/browser/ui/browser.h" |
41 #include "chrome/browser/ui/browser_command_controller.h" | 42 #include "chrome/browser/ui/browser_command_controller.h" |
42 #include "chrome/browser/ui/browser_commands.h" | 43 #include "chrome/browser/ui/browser_commands.h" |
43 #include "chrome/browser/ui/browser_content_setting_bubble_model_delegate.h" | 44 #include "chrome/browser/ui/browser_content_setting_bubble_model_delegate.h" |
44 #include "chrome/browser/ui/browser_instant_controller.h" | 45 #include "chrome/browser/ui/browser_instant_controller.h" |
45 #include "chrome/browser/ui/browser_list.h" | 46 #include "chrome/browser/ui/browser_list.h" |
46 #include "chrome/browser/ui/browser_tabstrip.h" | 47 #include "chrome/browser/ui/browser_tabstrip.h" |
47 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" | 48 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" |
48 #include "chrome/browser/ui/content_settings/content_setting_image_model.h" | 49 #include "chrome/browser/ui/content_settings/content_setting_image_model.h" |
49 #include "chrome/browser/ui/gtk/action_box_button_gtk.h" | 50 #include "chrome/browser/ui/gtk/action_box_button_gtk.h" |
50 #include "chrome/browser/ui/gtk/bookmarks/bookmark_bubble_gtk.h" | 51 #include "chrome/browser/ui/gtk/bookmarks/bookmark_bubble_gtk.h" |
51 #include "chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.h" | 52 #include "chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.h" |
52 #include "chrome/browser/ui/gtk/browser_window_gtk.h" | 53 #include "chrome/browser/ui/gtk/browser_window_gtk.h" |
53 #include "chrome/browser/ui/gtk/chrome_to_mobile_bubble_gtk.h" | 54 #include "chrome/browser/ui/gtk/chrome_to_mobile_bubble_gtk.h" |
54 #include "chrome/browser/ui/gtk/content_setting_bubble_gtk.h" | 55 #include "chrome/browser/ui/gtk/content_setting_bubble_gtk.h" |
55 #include "chrome/browser/ui/gtk/extensions/extension_popup_gtk.h" | 56 #include "chrome/browser/ui/gtk/extensions/extension_popup_gtk.h" |
56 #include "chrome/browser/ui/gtk/first_run_bubble.h" | 57 #include "chrome/browser/ui/gtk/first_run_bubble.h" |
57 #include "chrome/browser/ui/gtk/gtk_theme_service.h" | 58 #include "chrome/browser/ui/gtk/gtk_theme_service.h" |
58 #include "chrome/browser/ui/gtk/gtk_util.h" | 59 #include "chrome/browser/ui/gtk/gtk_util.h" |
59 #include "chrome/browser/ui/gtk/nine_box.h" | 60 #include "chrome/browser/ui/gtk/nine_box.h" |
60 #include "chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.h" | 61 #include "chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.h" |
61 #include "chrome/browser/ui/gtk/rounded_window.h" | 62 #include "chrome/browser/ui/gtk/rounded_window.h" |
| 63 #include "chrome/browser/ui/gtk/script_bubble_gtk.h" |
62 #include "chrome/browser/ui/gtk/view_id_util.h" | 64 #include "chrome/browser/ui/gtk/view_id_util.h" |
63 #include "chrome/browser/ui/gtk/zoom_bubble_gtk.h" | 65 #include "chrome/browser/ui/gtk/zoom_bubble_gtk.h" |
64 #include "chrome/browser/ui/intents/web_intent_picker_controller.h" | 66 #include "chrome/browser/ui/intents/web_intent_picker_controller.h" |
65 #include "chrome/browser/ui/omnibox/location_bar_util.h" | 67 #include "chrome/browser/ui/omnibox/location_bar_util.h" |
66 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h" | 68 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h" |
67 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" | 69 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" |
68 #include "chrome/browser/ui/webui/extensions/extension_info_ui.h" | 70 #include "chrome/browser/ui/webui/extensions/extension_info_ui.h" |
69 #include "chrome/browser/ui/zoom/zoom_controller.h" | 71 #include "chrome/browser/ui/zoom/zoom_controller.h" |
| 72 #include "chrome/common/badge_util.h" |
70 #include "chrome/common/chrome_notification_types.h" | 73 #include "chrome/common/chrome_notification_types.h" |
71 #include "chrome/common/chrome_switches.h" | 74 #include "chrome/common/chrome_switches.h" |
72 #include "chrome/common/extensions/extension.h" | 75 #include "chrome/common/extensions/extension.h" |
73 #include "chrome/common/extensions/extension_manifest_constants.h" | 76 #include "chrome/common/extensions/extension_manifest_constants.h" |
74 #include "chrome/common/extensions/extension_resource.h" | 77 #include "chrome/common/extensions/extension_resource.h" |
75 #include "chrome/common/extensions/feature_switch.h" | 78 #include "chrome/common/extensions/feature_switch.h" |
76 #include "chrome/common/pref_names.h" | 79 #include "chrome/common/pref_names.h" |
77 #include "content/public/browser/navigation_entry.h" | 80 #include "content/public/browser/navigation_entry.h" |
78 #include "content/public/browser/notification_service.h" | 81 #include "content/public/browser/notification_service.h" |
79 #include "content/public/browser/web_contents.h" | 82 #include "content/public/browser/web_contents.h" |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 | 383 |
381 //////////////////////////////////////////////////////////////////////////////// | 384 //////////////////////////////////////////////////////////////////////////////// |
382 // LocationBarViewGtk | 385 // LocationBarViewGtk |
383 | 386 |
384 // static | 387 // static |
385 const GdkColor LocationBarViewGtk::kBackgroundColor = | 388 const GdkColor LocationBarViewGtk::kBackgroundColor = |
386 GDK_COLOR_RGB(255, 255, 255); | 389 GDK_COLOR_RGB(255, 255, 255); |
387 | 390 |
388 LocationBarViewGtk::LocationBarViewGtk(Browser* browser) | 391 LocationBarViewGtk::LocationBarViewGtk(Browser* browser) |
389 : zoom_image_(NULL), | 392 : zoom_image_(NULL), |
| 393 script_bubble_button_image_(NULL), |
| 394 num_running_scripts_(0u), |
390 star_image_(NULL), | 395 star_image_(NULL), |
391 starred_(false), | 396 starred_(false), |
392 star_sized_(false), | 397 star_sized_(false), |
393 site_type_alignment_(NULL), | 398 site_type_alignment_(NULL), |
394 site_type_event_box_(NULL), | 399 site_type_event_box_(NULL), |
395 location_icon_image_(NULL), | 400 location_icon_image_(NULL), |
396 drag_icon_(NULL), | 401 drag_icon_(NULL), |
397 enable_location_drag_(false), | 402 enable_location_drag_(false), |
398 security_info_label_(NULL), | 403 security_info_label_(NULL), |
399 web_intents_button_view_(new WebIntentsButtonViewGtk(this)), | 404 web_intents_button_view_(new WebIntentsButtonViewGtk(this)), |
(...skipping 17 matching lines...) Expand all Loading... |
417 theme_service_(NULL), | 422 theme_service_(NULL), |
418 hbox_width_(0), | 423 hbox_width_(0), |
419 entry_box_width_(0), | 424 entry_box_width_(0), |
420 show_selected_keyword_(false), | 425 show_selected_keyword_(false), |
421 show_keyword_hint_(false) { | 426 show_keyword_hint_(false) { |
422 } | 427 } |
423 | 428 |
424 LocationBarViewGtk::~LocationBarViewGtk() { | 429 LocationBarViewGtk::~LocationBarViewGtk() { |
425 // All of our widgets should be children of / owned by the alignment. | 430 // All of our widgets should be children of / owned by the alignment. |
426 zoom_.Destroy(); | 431 zoom_.Destroy(); |
| 432 script_bubble_button_.Destroy(); |
427 star_.Destroy(); | 433 star_.Destroy(); |
428 hbox_.Destroy(); | 434 hbox_.Destroy(); |
429 content_setting_hbox_.Destroy(); | 435 content_setting_hbox_.Destroy(); |
430 page_action_hbox_.Destroy(); | 436 page_action_hbox_.Destroy(); |
431 web_intents_hbox_.Destroy(); | 437 web_intents_hbox_.Destroy(); |
432 } | 438 } |
433 | 439 |
434 void LocationBarViewGtk::Init(bool popup_window_mode) { | 440 void LocationBarViewGtk::Init(bool popup_window_mode) { |
435 popup_window_mode_ = popup_window_mode; | 441 popup_window_mode_ = popup_window_mode; |
436 | 442 |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
558 gtk_box_pack_end(GTK_BOX(hbox_.get()), alignment, | 564 gtk_box_pack_end(GTK_BOX(hbox_.get()), alignment, |
559 FALSE, FALSE, 0); | 565 FALSE, FALSE, 0); |
560 } | 566 } |
561 | 567 |
562 if (browser_defaults::bookmarks_enabled && !ShouldOnlyShowLocation()) { | 568 if (browser_defaults::bookmarks_enabled && !ShouldOnlyShowLocation()) { |
563 // Hide the star icon in popups, app windows, etc. | 569 // Hide the star icon in popups, app windows, etc. |
564 CreateStarButton(); | 570 CreateStarButton(); |
565 gtk_box_pack_end(GTK_BOX(hbox_.get()), star_.get(), FALSE, FALSE, 0); | 571 gtk_box_pack_end(GTK_BOX(hbox_.get()), star_.get(), FALSE, FALSE, 0); |
566 } | 572 } |
567 | 573 |
| 574 CreateScriptBubbleButton(); |
| 575 gtk_box_pack_end(GTK_BOX(hbox_.get()), script_bubble_button_.get(), FALSE, |
| 576 FALSE, 0); |
| 577 |
568 CreateZoomButton(); | 578 CreateZoomButton(); |
569 gtk_box_pack_end(GTK_BOX(hbox_.get()), zoom_.get(), FALSE, FALSE, 0); | 579 gtk_box_pack_end(GTK_BOX(hbox_.get()), zoom_.get(), FALSE, FALSE, 0); |
570 | 580 |
571 content_setting_hbox_.Own(gtk_hbox_new(FALSE, InnerPadding() + 1)); | 581 content_setting_hbox_.Own(gtk_hbox_new(FALSE, InnerPadding() + 1)); |
572 gtk_widget_set_name(content_setting_hbox_.get(), | 582 gtk_widget_set_name(content_setting_hbox_.get(), |
573 "chrome-content-setting-hbox"); | 583 "chrome-content-setting-hbox"); |
574 gtk_box_pack_end(GTK_BOX(hbox_.get()), content_setting_hbox_.get(), | 584 gtk_box_pack_end(GTK_BOX(hbox_.get()), content_setting_hbox_.get(), |
575 FALSE, FALSE, 1); | 585 FALSE, FALSE, 1); |
576 | 586 |
577 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { | 587 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
718 iter != page_action_views_.end(); | 728 iter != page_action_views_.end(); |
719 ++iter) { | 729 ++iter) { |
720 if ((*iter)->page_action() == page_action) | 730 if ((*iter)->page_action() == page_action) |
721 return (*iter)->widget(); | 731 return (*iter)->widget(); |
722 } | 732 } |
723 return NULL; | 733 return NULL; |
724 } | 734 } |
725 | 735 |
726 void LocationBarViewGtk::Update(const WebContents* contents) { | 736 void LocationBarViewGtk::Update(const WebContents* contents) { |
727 UpdateZoomIcon(); | 737 UpdateZoomIcon(); |
| 738 UpdateScriptBubbleIcon(); |
728 UpdateStarIcon(); | 739 UpdateStarIcon(); |
729 UpdateSiteTypeArea(); | 740 UpdateSiteTypeArea(); |
730 UpdateContentSettingsIcons(); | 741 UpdateContentSettingsIcons(); |
731 UpdatePageActions(); | 742 UpdatePageActions(); |
732 UpdateWebIntentsButton(); | 743 UpdateWebIntentsButton(); |
733 location_entry_->Update(contents); | 744 location_entry_->Update(contents); |
734 // The security level (background color) could have changed, etc. | 745 // The security level (background color) could have changed, etc. |
735 if (theme_service_->UsingNativeTheme()) { | 746 if (theme_service_->UsingNativeTheme()) { |
736 // In GTK mode, we need our parent to redraw, as it draws the text entry | 747 // In GTK mode, we need our parent to redraw, as it draws the text entry |
737 // border. | 748 // border. |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
832 } | 843 } |
833 | 844 |
834 void LocationBarViewGtk::CreateZoomButton() { | 845 void LocationBarViewGtk::CreateZoomButton() { |
835 zoom_.Own(CreateIconButton(&zoom_image_, | 846 zoom_.Own(CreateIconButton(&zoom_image_, |
836 0, | 847 0, |
837 VIEW_ID_ZOOM_BUTTON, | 848 VIEW_ID_ZOOM_BUTTON, |
838 0, | 849 0, |
839 OnZoomButtonPressThunk)); | 850 OnZoomButtonPressThunk)); |
840 } | 851 } |
841 | 852 |
| 853 void LocationBarViewGtk::CreateScriptBubbleButton() { |
| 854 script_bubble_button_.Own(CreateIconButton(&script_bubble_button_image_, |
| 855 0, |
| 856 VIEW_ID_SCRIPT_BUBBLE, |
| 857 IDS_TOOLTIP_SCRIPT_BUBBLE, |
| 858 OnScriptBubbleButtonPressThunk)); |
| 859 gtk_image_set_from_pixbuf( |
| 860 GTK_IMAGE(script_bubble_button_image_), |
| 861 theme_service_->GetImageNamed( |
| 862 IDR_EXTENSIONS_SCRIPT_BUBBLE).ToGdkPixbuf()); |
| 863 g_signal_connect_after(script_bubble_button_image_, "expose-event", |
| 864 G_CALLBACK(&OnScriptBubbleButtonExposeThunk), this); |
| 865 } |
| 866 |
842 void LocationBarViewGtk::CreateStarButton() { | 867 void LocationBarViewGtk::CreateStarButton() { |
843 star_.Own(CreateIconButton(&star_image_, | 868 star_.Own(CreateIconButton(&star_image_, |
844 0, | 869 0, |
845 VIEW_ID_STAR_BUTTON, | 870 VIEW_ID_STAR_BUTTON, |
846 IDS_TOOLTIP_STAR, | 871 IDS_TOOLTIP_STAR, |
847 OnStarButtonPressThunk)); | 872 OnStarButtonPressThunk)); |
848 // We need to track when the star button is resized to show any bubble | 873 // We need to track when the star button is resized to show any bubble |
849 // attached to it at this time. | 874 // attached to it at this time. |
850 g_signal_connect(star_image_, "size-allocate", | 875 g_signal_connect(star_image_, "size-allocate", |
851 G_CALLBACK(&OnStarButtonSizeAllocateThunk), this); | 876 G_CALLBACK(&OnStarButtonSizeAllocateThunk), this); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
943 toolbar_model_->GetInputInProgress() ? NULL : GetWebContents()); | 968 toolbar_model_->GetInputInProgress() ? NULL : GetWebContents()); |
944 any_visible = (*i)->IsVisible() || any_visible; | 969 any_visible = (*i)->IsVisible() || any_visible; |
945 } | 970 } |
946 | 971 |
947 // If there are no visible content things, hide the top level box so it | 972 // If there are no visible content things, hide the top level box so it |
948 // doesn't mess with padding. | 973 // doesn't mess with padding. |
949 gtk_widget_set_visible(content_setting_hbox_.get(), any_visible); | 974 gtk_widget_set_visible(content_setting_hbox_.get(), any_visible); |
950 } | 975 } |
951 | 976 |
952 void LocationBarViewGtk::UpdatePageActions() { | 977 void LocationBarViewGtk::UpdatePageActions() { |
| 978 UpdateScriptBubbleIcon(); |
| 979 |
953 std::vector<ExtensionAction*> new_page_actions; | 980 std::vector<ExtensionAction*> new_page_actions; |
954 | 981 |
955 WebContents* contents = GetWebContents(); | 982 WebContents* contents = GetWebContents(); |
956 if (contents) { | 983 if (contents) { |
957 LocationBarController* location_bar_controller = | 984 LocationBarController* location_bar_controller = |
958 extensions::TabHelper::FromWebContents(contents)-> | 985 extensions::TabHelper::FromWebContents(contents)-> |
959 location_bar_controller(); | 986 location_bar_controller(); |
960 new_page_actions = location_bar_controller->GetCurrentActions(); | 987 new_page_actions = location_bar_controller->GetCurrentActions(); |
961 } | 988 } |
962 | 989 |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1141 kTopMargin + kBorderThickness, | 1168 kTopMargin + kBorderThickness, |
1142 kBottomMargin + kBorderThickness, | 1169 kBottomMargin + kBorderThickness, |
1143 top_bottom, top_bottom); | 1170 top_bottom, top_bottom); |
1144 gtk_alignment_set_padding(GTK_ALIGNMENT(tab_to_search_alignment_), | 1171 gtk_alignment_set_padding(GTK_ALIGNMENT(tab_to_search_alignment_), |
1145 1, 1, 0, 0); | 1172 1, 1, 0, 0); |
1146 gtk_alignment_set_padding(GTK_ALIGNMENT(site_type_alignment_), | 1173 gtk_alignment_set_padding(GTK_ALIGNMENT(site_type_alignment_), |
1147 1, 1, 0, 0); | 1174 1, 1, 0, 0); |
1148 } | 1175 } |
1149 | 1176 |
1150 UpdateZoomIcon(); | 1177 UpdateZoomIcon(); |
| 1178 UpdateScriptBubbleIcon(); |
1151 UpdateStarIcon(); | 1179 UpdateStarIcon(); |
1152 UpdateSiteTypeArea(); | 1180 UpdateSiteTypeArea(); |
1153 UpdateContentSettingsIcons(); | 1181 UpdateContentSettingsIcons(); |
1154 UpdateWebIntentsButton(); | 1182 UpdateWebIntentsButton(); |
1155 break; | 1183 break; |
1156 } | 1184 } |
1157 | 1185 |
1158 default: | 1186 default: |
1159 NOTREACHED(); | 1187 NOTREACHED(); |
1160 } | 1188 } |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1493 GdkEventButton* event) { | 1521 GdkEventButton* event) { |
1494 if (event->button == 1 && GetWebContents()) { | 1522 if (event->button == 1 && GetWebContents()) { |
1495 // If the zoom icon is clicked, show the zoom bubble and keep it open until | 1523 // If the zoom icon is clicked, show the zoom bubble and keep it open until |
1496 // it loses focus. | 1524 // it loses focus. |
1497 ZoomBubbleGtk::Show(zoom_.get(), GetWebContents(), false); | 1525 ZoomBubbleGtk::Show(zoom_.get(), GetWebContents(), false); |
1498 return TRUE; | 1526 return TRUE; |
1499 } | 1527 } |
1500 return FALSE; | 1528 return FALSE; |
1501 } | 1529 } |
1502 | 1530 |
| 1531 gboolean LocationBarViewGtk::OnScriptBubbleButtonPress(GtkWidget* widget, |
| 1532 GdkEventButton* event) { |
| 1533 if (event->button == 1 && GetWebContents()) { |
| 1534 ScriptBubbleGtk::Show(script_bubble_button_image_, GetWebContents()); |
| 1535 return TRUE; |
| 1536 } |
| 1537 return FALSE; |
| 1538 } |
| 1539 |
| 1540 gboolean LocationBarViewGtk::OnScriptBubbleButtonExpose(GtkWidget* widget, |
| 1541 GdkEventExpose* event) { |
| 1542 gfx::CanvasSkiaPaint canvas(event, false); |
| 1543 GtkAllocation allocation; |
| 1544 gtk_widget_get_allocation(widget, &allocation); |
| 1545 badge_util::PaintBadge(&canvas, |
| 1546 gfx::Rect(allocation), |
| 1547 base::UintToString(num_running_scripts_), |
| 1548 SK_ColorWHITE, |
| 1549 SkColorSetRGB(0, 170, 0), |
| 1550 allocation.width, |
| 1551 Extension::ActionInfo::TYPE_PAGE); |
| 1552 return FALSE; |
| 1553 } |
| 1554 |
1503 void LocationBarViewGtk::OnStarButtonSizeAllocate(GtkWidget* sender, | 1555 void LocationBarViewGtk::OnStarButtonSizeAllocate(GtkWidget* sender, |
1504 GtkAllocation* allocation) { | 1556 GtkAllocation* allocation) { |
1505 if (!on_star_sized_.is_null()) { | 1557 if (!on_star_sized_.is_null()) { |
1506 on_star_sized_.Run(); | 1558 on_star_sized_.Run(); |
1507 on_star_sized_.Reset(); | 1559 on_star_sized_.Reset(); |
1508 } | 1560 } |
1509 star_sized_ = true; | 1561 star_sized_ = true; |
1510 } | 1562 } |
1511 | 1563 |
1512 gboolean LocationBarViewGtk::OnStarButtonPress(GtkWidget* widget, | 1564 gboolean LocationBarViewGtk::OnStarButtonPress(GtkWidget* widget, |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1577 gtk_image_set_from_pixbuf(GTK_IMAGE(zoom_image_), | 1629 gtk_image_set_from_pixbuf(GTK_IMAGE(zoom_image_), |
1578 theme_service_->GetImageNamed(zoom_resource).ToGdkPixbuf()); | 1630 theme_service_->GetImageNamed(zoom_resource).ToGdkPixbuf()); |
1579 | 1631 |
1580 string16 tooltip = l10n_util::GetStringFUTF16Int( | 1632 string16 tooltip = l10n_util::GetStringFUTF16Int( |
1581 IDS_TOOLTIP_ZOOM, zoom_controller->zoom_percent()); | 1633 IDS_TOOLTIP_ZOOM, zoom_controller->zoom_percent()); |
1582 gtk_widget_set_tooltip_text(zoom_.get(), UTF16ToUTF8(tooltip).c_str()); | 1634 gtk_widget_set_tooltip_text(zoom_.get(), UTF16ToUTF8(tooltip).c_str()); |
1583 | 1635 |
1584 gtk_widget_show(zoom_.get()); | 1636 gtk_widget_show(zoom_.get()); |
1585 } | 1637 } |
1586 | 1638 |
| 1639 void LocationBarViewGtk::UpdateScriptBubbleIcon() { |
| 1640 num_running_scripts_ = 0; |
| 1641 if (GetWebContents()) { |
| 1642 extensions::TabHelper* tab_helper = |
| 1643 extensions::TabHelper::FromWebContents(GetWebContents()); |
| 1644 if (tab_helper && tab_helper->script_bubble_controller()) { |
| 1645 num_running_scripts_ = tab_helper->script_bubble_controller()-> |
| 1646 extensions_running_scripts().size(); |
| 1647 } |
| 1648 } |
| 1649 |
| 1650 if (num_running_scripts_ == 0u) |
| 1651 gtk_widget_hide(script_bubble_button_.get()); |
| 1652 else |
| 1653 gtk_widget_show(script_bubble_button_.get()); |
| 1654 } |
| 1655 |
1587 void LocationBarViewGtk::UpdateStarIcon() { | 1656 void LocationBarViewGtk::UpdateStarIcon() { |
1588 if (!star_.get()) | 1657 if (!star_.get()) |
1589 return; | 1658 return; |
1590 // Indicate the star icon is not correctly sized. It will be marked as sized | 1659 // Indicate the star icon is not correctly sized. It will be marked as sized |
1591 // when the next size-allocate signal is received by the star widget. | 1660 // when the next size-allocate signal is received by the star widget. |
1592 star_sized_ = false; | 1661 star_sized_ = false; |
1593 bool star_enabled = !toolbar_model_->GetInputInProgress() && | 1662 bool star_enabled = !toolbar_model_->GetInputInProgress() && |
1594 edit_bookmarks_enabled_.GetValue(); | 1663 edit_bookmarks_enabled_.GetValue(); |
1595 command_updater_->UpdateCommandEnabled(IDC_BOOKMARK_PAGE, star_enabled); | 1664 command_updater_->UpdateCommandEnabled(IDC_BOOKMARK_PAGE, star_enabled); |
1596 if (extensions::FeatureSwitch::action_box()->IsEnabled() && !starred_) { | 1665 if (extensions::FeatureSwitch::action_box()->IsEnabled() && !starred_) { |
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2114 } | 2183 } |
2115 | 2184 |
2116 void LocationBarViewGtk::PageActionViewGtk::InspectPopup( | 2185 void LocationBarViewGtk::PageActionViewGtk::InspectPopup( |
2117 ExtensionAction* action) { | 2186 ExtensionAction* action) { |
2118 ExtensionPopupGtk::Show( | 2187 ExtensionPopupGtk::Show( |
2119 action->GetPopupUrl(current_tab_id_), | 2188 action->GetPopupUrl(current_tab_id_), |
2120 owner_->browser_, | 2189 owner_->browser_, |
2121 event_box_.get(), | 2190 event_box_.get(), |
2122 ExtensionPopupGtk::SHOW_AND_INSPECT); | 2191 ExtensionPopupGtk::SHOW_AND_INSPECT); |
2123 } | 2192 } |
OLD | NEW |