summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk/location_bar_view_gtk.cc
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-16 20:25:58 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-16 20:25:58 +0000
commit126f5006bc8aa83e8e83f4917f33333f10633f21 (patch)
treeebd4984af98c3ed198866c443f315fc461d0b741 /chrome/browser/gtk/location_bar_view_gtk.cc
parentfff4f6fffb6eb1cf1993beade81577d04198fe75 (diff)
downloadchromium_src-126f5006bc8aa83e8e83f4917f33333f10633f21.zip
chromium_src-126f5006bc8aa83e8e83f4917f33333f10633f21.tar.gz
chromium_src-126f5006bc8aa83e8e83f4917f33333f10633f21.tar.bz2
GTK: navigate to URL on PRIMARY when middle-clicking the location icon.
BUG=40610 TEST=manual Review URL: http://codereview.chromium.org/1549043 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44814 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk/location_bar_view_gtk.cc')
-rw-r--r--chrome/browser/gtk/location_bar_view_gtk.cc50
1 files changed, 35 insertions, 15 deletions
diff --git a/chrome/browser/gtk/location_bar_view_gtk.cc b/chrome/browser/gtk/location_bar_view_gtk.cc
index 6a66cb4..eab7c9b 100644
--- a/chrome/browser/gtk/location_bar_view_gtk.cc
+++ b/chrome/browser/gtk/location_bar_view_gtk.cc
@@ -909,24 +909,44 @@ void LocationBarViewGtk::ShowFirstRunBubbleInternal(
gboolean LocationBarViewGtk::OnIconReleased(GtkWidget* sender,
GdkEventButton* event) {
- // Do not show page info if the user has been editing the location
- // bar, or the location bar is at the NTP.
- if (location_entry()->IsEditingOrEmpty())
- return false;
+ TabContents* tab = GetTabContents();
- // (0,0) event coordinates indicates that the release came at the end of
- // a drag.
- if (event->button != 1 || (event->x == 0 && event->y == 0))
- return false;
+ if (event->button == 1) {
+ // Do not show page info if the user has been editing the location
+ // bar, or the location bar is at the NTP.
+ if (location_entry()->IsEditingOrEmpty())
+ return FALSE;
+
+ // (0,0) event coordinates indicates that the release came at the end of
+ // a drag.
+ if (event->x == 0 && event->y == 0)
+ return FALSE;
+
+ NavigationEntry* nav_entry = tab->controller().GetActiveEntry();
+ if (!nav_entry) {
+ NOTREACHED();
+ return FALSE;
+ }
+ tab->ShowPageInfo(nav_entry->url(), nav_entry->ssl(), true);
+ return TRUE;
+ } else if (event->button == 2) {
+ // When the user middle clicks on the location icon, try to open the
+ // contents of the PRIMARY selection in the current tab.
+ // If the click was outside our bounds, do nothing.
+ if (!gtk_util::WidgetBounds(sender).Contains(
+ gfx::Point(event->x, event->y))) {
+ return FALSE;
+ }
- TabContents* tab = GetTabContents();
- NavigationEntry* nav_entry = tab->controller().GetActiveEntry();
- if (!nav_entry) {
- NOTREACHED();
- return false;
+ GURL url;
+ if (!gtk_util::URLFromPrimarySelection(profile_, &url))
+ return FALSE;
+
+ tab->OpenURL(url, GURL(), CURRENT_TAB, PageTransition::TYPED);
+ return TRUE;
}
- tab->ShowPageInfo(nav_entry->url(), nav_entry->ssl(), true);
- return true;
+
+ return FALSE;
}
void LocationBarViewGtk::OnIconDragData(GtkWidget* sender,