summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views
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
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')
-rw-r--r--chrome/browser/views/sad_tab_view.cc46
-rw-r--r--chrome/browser/views/sad_tab_view.h4
-rw-r--r--chrome/browser/views/tab_contents/tab_contents_view_gtk.cc41
-rw-r--r--chrome/browser/views/tab_contents/tab_contents_view_gtk.h4
-rw-r--r--chrome/browser/views/tab_contents/tab_contents_view_win.cc2
5 files changed, 64 insertions, 33 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);
}
}
diff --git a/chrome/browser/views/sad_tab_view.h b/chrome/browser/views/sad_tab_view.h
index fe1c7aa..5b28705 100644
--- a/chrome/browser/views/sad_tab_view.h
+++ b/chrome/browser/views/sad_tab_view.h
@@ -11,6 +11,7 @@
#include "views/view.h"
class SkBitmap;
+class TabContents;
///////////////////////////////////////////////////////////////////////////////
//
@@ -23,7 +24,7 @@ class SkBitmap;
class SadTabView : public views::View,
public views::LinkController {
public:
- SadTabView();
+ explicit SadTabView(TabContents* tab_contents);
virtual ~SadTabView() {}
// Overridden from views::View:
@@ -44,6 +45,7 @@ class SadTabView : public views::View,
static std::wstring message_;
static int title_width_;
+ TabContents* tab_contents_;
views::Link* learn_more_link_;
// Regions within the display for different components, populated by
diff --git a/chrome/browser/views/tab_contents/tab_contents_view_gtk.cc b/chrome/browser/views/tab_contents/tab_contents_view_gtk.cc
index 7db5ad4..86a2452 100644
--- a/chrome/browser/views/tab_contents/tab_contents_view_gtk.cc
+++ b/chrome/browser/views/tab_contents/tab_contents_view_gtk.cc
@@ -68,13 +68,10 @@ gboolean OnLeaveNotify2(GtkWidget* widget, GdkEventCrossing* event,
return FALSE;
}
-// Called when the mouse moves within the widget. We notify our delegate.
-gboolean OnMouseMove(GtkWidget* widget, GdkEventMotion* event,
- TabContents* tab_contents) {
- if (tab_contents->delegate())
- tab_contents->delegate()->ContentsMouseEvent(
- tab_contents, views::Screen::GetCursorScreenPoint(), true);
- return FALSE;
+// Called when the mouse moves within the widget.
+gboolean CallMouseMove(GtkWidget* widget, GdkEventMotion* event,
+ TabContentsViewGtk* tab_contents_view) {
+ return tab_contents_view->OnMouseMove(widget, event);
}
// See tab_contents_view_win.cc for discussion of mouse scroll zooming.
@@ -104,6 +101,7 @@ TabContentsView* TabContentsView::Create(TabContents* tab_contents) {
TabContentsViewGtk::TabContentsViewGtk(TabContents* tab_contents)
: TabContentsView(tab_contents),
views::WidgetGtk(TYPE_CHILD),
+ sad_tab_(NULL),
ignore_next_char_event_(false) {
drag_source_.reset(new TabContentsDragSource(this));
last_focused_view_storage_id_ =
@@ -166,6 +164,12 @@ RenderWidgetHostView* TabContentsViewGtk::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;
+ }
+
RenderWidgetHostViewGtk* view =
new RenderWidgetHostViewGtk(render_widget_host);
view->InitAsChild();
@@ -174,7 +178,7 @@ RenderWidgetHostView* TabContentsViewGtk::CreateViewForWidget(
g_signal_connect(view->native_view(), "leave-notify-event",
G_CALLBACK(OnLeaveNotify2), tab_contents());
g_signal_connect(view->native_view(), "motion-notify-event",
- G_CALLBACK(OnMouseMove), tab_contents());
+ G_CALLBACK(CallMouseMove), this);
g_signal_connect(view->native_view(), "scroll-event",
G_CALLBACK(OnMouseScroll), tab_contents());
gtk_widget_add_events(view->native_view(), GDK_LEAVE_NOTIFY_MASK |
@@ -234,7 +238,7 @@ void TabContentsViewGtk::Focus() {
return;
}
- if (sad_tab_.get()) {
+ if (tab_contents()->is_crashed() && sad_tab_ != NULL) {
sad_tab_->RequestFocus();
return;
}
@@ -378,8 +382,10 @@ void TabContentsViewGtk::OnSizeAllocate(GtkWidget* widget,
void TabContentsViewGtk::OnPaint(GtkWidget* widget, GdkEventExpose* event) {
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(tab_contents());
+ SetContentsView(sad_tab_);
+ }
gfx::Rect bounds;
GetBounds(&bounds, true);
sad_tab_->SetBounds(gfx::Rect(0, 0, bounds.width(), bounds.height()));
@@ -426,3 +432,16 @@ void TabContentsViewGtk::SetFloatingPosition(const gfx::Size& size) {
PositionChild(widget, child_x, 0, requisition.width, requisition.height);
}
}
+
+// Called when the mouse moves within the widget. We notify SadTabView if it's
+// not NULL, else our delegate.
+gboolean TabContentsViewGtk::OnMouseMove(GtkWidget* widget,
+ GdkEventMotion* event) {
+ if (sad_tab_ != NULL)
+ WidgetGtk::OnMotionNotify(widget, event);
+ else if (tab_contents()->delegate())
+ tab_contents()->delegate()->ContentsMouseEvent(
+ tab_contents(), views::Screen::GetCursorScreenPoint(), true);
+ return FALSE;
+}
+
diff --git a/chrome/browser/views/tab_contents/tab_contents_view_gtk.h b/chrome/browser/views/tab_contents/tab_contents_view_gtk.h
index f9377a2..9e3cbdda 100644
--- a/chrome/browser/views/tab_contents/tab_contents_view_gtk.h
+++ b/chrome/browser/views/tab_contents/tab_contents_view_gtk.h
@@ -39,6 +39,8 @@ class TabContentsViewGtk : public TabContentsView,
void AttachConstrainedWindow(ConstrainedWindowGtk* constrained_window);
void RemoveConstrainedWindow(ConstrainedWindowGtk* constrained_window);
+ gboolean OnMouseMove(GtkWidget* widget, GdkEventMotion* event);
+
// TabContentsView implementation --------------------------------------------
virtual void CreateView(const gfx::Size& initial_size);
@@ -91,7 +93,7 @@ class TabContentsViewGtk : 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_;
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 96ae05d..90a3457 100644
--- a/chrome/browser/views/tab_contents/tab_contents_view_win.cc
+++ b/chrome/browser/views/tab_contents/tab_contents_view_win.cc
@@ -513,7 +513,7 @@ void TabContentsViewWin::OnPaint(HDC junk_dc) {
if (tab_contents()->render_view_host() &&
!tab_contents()->render_view_host()->IsRenderViewLive()) {
if (sad_tab_ == NULL) {
- sad_tab_ = new SadTabView;
+ sad_tab_ = new SadTabView(tab_contents());
SetContentsView(sad_tab_);
}
CRect cr;