| 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 938 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 949 } | 949 } |
| 950 | 950 |
| 951 // If there are no visible content things, hide the top level box so it | 951 // If there are no visible content things, hide the top level box so it |
| 952 // doesn't mess with padding. | 952 // doesn't mess with padding. |
| 953 gtk_widget_set_visible(content_setting_hbox_.get(), any_visible); | 953 gtk_widget_set_visible(content_setting_hbox_.get(), any_visible); |
| 954 } | 954 } |
| 955 | 955 |
| 956 void LocationBarViewGtk::UpdatePageActions() { | 956 void LocationBarViewGtk::UpdatePageActions() { |
| 957 std::vector<ExtensionAction*> new_page_actions; | 957 std::vector<ExtensionAction*> new_page_actions; |
| 958 | 958 |
| 959 TabContents* tab_contents = GetTabContents(); | 959 WebContents* contents = GetWebContents(); |
| 960 if (tab_contents) { | 960 if (contents) { |
| 961 LocationBarController* location_bar_controller = | 961 LocationBarController* location_bar_controller = |
| 962 tab_contents->extension_tab_helper()->location_bar_controller(); | 962 extensions::TabHelper::FromWebContents(contents)-> |
| 963 location_bar_controller(); |
| 963 new_page_actions = location_bar_controller->GetCurrentActions(); | 964 new_page_actions = location_bar_controller->GetCurrentActions(); |
| 964 } | 965 } |
| 965 | 966 |
| 966 // Initialize on the first call, or re-initialize if more extensions have been | 967 // Initialize on the first call, or re-initialize if more extensions have been |
| 967 // loaded or added after startup. | 968 // loaded or added after startup. |
| 968 if (new_page_actions != page_actions_) { | 969 if (new_page_actions != page_actions_) { |
| 969 page_actions_.swap(new_page_actions); | 970 page_actions_.swap(new_page_actions); |
| 970 page_action_views_.clear(); | 971 page_action_views_.clear(); |
| 971 | 972 |
| 972 for (size_t i = 0; i < page_actions_.size(); ++i) { | 973 for (size_t i = 0; i < page_actions_.size(); ++i) { |
| 973 page_action_views_.push_back( | 974 page_action_views_.push_back( |
| 974 new PageActionViewGtk(this, page_actions_[i])); | 975 new PageActionViewGtk(this, page_actions_[i])); |
| 975 gtk_box_pack_end(GTK_BOX(page_action_hbox_.get()), | 976 gtk_box_pack_end(GTK_BOX(page_action_hbox_.get()), |
| 976 page_action_views_[i]->widget(), FALSE, FALSE, 0); | 977 page_action_views_[i]->widget(), FALSE, FALSE, 0); |
| 977 } | 978 } |
| 978 content::NotificationService::current()->Notify( | 979 content::NotificationService::current()->Notify( |
| 979 chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_COUNT_CHANGED, | 980 chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_COUNT_CHANGED, |
| 980 content::Source<LocationBar>(this), | 981 content::Source<LocationBar>(this), |
| 981 content::NotificationService::NoDetails()); | 982 content::NotificationService::NoDetails()); |
| 982 } | 983 } |
| 983 | 984 |
| 984 WebContents* contents = GetWebContents(); | |
| 985 if (!page_action_views_.empty() && contents) { | 985 if (!page_action_views_.empty() && contents) { |
| 986 GURL url = chrome::GetActiveWebContents(browser())->GetURL(); | 986 GURL url = chrome::GetActiveWebContents(browser())->GetURL(); |
| 987 | 987 |
| 988 for (size_t i = 0; i < page_action_views_.size(); i++) { | 988 for (size_t i = 0; i < page_action_views_.size(); i++) { |
| 989 page_action_views_[i]->UpdateVisibility( | 989 page_action_views_[i]->UpdateVisibility( |
| 990 toolbar_model_->input_in_progress() ? NULL : contents, url); | 990 toolbar_model_->input_in_progress() ? NULL : contents, url); |
| 991 } | 991 } |
| 992 } | 992 } |
| 993 | 993 |
| 994 // If there are no visible page actions, hide the hbox too, so that it does | 994 // If there are no visible page actions, hide the hbox too, so that it does |
| (...skipping 1034 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2029 owner_->browser()->profile()->GetExtensionService(); | 2029 owner_->browser()->profile()->GetExtensionService(); |
| 2030 if (!extension_service) | 2030 if (!extension_service) |
| 2031 return TRUE; | 2031 return TRUE; |
| 2032 | 2032 |
| 2033 const Extension* extension = | 2033 const Extension* extension = |
| 2034 extension_service->extensions()->GetByID(page_action()->extension_id()); | 2034 extension_service->extensions()->GetByID(page_action()->extension_id()); |
| 2035 if (!extension) | 2035 if (!extension) |
| 2036 return TRUE; | 2036 return TRUE; |
| 2037 | 2037 |
| 2038 LocationBarController* controller = | 2038 LocationBarController* controller = |
| 2039 tab_contents->extension_tab_helper()->location_bar_controller(); | 2039 extensions::TabHelper::FromWebContents(tab_contents->web_contents())-> |
| 2040 location_bar_controller(); |
| 2040 | 2041 |
| 2041 switch (controller->OnClicked(extension->id(), event->button)) { | 2042 switch (controller->OnClicked(extension->id(), event->button)) { |
| 2042 case LocationBarController::ACTION_NONE: | 2043 case LocationBarController::ACTION_NONE: |
| 2043 break; | 2044 break; |
| 2044 | 2045 |
| 2045 case LocationBarController::ACTION_SHOW_POPUP: | 2046 case LocationBarController::ACTION_SHOW_POPUP: |
| 2046 ExtensionPopupGtk::Show( | 2047 ExtensionPopupGtk::Show( |
| 2047 page_action_->GetPopupUrl(current_tab_id_), | 2048 page_action_->GetPopupUrl(current_tab_id_), |
| 2048 owner_->browser_, | 2049 owner_->browser_, |
| 2049 event_box_.get(), | 2050 event_box_.get(), |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2114 } | 2115 } |
| 2115 | 2116 |
| 2116 void LocationBarViewGtk::PageActionViewGtk::InspectPopup( | 2117 void LocationBarViewGtk::PageActionViewGtk::InspectPopup( |
| 2117 ExtensionAction* action) { | 2118 ExtensionAction* action) { |
| 2118 ExtensionPopupGtk::Show( | 2119 ExtensionPopupGtk::Show( |
| 2119 action->GetPopupUrl(current_tab_id_), | 2120 action->GetPopupUrl(current_tab_id_), |
| 2120 owner_->browser_, | 2121 owner_->browser_, |
| 2121 event_box_.get(), | 2122 event_box_.get(), |
| 2122 ExtensionPopupGtk::SHOW_AND_INSPECT); | 2123 ExtensionPopupGtk::SHOW_AND_INSPECT); |
| 2123 } | 2124 } |
| OLD | NEW |