summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk/sad_tab_gtk.cc
diff options
context:
space:
mode:
authorkuan@chromium.org <kuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-03 16:00:46 +0000
committerkuan@chromium.org <kuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-03 16:00:46 +0000
commit65ed01e42abd1d73fd7eb520908bdff1b50c21fd (patch)
tree21ece79f36e545eb9c0dcb86d6018d5f4cc7b562 /chrome/browser/gtk/sad_tab_gtk.cc
parent120be5d1b6455f4a97eaf560d12f0f78c8b1a107 (diff)
downloadchromium_src-65ed01e42abd1d73fd7eb520908bdff1b50c21fd.zip
chromium_src-65ed01e42abd1d73fd7eb520908bdff1b50c21fd.tar.gz
chromium_src-65ed01e42abd1d73fd7eb520908bdff1b50c21fd.tar.bz2
linux: use TabContents to launch url for link in crash page
- used to use BrowserList::GetLastActive but that's null in chrome-frame release. - TabContents is passed into constructor and only if it's non-null is the link created. BUG=29034 TEST=verify that crash per bug report doesn't happen. Review URL: http://codereview.chromium.org/466016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@33684 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk/sad_tab_gtk.cc')
-rw-r--r--chrome/browser/gtk/sad_tab_gtk.cc40
1 files changed, 23 insertions, 17 deletions
diff --git a/chrome/browser/gtk/sad_tab_gtk.cc b/chrome/browser/gtk/sad_tab_gtk.cc
index 5a18f09..ea7a717 100644
--- a/chrome/browser/gtk/sad_tab_gtk.cc
+++ b/chrome/browser/gtk/sad_tab_gtk.cc
@@ -10,8 +10,8 @@
#include "app/l10n_util.h"
#include "app/resource_bundle.h"
#include "base/lazy_instance.h"
-#include "chrome/browser/browser_list.h"
#include "chrome/browser/gtk/gtk_chrome_link_button.h"
+#include "chrome/browser/tab_contents/tab_contents.h"
#include "grit/generated_resources.h"
#include "grit/locale_settings.h"
#include "grit/theme_resources.h"
@@ -67,9 +67,12 @@ GtkWidget* MakeWhiteMarkupLabel(const char* format, const std::string& str) {
} // namespace
-SadTabGtk::SadTabGtk()
+SadTabGtk::SadTabGtk(TabContents* tab_contents)
: width_(0),
- height_(0) {
+ height_(0),
+ tab_contents_(tab_contents) {
+ DCHECK(tab_contents_);
+
// Use an event box to get the background painting correctly.
event_box_.Own(gtk_event_box_new());
gtk_widget_set_app_paintable(event_box_.get(), TRUE);
@@ -110,16 +113,17 @@ SadTabGtk::SadTabGtk()
gtk_box_pack_start(GTK_BOX(vbox), message_, FALSE, FALSE,
kMessageLinkSpacing);
- // Add the learn-more link and center-align it in an alignment.
- GtkWidget* link = gtk_chrome_link_button_new(
- l10n_util::GetStringUTF8(IDS_LEARN_MORE).c_str());
- gtk_chrome_link_button_set_normal_color(GTK_CHROME_LINK_BUTTON(link),
- &gfx::kGdkWhite);
- g_signal_connect(link, "clicked", G_CALLBACK(OnLinkButtonClick),
- const_cast<char*>(sad_tab_constants.learn_more_url.c_str()));
- GtkWidget* link_alignment = gtk_alignment_new(0.5, 0.5, 0.0, 0.0);
- gtk_container_add(GTK_CONTAINER(link_alignment), link);
- gtk_box_pack_start(GTK_BOX(vbox), link_alignment, FALSE, FALSE, 0);
+ if (tab_contents_ != NULL) {
+ // Add the learn-more link and center-align it in an alignment.
+ GtkWidget* link = gtk_chrome_link_button_new(
+ l10n_util::GetStringUTF8(IDS_LEARN_MORE).c_str());
+ gtk_chrome_link_button_set_normal_color(GTK_CHROME_LINK_BUTTON(link),
+ &gfx::kGdkWhite);
+ g_signal_connect(link, "clicked", G_CALLBACK(OnLinkButtonClickThunk), this);
+ GtkWidget* link_alignment = gtk_alignment_new(0.5, 0.5, 0.0, 0.0);
+ gtk_container_add(GTK_CONTAINER(link_alignment), link);
+ gtk_box_pack_start(GTK_BOX(vbox), link_alignment, FALSE, FALSE, 0);
+ }
gtk_widget_show_all(event_box_.get());
}
@@ -177,8 +181,10 @@ void SadTabGtk::OnSizeAllocate(GtkWidget* widget, GtkAllocation* allocation) {
}
}
-// static
-void SadTabGtk::OnLinkButtonClick(GtkWidget* button, const char* url) {
- BrowserList::GetLastActive()->OpenURL(GURL(url), GURL(), CURRENT_TAB,
- PageTransition::LINK);
+void SadTabGtk::OnLinkButtonClick() {
+ if (tab_contents_ != NULL) {
+ const SadTabGtkConstants& sad_tab_constants = g_sad_tab_constants.Get();
+ tab_contents_->OpenURL(GURL(sad_tab_constants.learn_more_url.c_str()),
+ GURL(), CURRENT_TAB, PageTransition::LINK);
+ }
}