| 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(IDR_EXTENSIONS_FAVICON).ToGdkPixbuf()); |
| 862 g_signal_connect_after(script_bubble_button_image_, "expose-event", |
| 863 G_CALLBACK(&OnScriptBubbleButtonExposeThunk), this); |
| 864 } |
| 865 |
| 842 void LocationBarViewGtk::CreateStarButton() { | 866 void LocationBarViewGtk::CreateStarButton() { |
| 843 star_.Own(CreateIconButton(&star_image_, | 867 star_.Own(CreateIconButton(&star_image_, |
| 844 0, | 868 0, |
| 845 VIEW_ID_STAR_BUTTON, | 869 VIEW_ID_STAR_BUTTON, |
| 846 IDS_TOOLTIP_STAR, | 870 IDS_TOOLTIP_STAR, |
| 847 OnStarButtonPressThunk)); | 871 OnStarButtonPressThunk)); |
| 848 // We need to track when the star button is resized to show any bubble | 872 // We need to track when the star button is resized to show any bubble |
| 849 // attached to it at this time. | 873 // attached to it at this time. |
| 850 g_signal_connect(star_image_, "size-allocate", | 874 g_signal_connect(star_image_, "size-allocate", |
| 851 G_CALLBACK(&OnStarButtonSizeAllocateThunk), this); | 875 G_CALLBACK(&OnStarButtonSizeAllocateThunk), this); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 943 toolbar_model_->GetInputInProgress() ? NULL : GetWebContents()); | 967 toolbar_model_->GetInputInProgress() ? NULL : GetWebContents()); |
| 944 any_visible = (*i)->IsVisible() || any_visible; | 968 any_visible = (*i)->IsVisible() || any_visible; |
| 945 } | 969 } |
| 946 | 970 |
| 947 // If there are no visible content things, hide the top level box so it | 971 // If there are no visible content things, hide the top level box so it |
| 948 // doesn't mess with padding. | 972 // doesn't mess with padding. |
| 949 gtk_widget_set_visible(content_setting_hbox_.get(), any_visible); | 973 gtk_widget_set_visible(content_setting_hbox_.get(), any_visible); |
| 950 } | 974 } |
| 951 | 975 |
| 952 void LocationBarViewGtk::UpdatePageActions() { | 976 void LocationBarViewGtk::UpdatePageActions() { |
| 977 UpdateScriptBubbleIcon(); |
| 978 |
| 953 std::vector<ExtensionAction*> new_page_actions; | 979 std::vector<ExtensionAction*> new_page_actions; |
| 954 | 980 |
| 955 WebContents* contents = GetWebContents(); | 981 WebContents* contents = GetWebContents(); |
| 956 if (contents) { | 982 if (contents) { |
| 957 LocationBarController* location_bar_controller = | 983 LocationBarController* location_bar_controller = |
| 958 extensions::TabHelper::FromWebContents(contents)-> | 984 extensions::TabHelper::FromWebContents(contents)-> |
| 959 location_bar_controller(); | 985 location_bar_controller(); |
| 960 new_page_actions = location_bar_controller->GetCurrentActions(); | 986 new_page_actions = location_bar_controller->GetCurrentActions(); |
| 961 } | 987 } |
| 962 | 988 |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1141 kTopMargin + kBorderThickness, | 1167 kTopMargin + kBorderThickness, |
| 1142 kBottomMargin + kBorderThickness, | 1168 kBottomMargin + kBorderThickness, |
| 1143 top_bottom, top_bottom); | 1169 top_bottom, top_bottom); |
| 1144 gtk_alignment_set_padding(GTK_ALIGNMENT(tab_to_search_alignment_), | 1170 gtk_alignment_set_padding(GTK_ALIGNMENT(tab_to_search_alignment_), |
| 1145 1, 1, 0, 0); | 1171 1, 1, 0, 0); |
| 1146 gtk_alignment_set_padding(GTK_ALIGNMENT(site_type_alignment_), | 1172 gtk_alignment_set_padding(GTK_ALIGNMENT(site_type_alignment_), |
| 1147 1, 1, 0, 0); | 1173 1, 1, 0, 0); |
| 1148 } | 1174 } |
| 1149 | 1175 |
| 1150 UpdateZoomIcon(); | 1176 UpdateZoomIcon(); |
| 1177 UpdateScriptBubbleIcon(); |
| 1151 UpdateStarIcon(); | 1178 UpdateStarIcon(); |
| 1152 UpdateSiteTypeArea(); | 1179 UpdateSiteTypeArea(); |
| 1153 UpdateContentSettingsIcons(); | 1180 UpdateContentSettingsIcons(); |
| 1154 UpdateWebIntentsButton(); | 1181 UpdateWebIntentsButton(); |
| 1155 break; | 1182 break; |
| 1156 } | 1183 } |
| 1157 | 1184 |
| 1158 default: | 1185 default: |
| 1159 NOTREACHED(); | 1186 NOTREACHED(); |
| 1160 } | 1187 } |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1493 GdkEventButton* event) { | 1520 GdkEventButton* event) { |
| 1494 if (event->button == 1 && GetWebContents()) { | 1521 if (event->button == 1 && GetWebContents()) { |
| 1495 // If the zoom icon is clicked, show the zoom bubble and keep it open until | 1522 // If the zoom icon is clicked, show the zoom bubble and keep it open until |
| 1496 // it loses focus. | 1523 // it loses focus. |
| 1497 ZoomBubbleGtk::Show(zoom_.get(), GetWebContents(), false); | 1524 ZoomBubbleGtk::Show(zoom_.get(), GetWebContents(), false); |
| 1498 return TRUE; | 1525 return TRUE; |
| 1499 } | 1526 } |
| 1500 return FALSE; | 1527 return FALSE; |
| 1501 } | 1528 } |
| 1502 | 1529 |
| 1530 gboolean LocationBarViewGtk::OnScriptBubbleButtonPress(GtkWidget* widget, |
| 1531 GdkEventButton* event) { |
| 1532 if (event->button == 1 && GetWebContents()) { |
| 1533 ScriptBubbleGtk::Show(script_bubble_button_image_, GetWebContents()); |
| 1534 return TRUE; |
| 1535 } |
| 1536 return FALSE; |
| 1537 } |
| 1538 |
| 1539 gboolean LocationBarViewGtk::OnScriptBubbleButtonExpose(GtkWidget* widget, |
| 1540 GdkEventExpose* event) { |
| 1541 gfx::CanvasSkiaPaint canvas(event, false); |
| 1542 GtkAllocation allocation; |
| 1543 gtk_widget_get_allocation(widget, &allocation); |
| 1544 badge_util::PaintBadge(&canvas, |
| 1545 gfx::Rect(allocation), |
| 1546 base::UintToString(num_running_scripts_), |
| 1547 SK_ColorWHITE, |
| 1548 SkColorSetRGB(0, 170, 0), |
| 1549 allocation.width, |
| 1550 Extension::ActionInfo::TYPE_PAGE); |
| 1551 return FALSE; |
| 1552 } |
| 1553 |
| 1503 void LocationBarViewGtk::OnStarButtonSizeAllocate(GtkWidget* sender, | 1554 void LocationBarViewGtk::OnStarButtonSizeAllocate(GtkWidget* sender, |
| 1504 GtkAllocation* allocation) { | 1555 GtkAllocation* allocation) { |
| 1505 if (!on_star_sized_.is_null()) { | 1556 if (!on_star_sized_.is_null()) { |
| 1506 on_star_sized_.Run(); | 1557 on_star_sized_.Run(); |
| 1507 on_star_sized_.Reset(); | 1558 on_star_sized_.Reset(); |
| 1508 } | 1559 } |
| 1509 star_sized_ = true; | 1560 star_sized_ = true; |
| 1510 } | 1561 } |
| 1511 | 1562 |
| 1512 gboolean LocationBarViewGtk::OnStarButtonPress(GtkWidget* widget, | 1563 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_), | 1628 gtk_image_set_from_pixbuf(GTK_IMAGE(zoom_image_), |
| 1578 theme_service_->GetImageNamed(zoom_resource).ToGdkPixbuf()); | 1629 theme_service_->GetImageNamed(zoom_resource).ToGdkPixbuf()); |
| 1579 | 1630 |
| 1580 string16 tooltip = l10n_util::GetStringFUTF16Int( | 1631 string16 tooltip = l10n_util::GetStringFUTF16Int( |
| 1581 IDS_TOOLTIP_ZOOM, zoom_controller->zoom_percent()); | 1632 IDS_TOOLTIP_ZOOM, zoom_controller->zoom_percent()); |
| 1582 gtk_widget_set_tooltip_text(zoom_.get(), UTF16ToUTF8(tooltip).c_str()); | 1633 gtk_widget_set_tooltip_text(zoom_.get(), UTF16ToUTF8(tooltip).c_str()); |
| 1583 | 1634 |
| 1584 gtk_widget_show(zoom_.get()); | 1635 gtk_widget_show(zoom_.get()); |
| 1585 } | 1636 } |
| 1586 | 1637 |
| 1638 void LocationBarViewGtk::UpdateScriptBubbleIcon() { |
| 1639 num_running_scripts_ = 0; |
| 1640 if (GetWebContents()) { |
| 1641 extensions::TabHelper* tab_helper = |
| 1642 extensions::TabHelper::FromWebContents(GetWebContents()); |
| 1643 if (tab_helper && tab_helper->script_bubble_controller()) { |
| 1644 num_running_scripts_ = tab_helper->script_bubble_controller()-> |
| 1645 extensions_running_scripts().size(); |
| 1646 } |
| 1647 } |
| 1648 |
| 1649 if (num_running_scripts_ == 0u) |
| 1650 gtk_widget_hide(script_bubble_button_.get()); |
| 1651 else |
| 1652 gtk_widget_show(script_bubble_button_.get()); |
| 1653 } |
| 1654 |
| 1587 void LocationBarViewGtk::UpdateStarIcon() { | 1655 void LocationBarViewGtk::UpdateStarIcon() { |
| 1588 if (!star_.get()) | 1656 if (!star_.get()) |
| 1589 return; | 1657 return; |
| 1590 // Indicate the star icon is not correctly sized. It will be marked as sized | 1658 // 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. | 1659 // when the next size-allocate signal is received by the star widget. |
| 1592 star_sized_ = false; | 1660 star_sized_ = false; |
| 1593 bool star_enabled = !toolbar_model_->GetInputInProgress() && | 1661 bool star_enabled = !toolbar_model_->GetInputInProgress() && |
| 1594 edit_bookmarks_enabled_.GetValue(); | 1662 edit_bookmarks_enabled_.GetValue(); |
| 1595 command_updater_->UpdateCommandEnabled(IDC_BOOKMARK_PAGE, star_enabled); | 1663 command_updater_->UpdateCommandEnabled(IDC_BOOKMARK_PAGE, star_enabled); |
| 1596 if (extensions::FeatureSwitch::action_box()->IsEnabled() && !starred_) { | 1664 if (extensions::FeatureSwitch::action_box()->IsEnabled() && !starred_) { |
| (...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2114 } | 2182 } |
| 2115 | 2183 |
| 2116 void LocationBarViewGtk::PageActionViewGtk::InspectPopup( | 2184 void LocationBarViewGtk::PageActionViewGtk::InspectPopup( |
| 2117 ExtensionAction* action) { | 2185 ExtensionAction* action) { |
| 2118 ExtensionPopupGtk::Show( | 2186 ExtensionPopupGtk::Show( |
| 2119 action->GetPopupUrl(current_tab_id_), | 2187 action->GetPopupUrl(current_tab_id_), |
| 2120 owner_->browser_, | 2188 owner_->browser_, |
| 2121 event_box_.get(), | 2189 event_box_.get(), |
| 2122 ExtensionPopupGtk::SHOW_AND_INSPECT); | 2190 ExtensionPopupGtk::SHOW_AND_INSPECT); |
| 2123 } | 2191 } |
| OLD | NEW |