summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views/sad_tab_view.cc
diff options
context:
space:
mode:
authorkuan@chromium.org <kuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-02 20:05:43 +0000
committerkuan@chromium.org <kuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-02 20:05:43 +0000
commita221052ba1094b7755213945f8e322f40466a0c6 (patch)
treeca2ae048ad8872019fa98e2761388218707615b1 /chrome/browser/views/sad_tab_view.cc
parent47c196b188bf7b1051468a1de4e26d71cabf132f (diff)
downloadchromium_src-a221052ba1094b7755213945f8e322f40466a0c6.zip
chromium_src-a221052ba1094b7755213945f8e322f40466a0c6.tar.gz
chromium_src-a221052ba1094b7755213945f8e322f40466a0c6.tar.bz2
linux_view: implement learn-more link in crash page
- enable mouse-over event to show hand-cursor - enable mouse-click event, which launches help url win and linux_view: use TabContents to launch url for link in crash page - was using BrowserList::GetLastActive, but in chrome frame, this is null, so url can't launch. - now, TabcontentsView passes its TabContents when creating SadTabView. - SadTabView only creates learn-more link if TabContents is not null. BUG=27298,29034 TEST=chromeos: verify that link in crash page shows hand cursor on mouse over, and launches help url when clicked. win, chromeos: link in crash page can be launched successfully in chrome-frame release. Review URL: http://codereview.chromium.org/460021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@33595 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/sad_tab_view.cc')
-rw-r--r--chrome/browser/views/sad_tab_view.cc46
1 files changed, 27 insertions, 19 deletions
diff --git a/chrome/browser/views/sad_tab_view.cc b/chrome/browser/views/sad_tab_view.cc
index 0c3ed0a..9b9f839 100644
--- a/chrome/browser/views/sad_tab_view.cc
+++ b/chrome/browser/views/sad_tab_view.cc
@@ -8,7 +8,7 @@
#include "app/l10n_util.h"
#include "app/resource_bundle.h"
#include "base/gfx/size.h"
-#include "chrome/browser/browser_list.h"
+#include "chrome/browser/tab_contents/tab_contents.h"
#include "grit/generated_resources.h"
#include "grit/locale_settings.h"
#include "grit/theme_resources.h"
@@ -34,15 +34,20 @@ std::wstring SadTabView::title_;
std::wstring SadTabView::message_;
int SadTabView::title_width_;
-SadTabView::SadTabView()
- : learn_more_link_(NULL) {
+SadTabView::SadTabView(TabContents* tab_contents)
+ : tab_contents_(tab_contents),
+ learn_more_link_(NULL) {
+ DCHECK(tab_contents);
+
InitClass();
- learn_more_link_ = new views::Link(l10n_util::GetString(IDS_LEARN_MORE));
- learn_more_link_->SetFont(*message_font_);
- learn_more_link_->SetNormalColor(kLinkColor);
- learn_more_link_->SetController(this);
- AddChildView(learn_more_link_);
+ if (tab_contents != NULL) {
+ learn_more_link_ = new views::Link(l10n_util::GetString(IDS_LEARN_MORE));
+ learn_more_link_->SetFont(*message_font_);
+ learn_more_link_->SetNormalColor(kLinkColor);
+ learn_more_link_->SetController(this);
+ AddChildView(learn_more_link_);
+ }
}
void SadTabView::Paint(gfx::Canvas* canvas) {
@@ -67,8 +72,9 @@ void SadTabView::Paint(gfx::Canvas* canvas) {
message_bounds_.width(), message_bounds_.height(),
gfx::Canvas::MULTI_LINE);
- learn_more_link_->SetBounds(link_bounds_.x(), link_bounds_.y(),
- link_bounds_.width(), link_bounds_.height());
+ if (learn_more_link_ != NULL)
+ learn_more_link_->SetBounds(link_bounds_.x(), link_bounds_.y(),
+ link_bounds_.width(), link_bounds_.height());
}
void SadTabView::Layout() {
@@ -92,18 +98,20 @@ void SadTabView::Layout() {
int message_y = title_bounds_.bottom() + kTitleMessageSpacing;
message_bounds_.SetRect(message_x, message_y, message_width, message_height);
- gfx::Size sz = learn_more_link_->GetPreferredSize();
- gfx::Insets insets = learn_more_link_->GetInsets();
- link_bounds_.SetRect((width() - sz.width()) / 2,
- message_bounds_.bottom() + kTitleMessageSpacing -
- insets.top(), sz.width(), sz.height());
+ if (learn_more_link_ != NULL) {
+ gfx::Size sz = learn_more_link_->GetPreferredSize();
+ gfx::Insets insets = learn_more_link_->GetInsets();
+ link_bounds_.SetRect((width() - sz.width()) / 2,
+ message_bounds_.bottom() + kTitleMessageSpacing -
+ insets.top(), sz.width(), sz.height());
+ }
}
void SadTabView::LinkActivated(views::Link* source, int event_flags) {
- if (source == learn_more_link_) {
- Browser* browser = BrowserList::GetLastActive();
- browser->OpenURL(GURL(l10n_util::GetStringUTF16(IDS_CRASH_REASON_URL)),
- GURL(), CURRENT_TAB, PageTransition::LINK);
+ if (tab_contents_ != NULL && source == learn_more_link_) {
+ string16 url = l10n_util::GetStringUTF16(IDS_CRASH_REASON_URL);
+ tab_contents_->OpenURL(GURL(url), GURL(), CURRENT_TAB,
+ PageTransition::LINK);
}
}