Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Side by Side Diff: chrome/browser/ui/views/sad_tab_view.cc

Issue 8574074: Add reload button. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Replace conditional returns with DCHECKS. Formatting tweaks. Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/views/sad_tab_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/ui/views/sad_tab_view.h" 5 #include "chrome/browser/ui/views/sad_tab_view.h"
6 6
7 #include "base/metrics/histogram.h" 7 #include "base/metrics/histogram.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/google/google_util.h" 9 #include "chrome/browser/google/google_util.h"
10 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
11 #include "chrome/browser/ui/webui/bug_report_ui.h" 11 #include "chrome/browser/ui/webui/bug_report_ui.h"
12 #include "chrome/browser/userfeedback/proto/extension.pb.h" 12 #include "chrome/browser/userfeedback/proto/extension.pb.h"
13 #include "chrome/common/url_constants.h" 13 #include "chrome/common/url_constants.h"
14 #include "content/browser/tab_contents/tab_contents.h" 14 #include "content/browser/tab_contents/tab_contents.h"
15 #include "grit/generated_resources.h" 15 #include "grit/generated_resources.h"
16 #include "grit/theme_resources.h" 16 #include "grit/theme_resources.h"
17 #include "ui/base/l10n/l10n_util.h" 17 #include "ui/base/l10n/l10n_util.h"
18 #include "ui/base/resource/resource_bundle.h" 18 #include "ui/base/resource/resource_bundle.h"
19 #include "ui/gfx/font.h" 19 #include "ui/gfx/font.h"
20 #include "ui/views/layout/grid_layout.h" 20 #include "ui/views/layout/grid_layout.h"
21 #include "views/controls/button/text_button.h"
21 #include "views/controls/image_view.h" 22 #include "views/controls/image_view.h"
22 #include "views/controls/label.h" 23 #include "views/controls/label.h"
23 #include "views/controls/link.h" 24 #include "views/controls/link.h"
24 25
25 static const int kPadding = 20; 26 static const int kPadding = 20;
26 static const float kMessageSize = 0.65f; 27 static const float kMessageSize = 0.65f;
27 static const SkColor kTextColor = SK_ColorWHITE; 28 static const SkColor kTextColor = SK_ColorWHITE;
28 static const SkColor kCrashColor = SkColorSetRGB(35, 48, 64); 29 static const SkColor kCrashColor = SkColorSetRGB(35, 48, 64);
29 static const SkColor kKillColor = SkColorSetRGB(57, 48, 88); 30 static const SkColor kKillColor = SkColorSetRGB(57, 48, 88);
30 31
(...skipping 22 matching lines...) Expand all
53 UMA_HISTOGRAM_COUNTS("SadTab.Created", kind_); 54 UMA_HISTOGRAM_COUNTS("SadTab.Created", kind_);
54 55
55 // Set the background color. 56 // Set the background color.
56 set_background(views::Background::CreateSolidBackground( 57 set_background(views::Background::CreateSolidBackground(
57 (kind_ == CRASHED) ? kCrashColor : kKillColor)); 58 (kind_ == CRASHED) ? kCrashColor : kKillColor));
58 } 59 }
59 60
60 SadTabView::~SadTabView() {} 61 SadTabView::~SadTabView() {}
61 62
62 void SadTabView::LinkClicked(views::Link* source, int event_flags) { 63 void SadTabView::LinkClicked(views::Link* source, int event_flags) {
63 if (tab_contents_ != NULL && source == help_link_) { 64 DCHECK(tab_contents_);
65 if (source == help_link_) {
64 GURL help_url = 66 GURL help_url =
65 google_util::AppendGoogleLocaleParam(GURL(kind_ == CRASHED ? 67 google_util::AppendGoogleLocaleParam(GURL(kind_ == CRASHED ?
66 chrome::kCrashReasonURL : 68 chrome::kCrashReasonURL :
67 chrome::kKillReasonURL)); 69 chrome::kKillReasonURL));
68 tab_contents_->OpenURL( 70 tab_contents_->OpenURL(OpenURLParams(
69 help_url, GURL(), CURRENT_TAB, content::PAGE_TRANSITION_LINK); 71 help_url,
70 } else if (tab_contents_ != NULL && source == feedback_link_) { 72 GURL(),
73 CURRENT_TAB,
74 content::PAGE_TRANSITION_LINK,
75 false /* is renderer initiated */));
76 } else if (source == feedback_link_) {
71 browser::ShowHtmlBugReportView( 77 browser::ShowHtmlBugReportView(
72 Browser::GetBrowserForController(&tab_contents_->controller(), NULL), 78 Browser::GetBrowserForController(&tab_contents_->controller(), NULL),
73 l10n_util::GetStringUTF8(IDS_KILLED_TAB_FEEDBACK_MESSAGE), 79 l10n_util::GetStringUTF8(IDS_KILLED_TAB_FEEDBACK_MESSAGE),
74 userfeedback::ChromeOsData_ChromeOsCategory_CRASH); 80 userfeedback::ChromeOsData_ChromeOsCategory_CRASH);
75 } 81 }
76 } 82 }
77 83
84 void SadTabView::ButtonPressed(views::Button* source,
85 const views::Event& event) {
86 DCHECK(tab_contents_);
87 DCHECK(source == reload_button_);
88 tab_contents_->controller().Reload(true);
89 }
90
78 void SadTabView::Layout() { 91 void SadTabView::Layout() {
79 // Specify the maximum message width explicitly. 92 // Specify the maximum message width explicitly.
80 message_->SizeToFit(static_cast<int>(width() * kMessageSize)); 93 message_->SizeToFit(static_cast<int>(width() * kMessageSize));
81 View::Layout(); 94 View::Layout();
82 } 95 }
83 96
84 void SadTabView::ViewHierarchyChanged(bool is_add, 97 void SadTabView::ViewHierarchyChanged(bool is_add,
85 views::View* parent, 98 views::View* parent,
86 views::View* child) { 99 views::View* child) {
87 if (child != this || !is_add) 100 if (child != this || !is_add)
(...skipping 21 matching lines...) Expand all
109 layout->StartRowWithPadding(0, column_set_id, 0, kPadding); 122 layout->StartRowWithPadding(0, column_set_id, 0, kPadding);
110 layout->AddView(title); 123 layout->AddView(title);
111 124
112 message_ = CreateLabel(l10n_util::GetStringUTF16( 125 message_ = CreateLabel(l10n_util::GetStringUTF16(
113 (kind_ == CRASHED) ? IDS_SAD_TAB_MESSAGE : IDS_KILLED_TAB_MESSAGE)); 126 (kind_ == CRASHED) ? IDS_SAD_TAB_MESSAGE : IDS_KILLED_TAB_MESSAGE));
114 message_->SetMultiLine(true); 127 message_->SetMultiLine(true);
115 layout->StartRowWithPadding(0, column_set_id, 0, kPadding); 128 layout->StartRowWithPadding(0, column_set_id, 0, kPadding);
116 layout->AddView(message_); 129 layout->AddView(message_);
117 130
118 if (tab_contents_) { 131 if (tab_contents_) {
132 layout->StartRowWithPadding(0, column_set_id, 0, kPadding);
133 reload_button_ = new views::TextButton(
134 this,
135 l10n_util::GetStringUTF16(IDS_SAD_TAB_RELOAD_LABEL));
136 reload_button_->set_border(new views::TextButtonNativeThemeBorder(
137 reload_button_));
138 layout->AddView(reload_button_);
139
119 help_link_ = CreateLink(l10n_util::GetStringUTF16( 140 help_link_ = CreateLink(l10n_util::GetStringUTF16(
120 (kind_ == CRASHED) ? IDS_SAD_TAB_HELP_LINK : IDS_LEARN_MORE)); 141 (kind_ == CRASHED) ? IDS_SAD_TAB_HELP_LINK : IDS_LEARN_MORE));
121 142
122 if (kind_ == CRASHED) { 143 if (kind_ == CRASHED) {
123 size_t offset = 0; 144 size_t offset = 0;
124 string16 help_text(l10n_util::GetStringFUTF16(IDS_SAD_TAB_HELP_MESSAGE, 145 string16 help_text(l10n_util::GetStringFUTF16(IDS_SAD_TAB_HELP_MESSAGE,
125 string16(), &offset)); 146 string16(), &offset));
126 views::Label* help_prefix = CreateLabel(help_text.substr(0, offset)); 147 views::Label* help_prefix = CreateLabel(help_text.substr(0, offset));
127 views::Label* help_suffix = CreateLabel(help_text.substr(offset)); 148 views::Label* help_suffix = CreateLabel(help_text.substr(offset));
128 149
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 } 191 }
171 192
172 views::Link* SadTabView::CreateLink(const string16& text) { 193 views::Link* SadTabView::CreateLink(const string16& text) {
173 views::Link* link = new views::Link(text); 194 views::Link* link = new views::Link(text);
174 link->SetFont(base_font_.DeriveFont(kMessageFontSizeDelta)); 195 link->SetFont(base_font_.DeriveFont(kMessageFontSizeDelta));
175 link->SetBackgroundColor(background()->get_color()); 196 link->SetBackgroundColor(background()->get_color());
176 link->SetEnabledColor(kTextColor); 197 link->SetEnabledColor(kTextColor);
177 link->set_listener(this); 198 link->set_listener(this);
178 return link; 199 return link;
179 } 200 }
201
202
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/sad_tab_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698