summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbenwells@chromium.org <benwells@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-15 01:35:36 +0000
committerbenwells@chromium.org <benwells@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-15 01:35:36 +0000
commit6d340494fe9e6dec1222aab3c4d3f09e21e80150 (patch)
treee9abbb167e4315458d36ad4641c4ce068de6e284
parent43a3ced8ab40b7a9e36ca2286be7a423072aec9e (diff)
downloadchromium_src-6d340494fe9e6dec1222aab3c4d3f09e21e80150.zip
chromium_src-6d340494fe9e6dec1222aab3c4d3f09e21e80150.tar.gz
chromium_src-6d340494fe9e6dec1222aab3c4d3f09e21e80150.tar.bz2
Allow popup extensions to be inspected on gtk
This was recently enabled for Windows. To enable on gtk, gtk bubbles are now able to stop grabbing keyboard and mouse input. BUG=53518 TEST=Manually tested on ubuntu Review URL: http://codereview.chromium.org/9372050 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@121989 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/tab_contents/render_view_context_menu.cc4
-rw-r--r--chrome/browser/ui/gtk/bubble/bubble_gtk.cc7
-rw-r--r--chrome/browser/ui/gtk/bubble/bubble_gtk.h6
-rw-r--r--chrome/browser/ui/gtk/extensions/extension_popup_gtk.cc29
4 files changed, 37 insertions, 9 deletions
diff --git a/chrome/browser/tab_contents/render_view_context_menu.cc b/chrome/browser/tab_contents/render_view_context_menu.cc
index 5fcf087..ae4078f 100644
--- a/chrome/browser/tab_contents/render_view_context_menu.cc
+++ b/chrome/browser/tab_contents/render_view_context_menu.cc
@@ -1913,9 +1913,9 @@ bool RenderViewContextMenu::IsDevCommandEnabled(int id) const {
prefs::kWebKitJavascriptEnabled) ||
command_line->HasSwitch(switches::kDisableJavaScript))
return false;
-#if !defined(TOOLKIT_VIEWS)
+#if defined(OS_MACOSX)
} else {
- // Disable dev tools for popup extensions for non-views builds, as the
+ // Disable dev tools for popup extensions for Mac OS X builds, as the
// extension popups for these builds do not support dynamically inspecting
// the popups.
// TODO(benwells): Add support for these builds and remove this #if.
diff --git a/chrome/browser/ui/gtk/bubble/bubble_gtk.cc b/chrome/browser/ui/gtk/bubble/bubble_gtk.cc
index dc0f3c5..be2acd4 100644
--- a/chrome/browser/ui/gtk/bubble/bubble_gtk.cc
+++ b/chrome/browser/ui/gtk/bubble/bubble_gtk.cc
@@ -457,6 +457,13 @@ void BubbleGtk::HandlePointerAndKeyboardUngrabbedByContent() {
GrabPointerAndKeyboard();
}
+void BubbleGtk::StopGrabbingInput() {
+ if (!grab_input_)
+ return;
+ grab_input_ = false;
+ gtk_grab_remove(window_);
+}
+
void BubbleGtk::Close() {
// We don't need to ungrab the pointer or keyboard here; the X server will
// automatically do that when we destroy our window.
diff --git a/chrome/browser/ui/gtk/bubble/bubble_gtk.h b/chrome/browser/ui/gtk/bubble/bubble_gtk.h
index e5464be..ba64ec8 100644
--- a/chrome/browser/ui/gtk/bubble/bubble_gtk.h
+++ b/chrome/browser/ui/gtk/bubble/bubble_gtk.h
@@ -95,6 +95,12 @@ class BubbleGtk : public content::NotificationObserver {
// in them.
void HandlePointerAndKeyboardUngrabbedByContent();
+ // Change an input-grabbing bubble into a non-input-grabbing bubble. This
+ // allows a window to change from auto closing when it loses to focus to being
+ // a window that does not auto close, and is useful if an auto closing window
+ // starts being inspected.
+ void StopGrabbingInput();
+
private:
FRIEND_TEST_ALL_PREFIXES(BubbleGtkTest, ArrowLocation);
FRIEND_TEST_ALL_PREFIXES(BubbleGtkTest, NoArrow);
diff --git a/chrome/browser/ui/gtk/extensions/extension_popup_gtk.cc b/chrome/browser/ui/gtk/extensions/extension_popup_gtk.cc
index 6bca52d..1f91996 100644
--- a/chrome/browser/ui/gtk/extensions/extension_popup_gtk.cc
+++ b/chrome/browser/ui/gtk/extensions/extension_popup_gtk.cc
@@ -60,6 +60,14 @@ ExtensionPopupGtk::ExtensionPopupGtk(Browser* browser,
registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE,
content::Source<Profile>(host->profile()));
+
+ registrar_.Add(this, content::NOTIFICATION_DEVTOOLS_WINDOW_CLOSING,
+ content::Source<Profile>(host->profile()));
+
+ if (!being_inspected_) {
+ registrar_.Add(this, content::NOTIFICATION_DEVTOOLS_WINDOW_OPENING,
+ content::Source<Profile>(host->profile()));
+ }
}
ExtensionPopupGtk::~ExtensionPopupGtk() {
@@ -91,9 +99,20 @@ void ExtensionPopupGtk::Observe(int type,
if (content::Details<ExtensionHost>(host_.get()) == details)
DestroyPopup();
break;
+ case content::NOTIFICATION_DEVTOOLS_WINDOW_OPENING:
+ // Make sure it's the devtools window that is inspecting our popup.
+ if (content::Details<RenderViewHost>(host_->render_view_host()) !=
+ details)
+ break;
+
+ // Make sure that the popup won't go away when the inspector is activated.
+ if (bubble_)
+ bubble_->StopGrabbingInput();
+ break;
case content::NOTIFICATION_DEVTOOLS_WINDOW_CLOSING:
- // Make sure its the devtools window that inspecting our popup.
- if (content::Details<RenderViewHost>(host_->render_view_host()) != details)
+ // Make sure it's the devtools window that is inspecting our popup.
+ if (content::Details<RenderViewHost>(host_->render_view_host()) !=
+ details)
break;
// If the devtools window is closing, we post a task to ourselves to
@@ -141,12 +160,8 @@ void ExtensionPopupGtk::ShowPopup() {
return;
}
- if (being_inspected_) {
+ if (being_inspected_)
DevToolsWindow::OpenDevToolsWindow(host_->render_view_host());
- // Listen for the the devtools window closing.
- registrar_.Add(this, content::NOTIFICATION_DEVTOOLS_WINDOW_CLOSING,
- content::Source<content::BrowserContext>(host_->profile()));
- }
// Only one instance should be showing at a time. Get rid of the old one, if
// any. Typically, |current_extension_popup_| will be NULL, but it can be