summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views
diff options
context:
space:
mode:
authorkuan@chromium.org <kuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-10 18:51:33 +0000
committerkuan@chromium.org <kuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-10 18:51:33 +0000
commit62cf690a77564be902cf481803a9a7e3d52f7c55 (patch)
tree3792385594c7eaf77294a7fae3dacaa3ada4c3d4 /chrome/browser/views
parente3615577169f4e84cdf274493d876fea060020f9 (diff)
downloadchromium_src-62cf690a77564be902cf481803a9a7e3d52f7c55.zip
chromium_src-62cf690a77564be902cf481803a9a7e3d52f7c55.tar.gz
chromium_src-62cf690a77564be902cf481803a9a7e3d52f7c55.tar.bz2
implement "Learn more" link in "Aw snap" page.
this changelist is only for windows. BUG=21726 TEST=verify that "Learn More" link shows up centralized beneath crash message and when clicked, opens the url specified in bug. Review URL: http://codereview.chromium.org/377016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31573 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views')
-rw-r--r--chrome/browser/views/sad_tab_view.cc28
-rw-r--r--chrome/browser/views/sad_tab_view.h17
-rw-r--r--chrome/browser/views/tab_contents/tab_contents_view_win.cc21
-rw-r--r--chrome/browser/views/tab_contents/tab_contents_view_win.h2
4 files changed, 54 insertions, 14 deletions
diff --git a/chrome/browser/views/sad_tab_view.cc b/chrome/browser/views/sad_tab_view.cc
index 2c5ee30..da2c6fde 100644
--- a/chrome/browser/views/sad_tab_view.cc
+++ b/chrome/browser/views/sad_tab_view.cc
@@ -8,7 +8,9 @@
#include "app/l10n_util.h"
#include "app/resource_bundle.h"
#include "base/gfx/size.h"
+#include "chrome/browser/browser_list.h"
#include "grit/generated_resources.h"
+#include "grit/locale_settings.h"
#include "grit/theme_resources.h"
#include "skia/ext/skia_utils.h"
#include "third_party/skia/include/effects/SkGradientShader.h"
@@ -31,8 +33,15 @@ std::wstring SadTabView::title_;
std::wstring SadTabView::message_;
int SadTabView::title_width_;
-SadTabView::SadTabView() {
+SadTabView::SadTabView()
+ : learn_more_link_(NULL) {
InitClass();
+
+ learn_more_link_ = new views::Link(l10n_util::GetString(IDS_LEARN_MORE));
+ learn_more_link_->SetFont(*message_font_);
+ learn_more_link_->MakeReadableOverBackgroundColor(kBackgroundColor);
+ learn_more_link_->SetController(this);
+ AddChildView(learn_more_link_);
}
void SadTabView::Paint(gfx::Canvas* canvas) {
@@ -56,6 +65,9 @@ void SadTabView::Paint(gfx::Canvas* canvas) {
message_bounds_.x(), message_bounds_.y(),
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());
}
void SadTabView::Layout() {
@@ -78,6 +90,20 @@ void SadTabView::Layout() {
int message_x = (width() - message_width) / 2;
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());
+}
+
+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);
+ }
}
// static
diff --git a/chrome/browser/views/sad_tab_view.h b/chrome/browser/views/sad_tab_view.h
index 65ed6fb..fe1c7aa 100644
--- a/chrome/browser/views/sad_tab_view.h
+++ b/chrome/browser/views/sad_tab_view.h
@@ -7,6 +7,7 @@
#include "app/gfx/font.h"
#include "base/basictypes.h"
+#include "views/controls/link.h"
#include "views/view.h"
class SkBitmap;
@@ -18,15 +19,9 @@ class SkBitmap;
// A views::View subclass used to render the presentation of the crashed
// "sad tab" in the browser window when a renderer is destroyed unnaturally.
//
-// Note that since this view is not (currently) part of a Container or
-// RootView hierarchy, it cannot respond to events or contain controls that
-// do, right now it is used simply to render. Adding an extra Container to
-// TabContents seemed like a lot of complexity. Ideally, perhaps TabContents'
-// view portion would itself become a Container in the future, then event
-// processing will work.
-//
///////////////////////////////////////////////////////////////////////////////
-class SadTabView : public views::View {
+class SadTabView : public views::View,
+ public views::LinkController {
public:
SadTabView();
virtual ~SadTabView() {}
@@ -35,6 +30,9 @@ class SadTabView : public views::View {
virtual void Paint(gfx::Canvas* canvas);
virtual void Layout();
+ // Overridden from views::LinkController:
+ virtual void LinkActivated(views::Link* source, int event_flags);
+
private:
static void InitClass();
@@ -46,11 +44,14 @@ class SadTabView : public views::View {
static std::wstring message_;
static int title_width_;
+ views::Link* learn_more_link_;
+
// Regions within the display for different components, populated by
// Layout().
gfx::Rect icon_bounds_;
gfx::Rect title_bounds_;
gfx::Rect message_bounds_;
+ gfx::Rect link_bounds_;
DISALLOW_COPY_AND_ASSIGN(SadTabView);
};
diff --git a/chrome/browser/views/tab_contents/tab_contents_view_win.cc b/chrome/browser/views/tab_contents/tab_contents_view_win.cc
index c402d68..a0a0beb 100644
--- a/chrome/browser/views/tab_contents/tab_contents_view_win.cc
+++ b/chrome/browser/views/tab_contents/tab_contents_view_win.cc
@@ -48,7 +48,8 @@ TabContentsViewWin::TabContentsViewWin(TabContents* tab_contents)
: TabContentsView(tab_contents),
ignore_next_char_event_(false),
focus_manager_(NULL),
- close_tab_after_drag_ends_(false) {
+ close_tab_after_drag_ends_(false),
+ sad_tab_(NULL) {
last_focused_view_storage_id_ =
views::ViewStorage::GetSharedInstance()->CreateStorageID();
}
@@ -98,6 +99,12 @@ RenderWidgetHostView* TabContentsViewWin::CreateViewForWidget(
return render_widget_host->view();
}
+ // If we were showing sad tab, remove it now.
+ if (sad_tab_ != NULL) {
+ SetContentsView(new views::View());
+ sad_tab_ = NULL;
+ }
+
RenderWidgetHostViewWin* view =
new RenderWidgetHostViewWin(render_widget_host);
view->Create(GetNativeView());
@@ -239,7 +246,7 @@ void TabContentsViewWin::Focus() {
return;
}
- if (tab_contents()->is_crashed() && sad_tab_.get()) {
+ if (tab_contents()->is_crashed() && sad_tab_ != NULL) {
sad_tab_->RequestFocus();
return;
}
@@ -473,6 +480,10 @@ void TabContentsViewWin::OnMouseLeave() {
LRESULT TabContentsViewWin::OnMouseRange(UINT msg,
WPARAM w_param, LPARAM l_param) {
+ if (tab_contents()->is_crashed() && sad_tab_ != NULL) {
+ return WidgetWin::OnMouseRange(msg, w_param, l_param);
+ }
+
switch (msg) {
case WM_LBUTTONDOWN:
case WM_MBUTTONDOWN:
@@ -499,8 +510,10 @@ LRESULT TabContentsViewWin::OnMouseRange(UINT msg,
void TabContentsViewWin::OnPaint(HDC junk_dc) {
if (tab_contents()->render_view_host() &&
!tab_contents()->render_view_host()->IsRenderViewLive()) {
- if (!sad_tab_.get())
- sad_tab_.reset(new SadTabView);
+ if (sad_tab_ == NULL) {
+ sad_tab_ = new SadTabView;
+ SetContentsView(sad_tab_);
+ }
CRect cr;
GetClientRect(&cr);
sad_tab_->SetBounds(gfx::Rect(cr));
diff --git a/chrome/browser/views/tab_contents/tab_contents_view_win.h b/chrome/browser/views/tab_contents/tab_contents_view_win.h
index e728449..5b63dfc 100644
--- a/chrome/browser/views/tab_contents/tab_contents_view_win.h
+++ b/chrome/browser/views/tab_contents/tab_contents_view_win.h
@@ -107,7 +107,7 @@ class TabContentsViewWin : public TabContentsView,
// Used to render the sad tab. This will be non-NULL only when the sad tab is
// visible.
- scoped_ptr<SadTabView> sad_tab_;
+ SadTabView* sad_tab_;
// Whether to ignore the next CHAR keyboard event.
bool ignore_next_char_event_;