OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/gtk/tabs/tab_strip_gtk.h" | 5 #include "chrome/browser/gtk/tabs/tab_strip_gtk.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "app/gtk_dnd_util.h" | 9 #include "app/gtk_dnd_util.h" |
10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
11 #include "app/slide_animation.h" | 11 #include "app/slide_animation.h" |
12 #include "base/i18n/rtl.h" | 12 #include "base/i18n/rtl.h" |
13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
14 #include "chrome/browser/autocomplete/autocomplete.h" | 14 #include "chrome/browser/autocomplete/autocomplete.h" |
15 #include "chrome/browser/browser.h" | |
15 #include "chrome/browser/gtk/browser_window_gtk.h" | 16 #include "chrome/browser/gtk/browser_window_gtk.h" |
16 #include "chrome/browser/gtk/custom_button.h" | 17 #include "chrome/browser/gtk/custom_button.h" |
17 #include "chrome/browser/gtk/gtk_theme_provider.h" | 18 #include "chrome/browser/gtk/gtk_theme_provider.h" |
18 #include "chrome/browser/gtk/gtk_util.h" | 19 #include "chrome/browser/gtk/gtk_util.h" |
19 #include "chrome/browser/gtk/tabs/dragged_tab_controller_gtk.h" | 20 #include "chrome/browser/gtk/tabs/dragged_tab_controller_gtk.h" |
20 #include "chrome/browser/profile.h" | 21 #include "chrome/browser/profile.h" |
21 #include "chrome/browser/tab_contents/tab_contents.h" | 22 #include "chrome/browser/tab_contents/tab_contents.h" |
22 #include "chrome/browser/tabs/tab_strip_model_delegate.h" | 23 #include "chrome/browser/tabs/tab_strip_model_delegate.h" |
23 #include "chrome/browser/themes/browser_theme_provider.h" | 24 #include "chrome/browser/themes/browser_theme_provider.h" |
24 #include "chrome/common/notification_service.h" | 25 #include "chrome/common/notification_service.h" |
(...skipping 1942 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1967 case 1: | 1968 case 1: |
1968 model_->delegate()->AddBlankTab(true); | 1969 model_->delegate()->AddBlankTab(true); |
1969 break; | 1970 break; |
1970 case 2: { | 1971 case 2: { |
1971 // On middle-click, try to parse the PRIMARY selection as a URL and load | 1972 // On middle-click, try to parse the PRIMARY selection as a URL and load |
1972 // it instead of creating a blank page. | 1973 // it instead of creating a blank page. |
1973 GURL url; | 1974 GURL url; |
1974 if (!gtk_util::URLFromPrimarySelection(model_->profile(), &url)) | 1975 if (!gtk_util::URLFromPrimarySelection(model_->profile(), &url)) |
1975 return; | 1976 return; |
1976 | 1977 |
1977 TabContents* contents = | 1978 Browser* browser = window_->browser(); |
1978 model_->delegate()->CreateTabContentsForURL( | 1979 if (!browser) { |
Peter Kasting
2010/11/12 19:49:01
Nit: Just DCHECK(browser) and keep going. ("Don't
Evan Stade
2010/11/12 20:47:12
Done.
| |
1979 url, | 1980 NOTREACHED(); |
1980 GURL(), // referrer | 1981 break; |
1981 model_->profile(), | 1982 } |
1982 PageTransition::TYPED, | 1983 |
1983 false, // defer_load | 1984 browser->AddSelectedTabWithURL(url, PageTransition::TYPED); |
Peter Kasting
2010/11/12 19:49:01
This should actually be LINK rather than TYPED (th
Evan Stade
2010/11/12 20:47:12
Done.
| |
1984 NULL); // instance | |
1985 model_->AddTabContents( | |
1986 contents, | |
1987 -1, // index | |
1988 PageTransition::TYPED, | |
1989 TabStripModel::ADD_SELECTED); | |
1990 break; | 1985 break; |
1991 } | 1986 } |
1992 default: | 1987 default: |
1993 NOTREACHED() << "Got click on new tab button with unhandled mouse " | 1988 NOTREACHED() << "Got click on new tab button with unhandled mouse " |
1994 << "button " << mouse_button; | 1989 << "button " << mouse_button; |
1995 } | 1990 } |
1996 } | 1991 } |
1997 | 1992 |
1998 void TabStripGtk::SetTabBounds(TabGtk* tab, const gfx::Rect& bounds) { | 1993 void TabStripGtk::SetTabBounds(TabGtk* tab, const gfx::Rect& bounds) { |
1999 gfx::Rect bds = bounds; | 1994 gfx::Rect bds = bounds; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2035 | 2030 |
2036 // Let the middle mouse button initiate clicks as well. | 2031 // Let the middle mouse button initiate clicks as well. |
2037 gtk_util::SetButtonTriggersNavigation(button->widget()); | 2032 gtk_util::SetButtonTriggersNavigation(button->widget()); |
2038 g_signal_connect(button->widget(), "clicked", | 2033 g_signal_connect(button->widget(), "clicked", |
2039 G_CALLBACK(OnNewTabClickedThunk), this); | 2034 G_CALLBACK(OnNewTabClickedThunk), this); |
2040 GTK_WIDGET_UNSET_FLAGS(button->widget(), GTK_CAN_FOCUS); | 2035 GTK_WIDGET_UNSET_FLAGS(button->widget(), GTK_CAN_FOCUS); |
2041 gtk_fixed_put(GTK_FIXED(tabstrip_.get()), button->widget(), 0, 0); | 2036 gtk_fixed_put(GTK_FIXED(tabstrip_.get()), button->widget(), 0, 0); |
2042 | 2037 |
2043 return button; | 2038 return button; |
2044 } | 2039 } |
OLD | NEW |