| 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 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 732 if (tab_contents) { | 732 if (tab_contents) { |
| 733 LocationBarController* location_bar_controller = | 733 LocationBarController* location_bar_controller = |
| 734 tab_contents->extension_tab_helper()->location_bar_controller(); | 734 tab_contents->extension_tab_helper()->location_bar_controller(); |
| 735 new_page_actions = location_bar_controller->GetCurrentActions(); | 735 new_page_actions = location_bar_controller->GetCurrentActions(); |
| 736 } | 736 } |
| 737 | 737 |
| 738 // Initialize on the first call, or re-initialize if more extensions have been | 738 // Initialize on the first call, or re-initialize if more extensions have been |
| 739 // loaded or added after startup. | 739 // loaded or added after startup. |
| 740 if (new_page_actions != page_actions_) { | 740 if (new_page_actions != page_actions_) { |
| 741 page_actions_.swap(new_page_actions); | 741 page_actions_.swap(new_page_actions); |
| 742 page_action_views_.reset(); | 742 page_action_views_.clear(); |
| 743 | 743 |
| 744 for (size_t i = 0; i < page_actions_.size(); ++i) { | 744 for (size_t i = 0; i < page_actions_.size(); ++i) { |
| 745 page_action_views_.push_back( | 745 page_action_views_.push_back( |
| 746 new PageActionViewGtk(this, page_actions_[i])); | 746 new PageActionViewGtk(this, page_actions_[i])); |
| 747 gtk_box_pack_end(GTK_BOX(page_action_hbox_.get()), | 747 gtk_box_pack_end(GTK_BOX(page_action_hbox_.get()), |
| 748 page_action_views_[i]->widget(), FALSE, FALSE, 0); | 748 page_action_views_[i]->widget(), FALSE, FALSE, 0); |
| 749 } | 749 } |
| 750 content::NotificationService::current()->Notify( | 750 content::NotificationService::current()->Notify( |
| 751 chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_COUNT_CHANGED, | 751 chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_COUNT_CHANGED, |
| 752 content::Source<LocationBar>(this), | 752 content::Source<LocationBar>(this), |
| (...skipping 11 matching lines...) Expand all Loading... |
| 764 } | 764 } |
| 765 | 765 |
| 766 // If there are no visible page actions, hide the hbox too, so that it does | 766 // If there are no visible page actions, hide the hbox too, so that it does |
| 767 // not affect the padding in the location bar. | 767 // not affect the padding in the location bar. |
| 768 gtk_widget_set_visible(page_action_hbox_.get(), | 768 gtk_widget_set_visible(page_action_hbox_.get(), |
| 769 PageActionVisibleCount() && !ShouldOnlyShowLocation()); | 769 PageActionVisibleCount() && !ShouldOnlyShowLocation()); |
| 770 } | 770 } |
| 771 | 771 |
| 772 void LocationBarViewGtk::InvalidatePageActions() { | 772 void LocationBarViewGtk::InvalidatePageActions() { |
| 773 size_t count_before = page_action_views_.size(); | 773 size_t count_before = page_action_views_.size(); |
| 774 page_action_views_.reset(); | 774 page_action_views_.clear(); |
| 775 if (page_action_views_.size() != count_before) { | 775 if (page_action_views_.size() != count_before) { |
| 776 content::NotificationService::current()->Notify( | 776 content::NotificationService::current()->Notify( |
| 777 chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_COUNT_CHANGED, | 777 chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_COUNT_CHANGED, |
| 778 content::Source<LocationBar>(this), | 778 content::Source<LocationBar>(this), |
| 779 content::NotificationService::NoDetails()); | 779 content::NotificationService::NoDetails()); |
| 780 } | 780 } |
| 781 } | 781 } |
| 782 | 782 |
| 783 void LocationBarViewGtk::SaveStateToContents(WebContents* contents) { | 783 void LocationBarViewGtk::SaveStateToContents(WebContents* contents) { |
| 784 location_entry_->SaveStateToTab(contents); | 784 location_entry_->SaveStateToTab(contents); |
| (...skipping 1188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1973 } | 1973 } |
| 1974 | 1974 |
| 1975 void LocationBarViewGtk::PageActionViewGtk::InspectPopup( | 1975 void LocationBarViewGtk::PageActionViewGtk::InspectPopup( |
| 1976 ExtensionAction* action) { | 1976 ExtensionAction* action) { |
| 1977 ExtensionPopupGtk::Show( | 1977 ExtensionPopupGtk::Show( |
| 1978 action->GetPopupUrl(current_tab_id_), | 1978 action->GetPopupUrl(current_tab_id_), |
| 1979 owner_->browser_, | 1979 owner_->browser_, |
| 1980 event_box_.get(), | 1980 event_box_.get(), |
| 1981 ExtensionPopupGtk::SHOW_AND_INSPECT); | 1981 ExtensionPopupGtk::SHOW_AND_INSPECT); |
| 1982 } | 1982 } |
| OLD | NEW |