| Index: chrome/browser/ui/gtk/location_bar_view_gtk.cc
|
| diff --git a/chrome/browser/ui/gtk/location_bar_view_gtk.cc b/chrome/browser/ui/gtk/location_bar_view_gtk.cc
|
| index 4a24534b141ea73267877a882eb3e25a79fe5fec..8adc309c683eebfaeb61cb7497dab02ee8b82010 100644
|
| --- a/chrome/browser/ui/gtk/location_bar_view_gtk.cc
|
| +++ b/chrome/browser/ui/gtk/location_bar_view_gtk.cc
|
| @@ -26,6 +26,7 @@
|
| #include "chrome/browser/defaults.h"
|
| #include "chrome/browser/extensions/api/commands/extension_command_service.h"
|
| #include "chrome/browser/extensions/api/commands/extension_command_service_factory.h"
|
| +#include "chrome/browser/extensions/page_box_controller.h"
|
| #include "chrome/browser/extensions/extension_browser_event_router.h"
|
| #include "chrome/browser/extensions/extension_service.h"
|
| #include "chrome/browser/extensions/extension_tab_util.h"
|
| @@ -82,6 +83,7 @@
|
| using content::NavigationEntry;
|
| using content::OpenURLParams;
|
| using content::WebContents;
|
| +using extensions::PageBoxController;
|
|
|
| namespace {
|
|
|
| @@ -683,26 +685,22 @@ void LocationBarViewGtk::UpdateContentSettingsIcons() {
|
| }
|
|
|
| void LocationBarViewGtk::UpdatePageActions() {
|
| - std::vector<ExtensionAction*> page_actions;
|
| ExtensionService* service = browser_->profile()->GetExtensionService();
|
| if (!service)
|
| return;
|
|
|
| - // Find all the page actions.
|
| - for (ExtensionSet::const_iterator it = service->extensions()->begin();
|
| - it != service->extensions()->end(); ++it) {
|
| - if ((*it)->page_action())
|
| - page_actions.push_back((*it)->page_action());
|
| - }
|
| + scoped_ptr<PageBoxController::DataList> page_actions =
|
| + GetTabContentsWrapper()->extensions_page_box_controller()->
|
| + GetAllBadgeData();
|
|
|
| // Initialize on the first call, or re-inialize if more extensions have been
|
| // loaded or added after startup.
|
| - if (page_actions.size() != page_action_views_.size()) {
|
| + if (page_actions->size() != page_action_views_.size()) {
|
| page_action_views_.reset(); // Delete the old views (if any).
|
|
|
| - for (size_t i = 0; i < page_actions.size(); ++i) {
|
| + for (size_t i = 0; i < page_actions->size(); ++i) {
|
| page_action_views_.push_back(
|
| - new PageActionViewGtk(this, page_actions[i]));
|
| + new PageActionViewGtk(this, (*page_actions)[i].action));
|
| gtk_box_pack_end(GTK_BOX(page_action_hbox_.get()),
|
| page_action_views_[i]->widget(), FALSE, FALSE, 0);
|
| }
|
| @@ -1681,17 +1679,6 @@ void LocationBarViewGtk::EnabledStateChangedForCommand(int id, bool enabled) {
|
| UpdateChromeToMobileIcon();
|
| }
|
|
|
| -bool LocationBarViewGtk::PageActionViewGtk::ShowPopup() {
|
| - if (!page_action_->HasPopup(current_tab_id_))
|
| - return false;
|
| -
|
| - ExtensionPopupGtk::Show(
|
| - page_action_->GetPopupUrl(current_tab_id_),
|
| - owner_->browser_,
|
| - event_box_.get());
|
| - return true;
|
| -}
|
| -
|
| void LocationBarViewGtk::PageActionViewGtk::ConnectPageActionAccelerator() {
|
| const ExtensionSet* extensions = owner_->browser()->profile()->
|
| GetExtensionService()->extensions();
|
| @@ -1746,25 +1733,48 @@ void LocationBarViewGtk::PageActionViewGtk::DisconnectPageActionAccelerator() {
|
| gboolean LocationBarViewGtk::PageActionViewGtk::OnButtonPressed(
|
| GtkWidget* sender,
|
| GdkEventButton* event) {
|
| - Profile* profile = owner_->browser()->profile();
|
| - if (event->button != 3) {
|
| - if (!ShowPopup()) {
|
| - ExtensionService* service = profile->GetExtensionService();
|
| - service->browser_event_router()->PageActionExecuted(profile,
|
| - page_action_->extension_id(), page_action_->id(), current_tab_id_,
|
| - current_url_.spec(), event->button);
|
| - }
|
| - } else {
|
| - const Extension* extension = profile->GetExtensionService()->
|
| - GetExtensionById(page_action()->extension_id(), false);
|
| + const Extension* extension =
|
| + owner_->browser()->profile()->GetExtensionService()->
|
| + GetExtensionById(page_action()->extension_id(), false);
|
| + CHECK(extension);
|
| + PageBoxController* page_box_controller =
|
| + owner_->GetTabContentsWrapper()->extensions_page_box_controller();
|
| +
|
| + PageBoxController::MouseButton button = PageBoxController::MOUSE_LEFT;
|
| + switch (event->button) {
|
| + case 1:
|
| + button = PageBoxController::MOUSE_LEFT;
|
| + break;
|
| + case 2:
|
| + button = PageBoxController::MOUSE_MIDDLE;
|
| + break;
|
| + case 3:
|
| + button = PageBoxController::MOUSE_RIGHT;
|
| + break;
|
| + default:
|
| + // Apparently this can happen in GDK, presumably weird buttons.
|
| + button = PageBoxController::MOUSE_LEFT;
|
| + break;
|
| + }
|
| +
|
| + switch (page_box_controller->OnClicked(extension->id(), button)) {
|
| + case PageBoxController::ACTION_NONE:
|
| + break;
|
|
|
| - if (extension->ShowConfigureContextMenus()) {
|
| + case PageBoxController::ACTION_SHOW_POPUP:
|
| + ExtensionPopupGtk::Show(
|
| + page_action_->GetPopupUrl(current_tab_id_),
|
| + owner_->browser_,
|
| + event_box_.get());
|
| + break;
|
| +
|
| + case PageBoxController::ACTION_SHOW_CONTEXT_MENU:
|
| context_menu_model_ =
|
| new ExtensionContextMenuModel(extension, owner_->browser_);
|
| context_menu_.reset(
|
| new MenuGtk(NULL, context_menu_model_.get()));
|
| context_menu_->PopupForWidget(sender, event->button, event->time);
|
| - }
|
| + break;
|
| }
|
|
|
| return TRUE;
|
|
|