summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk/browser_actions_toolbar_gtk.cc
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-23 22:20:47 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-23 22:20:47 +0000
commit5ff5ee97910c9fb6909f4a3029427edd21366d9b (patch)
treeae91db49647992032403bea599588408e74282c8 /chrome/browser/gtk/browser_actions_toolbar_gtk.cc
parentb22189fe300c9cdcd5cf929c2f9e76c3f935fcfa (diff)
downloadchromium_src-5ff5ee97910c9fb6909f4a3029427edd21366d9b.zip
chromium_src-5ff5ee97910c9fb6909f4a3029427edd21366d9b.tar.gz
chromium_src-5ff5ee97910c9fb6909f4a3029427edd21366d9b.tar.bz2
GTK: allow inspecting of extension popups.
BUG=24477 TEST=manual Review URL: http://codereview.chromium.org/1170001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42389 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk/browser_actions_toolbar_gtk.cc')
-rw-r--r--chrome/browser/gtk/browser_actions_toolbar_gtk.cc52
1 files changed, 32 insertions, 20 deletions
diff --git a/chrome/browser/gtk/browser_actions_toolbar_gtk.cc b/chrome/browser/gtk/browser_actions_toolbar_gtk.cc
index 31d3c24..b6bb11b 100644
--- a/chrome/browser/gtk/browser_actions_toolbar_gtk.cc
+++ b/chrome/browser/gtk/browser_actions_toolbar_gtk.cc
@@ -178,10 +178,32 @@ class BrowserActionButton : public NotificationObserver,
}
private:
+ // Returns true to prevent further processing of the event that caused us to
+ // show the popup, or false to continue processing.
+ bool ShowPopup(bool devtools) {
+ ExtensionAction* browser_action = extension_->browser_action();
+
+ int tab_id = toolbar_->GetCurrentTabId();
+ if (tab_id < 0) {
+ NOTREACHED() << "No current tab.";
+ return true;
+ }
+
+ if (browser_action->HasPopup(tab_id)) {
+ ExtensionPopupGtk::Show(
+ browser_action->GetPopupUrl(tab_id),
+ toolbar_->browser(),
+ gtk_util::GetWidgetRectRelativeToToplevel(widget()),
+ devtools);
+ return true;
+ }
+
+ return false;
+ }
+
// ExtensionContextMenuModel::PopupDelegate implementation.
virtual void InspectPopup(ExtensionAction* action) {
- // TODO(estade): http://crbug.com/24477
- NOTIMPLEMENTED();
+ ShowPopup(true);
}
void SetImage(GdkPixbuf* image) {
@@ -208,24 +230,12 @@ class BrowserActionButton : public NotificationObserver,
}
static void OnClicked(GtkWidget* widget, BrowserActionButton* action) {
- ExtensionAction* browser_action = action->extension_->browser_action();
-
- int tab_id = action->toolbar_->GetCurrentTabId();
- if (tab_id < 0) {
- NOTREACHED() << "No current tab.";
+ if (action->ShowPopup(false))
return;
- }
- if (browser_action->HasPopup(tab_id)) {
- ExtensionPopupGtk::Show(
- browser_action->GetPopupUrl(tab_id),
- action->toolbar_->browser(),
- gtk_util::GetWidgetRectRelativeToToplevel(widget));
- } else {
- ExtensionBrowserEventRouter::GetInstance()->BrowserActionExecuted(
- action->toolbar_->browser()->profile(), action->extension_->id(),
- action->toolbar_->browser());
- }
+ ExtensionBrowserEventRouter::GetInstance()->BrowserActionExecuted(
+ action->toolbar_->browser()->profile(), action->extension_->id(),
+ action->toolbar_->browser());
}
static gboolean OnExposeEvent(GtkWidget* widget,
@@ -541,7 +551,8 @@ void BrowserActionsToolbarGtk::ExecuteCommandById(int command_id) {
if (browser_action->HasPopup(tab_id)) {
ExtensionPopupGtk::Show(
browser_action->GetPopupUrl(tab_id), browser(),
- gtk_util::GetWidgetRectRelativeToToplevel(overflow_button_.widget()));
+ gtk_util::GetWidgetRectRelativeToToplevel(overflow_button_.widget()),
+ false);
} else {
ExtensionBrowserEventRouter::GetInstance()->BrowserActionExecuted(
browser()->profile(), extension->id(), browser());
@@ -644,10 +655,11 @@ void BrowserActionsToolbarGtk::OnHierarchyChanged(GtkWidget* widget,
void BrowserActionsToolbarGtk::OnSetFocus(GtkWidget* widget,
GtkWidget* focus_widget) {
+ ExtensionPopupGtk* popup = ExtensionPopupGtk::get_current_extension_popup();
// The focus of the parent window has changed. Close the popup. Delay the hide
// because it will destroy the RenderViewHost, which may still be on the
// call stack.
- if (!ExtensionPopupGtk::get_current_extension_popup())
+ if (!popup || popup->being_inspected())
return;
MessageLoop::current()->PostTask(FROM_HERE,
method_factory_.NewRunnableMethod(&BrowserActionsToolbarGtk::HidePopup));