| 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/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 842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 853 // We need to track when the star button is resized to show any bubble | 853 // We need to track when the star button is resized to show any bubble |
| 854 // attached to it at this time. | 854 // attached to it at this time. |
| 855 g_signal_connect(star_image_, "size-allocate", | 855 g_signal_connect(star_image_, "size-allocate", |
| 856 G_CALLBACK(&OnStarButtonSizeAllocateThunk), this); | 856 G_CALLBACK(&OnStarButtonSizeAllocateThunk), this); |
| 857 } | 857 } |
| 858 | 858 |
| 859 void LocationBarViewGtk::OnInputInProgress(bool in_progress) { | 859 void LocationBarViewGtk::OnInputInProgress(bool in_progress) { |
| 860 // This is identical to the Windows code, except that we don't proxy the call | 860 // This is identical to the Windows code, except that we don't proxy the call |
| 861 // back through the Toolbar, and just access the model here. | 861 // back through the Toolbar, and just access the model here. |
| 862 // The edit should make sure we're only notified when something changes. | 862 // The edit should make sure we're only notified when something changes. |
| 863 DCHECK(toolbar_model_->input_in_progress() != in_progress); | 863 DCHECK(toolbar_model_->GetInputInProgress() != in_progress); |
| 864 | 864 |
| 865 toolbar_model_->set_input_in_progress(in_progress); | 865 toolbar_model_->SetInputInProgress(in_progress); |
| 866 Update(NULL); | 866 Update(NULL); |
| 867 } | 867 } |
| 868 | 868 |
| 869 void LocationBarViewGtk::OnKillFocus() { | 869 void LocationBarViewGtk::OnKillFocus() { |
| 870 } | 870 } |
| 871 | 871 |
| 872 void LocationBarViewGtk::OnSetFocus() { | 872 void LocationBarViewGtk::OnSetFocus() { |
| 873 Profile* profile = browser_->profile(); | 873 Profile* profile = browser_->profile(); |
| 874 AccessibilityTextBoxInfo info( | 874 AccessibilityTextBoxInfo info( |
| 875 profile, | 875 profile, |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 941 location_entry_->SetFocus(); | 941 location_entry_->SetFocus(); |
| 942 location_entry_->SetForcedQuery(); | 942 location_entry_->SetForcedQuery(); |
| 943 } | 943 } |
| 944 | 944 |
| 945 void LocationBarViewGtk::UpdateContentSettingsIcons() { | 945 void LocationBarViewGtk::UpdateContentSettingsIcons() { |
| 946 bool any_visible = false; | 946 bool any_visible = false; |
| 947 for (ScopedVector<PageToolViewGtk>::iterator i( | 947 for (ScopedVector<PageToolViewGtk>::iterator i( |
| 948 content_setting_views_.begin()); | 948 content_setting_views_.begin()); |
| 949 i != content_setting_views_.end(); ++i) { | 949 i != content_setting_views_.end(); ++i) { |
| 950 (*i)->Update( | 950 (*i)->Update( |
| 951 toolbar_model_->input_in_progress() ? NULL : GetTabContents()); | 951 toolbar_model_->GetInputInProgress() ? NULL : GetTabContents()); |
| 952 any_visible = (*i)->IsVisible() || any_visible; | 952 any_visible = (*i)->IsVisible() || any_visible; |
| 953 } | 953 } |
| 954 | 954 |
| 955 // If there are no visible content things, hide the top level box so it | 955 // If there are no visible content things, hide the top level box so it |
| 956 // doesn't mess with padding. | 956 // doesn't mess with padding. |
| 957 gtk_widget_set_visible(content_setting_hbox_.get(), any_visible); | 957 gtk_widget_set_visible(content_setting_hbox_.get(), any_visible); |
| 958 } | 958 } |
| 959 | 959 |
| 960 void LocationBarViewGtk::UpdatePageActions() { | 960 void LocationBarViewGtk::UpdatePageActions() { |
| 961 std::vector<ExtensionAction*> new_page_actions; | 961 std::vector<ExtensionAction*> new_page_actions; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 984 chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_COUNT_CHANGED, | 984 chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_COUNT_CHANGED, |
| 985 content::Source<LocationBar>(this), | 985 content::Source<LocationBar>(this), |
| 986 content::NotificationService::NoDetails()); | 986 content::NotificationService::NoDetails()); |
| 987 } | 987 } |
| 988 | 988 |
| 989 if (!page_action_views_.empty() && contents) { | 989 if (!page_action_views_.empty() && contents) { |
| 990 GURL url = chrome::GetActiveWebContents(browser())->GetURL(); | 990 GURL url = chrome::GetActiveWebContents(browser())->GetURL(); |
| 991 | 991 |
| 992 for (size_t i = 0; i < page_action_views_.size(); i++) { | 992 for (size_t i = 0; i < page_action_views_.size(); i++) { |
| 993 page_action_views_[i]->UpdateVisibility( | 993 page_action_views_[i]->UpdateVisibility( |
| 994 toolbar_model_->input_in_progress() ? NULL : contents, url); | 994 toolbar_model_->GetInputInProgress() ? NULL : contents, url); |
| 995 } | 995 } |
| 996 gtk_widget_queue_draw(hbox_.get()); | 996 gtk_widget_queue_draw(hbox_.get()); |
| 997 } | 997 } |
| 998 | 998 |
| 999 // If there are no visible page actions, hide the hbox too, so that it does | 999 // If there are no visible page actions, hide the hbox too, so that it does |
| 1000 // not affect the padding in the location bar. | 1000 // not affect the padding in the location bar. |
| 1001 gtk_widget_set_visible(page_action_hbox_.get(), | 1001 gtk_widget_set_visible(page_action_hbox_.get(), |
| 1002 PageActionVisibleCount() && !ShouldOnlyShowLocation()); | 1002 PageActionVisibleCount() && !ShouldOnlyShowLocation()); |
| 1003 } | 1003 } |
| 1004 | 1004 |
| (...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1529 gboolean LocationBarViewGtk::OnStarButtonPress(GtkWidget* widget, | 1529 gboolean LocationBarViewGtk::OnStarButtonPress(GtkWidget* widget, |
| 1530 GdkEventButton* event) { | 1530 GdkEventButton* event) { |
| 1531 if (event->button == 1) { | 1531 if (event->button == 1) { |
| 1532 chrome::ExecuteCommand(browser_, IDC_BOOKMARK_PAGE); | 1532 chrome::ExecuteCommand(browser_, IDC_BOOKMARK_PAGE); |
| 1533 return TRUE; | 1533 return TRUE; |
| 1534 } | 1534 } |
| 1535 return FALSE; | 1535 return FALSE; |
| 1536 } | 1536 } |
| 1537 | 1537 |
| 1538 void LocationBarViewGtk::ShowZoomBubble() { | 1538 void LocationBarViewGtk::ShowZoomBubble() { |
| 1539 if (!zoom_.get() || toolbar_model_->input_in_progress()) | 1539 if (!zoom_.get() || toolbar_model_->GetInputInProgress()) |
| 1540 return; | 1540 return; |
| 1541 | 1541 |
| 1542 ZoomBubbleGtk::Show(zoom_.get(), GetTabContents(), true); | 1542 ZoomBubbleGtk::Show(zoom_.get(), GetTabContents(), true); |
| 1543 } | 1543 } |
| 1544 | 1544 |
| 1545 void LocationBarViewGtk::ShowStarBubble(const GURL& url, | 1545 void LocationBarViewGtk::ShowStarBubble(const GURL& url, |
| 1546 bool newly_bookmarked) { | 1546 bool newly_bookmarked) { |
| 1547 if (!star_.get()) | 1547 if (!star_.get()) |
| 1548 return; | 1548 return; |
| 1549 | 1549 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1577 } | 1577 } |
| 1578 | 1578 |
| 1579 void LocationBarViewGtk::UpdateZoomIcon() { | 1579 void LocationBarViewGtk::UpdateZoomIcon() { |
| 1580 TabContents* tab_contents = GetTabContents(); | 1580 TabContents* tab_contents = GetTabContents(); |
| 1581 if (!zoom_.get() || !tab_contents) | 1581 if (!zoom_.get() || !tab_contents) |
| 1582 return; | 1582 return; |
| 1583 | 1583 |
| 1584 ZoomController* zoom_controller = | 1584 ZoomController* zoom_controller = |
| 1585 ZoomController::FromWebContents(tab_contents->web_contents()); | 1585 ZoomController::FromWebContents(tab_contents->web_contents()); |
| 1586 if (!zoom_controller || zoom_controller->IsAtDefaultZoom() || | 1586 if (!zoom_controller || zoom_controller->IsAtDefaultZoom() || |
| 1587 toolbar_model_->input_in_progress()) { | 1587 toolbar_model_->GetInputInProgress()) { |
| 1588 gtk_widget_hide(zoom_.get()); | 1588 gtk_widget_hide(zoom_.get()); |
| 1589 ZoomBubbleGtk::Close(); | 1589 ZoomBubbleGtk::Close(); |
| 1590 return; | 1590 return; |
| 1591 } | 1591 } |
| 1592 | 1592 |
| 1593 const int zoom_resource = zoom_controller->GetResourceForZoomLevel(); | 1593 const int zoom_resource = zoom_controller->GetResourceForZoomLevel(); |
| 1594 gtk_image_set_from_pixbuf(GTK_IMAGE(zoom_image_), | 1594 gtk_image_set_from_pixbuf(GTK_IMAGE(zoom_image_), |
| 1595 theme_service_->GetImageNamed(zoom_resource).ToGdkPixbuf()); | 1595 theme_service_->GetImageNamed(zoom_resource).ToGdkPixbuf()); |
| 1596 | 1596 |
| 1597 string16 tooltip = l10n_util::GetStringFUTF16Int( | 1597 string16 tooltip = l10n_util::GetStringFUTF16Int( |
| 1598 IDS_TOOLTIP_ZOOM, zoom_controller->zoom_percent()); | 1598 IDS_TOOLTIP_ZOOM, zoom_controller->zoom_percent()); |
| 1599 gtk_widget_set_tooltip_text(zoom_.get(), UTF16ToUTF8(tooltip).c_str()); | 1599 gtk_widget_set_tooltip_text(zoom_.get(), UTF16ToUTF8(tooltip).c_str()); |
| 1600 | 1600 |
| 1601 gtk_widget_show(zoom_.get()); | 1601 gtk_widget_show(zoom_.get()); |
| 1602 } | 1602 } |
| 1603 | 1603 |
| 1604 void LocationBarViewGtk::UpdateStarIcon() { | 1604 void LocationBarViewGtk::UpdateStarIcon() { |
| 1605 if (!star_.get()) | 1605 if (!star_.get()) |
| 1606 return; | 1606 return; |
| 1607 // Indicate the star icon is not correctly sized. It will be marked as sized | 1607 // Indicate the star icon is not correctly sized. It will be marked as sized |
| 1608 // when the next size-allocate signal is received by the star widget. | 1608 // when the next size-allocate signal is received by the star widget. |
| 1609 star_sized_ = false; | 1609 star_sized_ = false; |
| 1610 bool star_enabled = !toolbar_model_->input_in_progress() && | 1610 bool star_enabled = !toolbar_model_->GetInputInProgress() && |
| 1611 edit_bookmarks_enabled_.GetValue(); | 1611 edit_bookmarks_enabled_.GetValue(); |
| 1612 command_updater_->UpdateCommandEnabled(IDC_BOOKMARK_PAGE, star_enabled); | 1612 command_updater_->UpdateCommandEnabled(IDC_BOOKMARK_PAGE, star_enabled); |
| 1613 if (extensions::switch_utils::IsActionBoxEnabled() && !starred_) { | 1613 if (extensions::switch_utils::IsActionBoxEnabled() && !starred_) { |
| 1614 star_enabled = false; | 1614 star_enabled = false; |
| 1615 } | 1615 } |
| 1616 if (star_enabled) { | 1616 if (star_enabled) { |
| 1617 gtk_widget_show_all(star_.get()); | 1617 gtk_widget_show_all(star_.get()); |
| 1618 int id = starred_ ? IDR_STAR_LIT : IDR_STAR; | 1618 int id = starred_ ? IDR_STAR_LIT : IDR_STAR; |
| 1619 gtk_image_set_from_pixbuf(GTK_IMAGE(star_image_), | 1619 gtk_image_set_from_pixbuf(GTK_IMAGE(star_image_), |
| 1620 theme_service_->GetImageNamed(id).ToGdkPixbuf()); | 1620 theme_service_->GetImageNamed(id).ToGdkPixbuf()); |
| 1621 } else { | 1621 } else { |
| 1622 gtk_widget_hide_all(star_.get()); | 1622 gtk_widget_hide_all(star_.get()); |
| 1623 } | 1623 } |
| 1624 } | 1624 } |
| 1625 | 1625 |
| 1626 void LocationBarViewGtk::UpdateChromeToMobileState() { | 1626 void LocationBarViewGtk::UpdateChromeToMobileState() { |
| 1627 ChromeToMobileService* service = | 1627 ChromeToMobileService* service = |
| 1628 ChromeToMobileServiceFactory::GetForProfile(browser()->profile()); | 1628 ChromeToMobileServiceFactory::GetForProfile(browser()->profile()); |
| 1629 command_updater_->UpdateCommandEnabled(IDC_CHROME_TO_MOBILE_PAGE, | 1629 command_updater_->UpdateCommandEnabled(IDC_CHROME_TO_MOBILE_PAGE, |
| 1630 !toolbar_model_->input_in_progress() && service && service->HasMobiles()); | 1630 !toolbar_model_->GetInputInProgress() && |
| 1631 service && service->HasMobiles()); |
| 1631 } | 1632 } |
| 1632 | 1633 |
| 1633 bool LocationBarViewGtk::ShouldOnlyShowLocation() { | 1634 bool LocationBarViewGtk::ShouldOnlyShowLocation() { |
| 1634 return !browser_->is_type_tabbed(); | 1635 return !browser_->is_type_tabbed(); |
| 1635 } | 1636 } |
| 1636 | 1637 |
| 1637 void LocationBarViewGtk::AdjustChildrenVisibility() { | 1638 void LocationBarViewGtk::AdjustChildrenVisibility() { |
| 1638 int text_width = location_entry_->TextWidth(); | 1639 int text_width = location_entry_->TextWidth(); |
| 1639 int available_width = entry_box_width_ - text_width - InnerPadding(); | 1640 int available_width = entry_box_width_ - text_width - InnerPadding(); |
| 1640 | 1641 |
| (...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2146 } | 2147 } |
| 2147 | 2148 |
| 2148 void LocationBarViewGtk::PageActionViewGtk::InspectPopup( | 2149 void LocationBarViewGtk::PageActionViewGtk::InspectPopup( |
| 2149 ExtensionAction* action) { | 2150 ExtensionAction* action) { |
| 2150 ExtensionPopupGtk::Show( | 2151 ExtensionPopupGtk::Show( |
| 2151 action->GetPopupUrl(current_tab_id_), | 2152 action->GetPopupUrl(current_tab_id_), |
| 2152 owner_->browser_, | 2153 owner_->browser_, |
| 2153 event_box_.get(), | 2154 event_box_.get(), |
| 2154 ExtensionPopupGtk::SHOW_AND_INSPECT); | 2155 ExtensionPopupGtk::SHOW_AND_INSPECT); |
| 2155 } | 2156 } |
| OLD | NEW |