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

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: Switch from reload link to reload button. 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
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 "views/controls/button/text_button.h"
20 #include "views/controls/image_view.h" 21 #include "views/controls/image_view.h"
21 #include "views/controls/label.h" 22 #include "views/controls/label.h"
22 #include "views/controls/link.h" 23 #include "views/controls/link.h"
23 #include "views/layout/grid_layout.h" 24 #include "views/layout/grid_layout.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);
(...skipping 23 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 if (tab_contents_ == NULL)
Peter Kasting 2011/11/21 21:31:06 Honestly, can we ever create a SadTabView() with a
kevers 2011/11/22 13:52:02 Done.
65 return;
66 if (source == help_link_) {
64 GURL help_url = 67 GURL help_url =
65 google_util::AppendGoogleLocaleParam(GURL(kind_ == CRASHED ? 68 google_util::AppendGoogleLocaleParam(GURL(kind_ == CRASHED ?
66 chrome::kCrashReasonURL : 69 chrome::kCrashReasonURL :
67 chrome::kKillReasonURL)); 70 chrome::kKillReasonURL));
68 tab_contents_->OpenURL( 71 tab_contents_->OpenURL(OpenURLParams(
69 help_url, GURL(), CURRENT_TAB, content::PAGE_TRANSITION_LINK); 72 help_url,
kevers 2011/11/21 17:42:49 This version of OpenURL has been deprecated. Sinc
70 } else if (tab_contents_ != NULL && source == feedback_link_) { 73 GURL(),
74 CURRENT_TAB,
75 content::PAGE_TRANSITION_LINK,
76 false /* is renderer initiated */));
77 } else if (source == feedback_link_) {
71 browser::ShowHtmlBugReportView( 78 browser::ShowHtmlBugReportView(
72 Browser::GetBrowserForController(&tab_contents_->controller(), NULL), 79 Browser::GetBrowserForController(&tab_contents_->controller(), NULL),
73 l10n_util::GetStringUTF8(IDS_KILLED_TAB_FEEDBACK_MESSAGE), 80 l10n_util::GetStringUTF8(IDS_KILLED_TAB_FEEDBACK_MESSAGE),
74 userfeedback::ChromeOsData_ChromeOsCategory_CRASH); 81 userfeedback::ChromeOsData_ChromeOsCategory_CRASH);
75 } 82 }
76 } 83 }
77 84
85 void SadTabView::ButtonPressed(
86 views::Button* source,
Peter Kasting 2011/11/21 21:31:06 Nit: Move to previous line, align next arg
kevers 2011/11/22 13:52:02 Done.
87 const views::Event& event) {
88 if (tab_contents_ == NULL)
Peter Kasting 2011/11/21 21:31:06 Nit: We only add the reload button if |tab_content
kevers 2011/11/22 13:52:02 Done.
89 return;
90 if (source == reload_button_)
91 tab_contents_->controller().Reload(true);
92 }
93
78 void SadTabView::Layout() { 94 void SadTabView::Layout() {
79 // Specify the maximum message width explicitly. 95 // Specify the maximum message width explicitly.
80 message_->SizeToFit(static_cast<int>(width() * kMessageSize)); 96 message_->SizeToFit(static_cast<int>(width() * kMessageSize));
81 View::Layout(); 97 View::Layout();
82 } 98 }
83 99
84 void SadTabView::ViewHierarchyChanged(bool is_add, 100 void SadTabView::ViewHierarchyChanged(bool is_add,
85 views::View* parent, 101 views::View* parent,
86 views::View* child) { 102 views::View* child) {
87 if (child != this || !is_add) 103 if (child != this || !is_add)
(...skipping 21 matching lines...) Expand all
109 layout->StartRowWithPadding(0, column_set_id, 0, kPadding); 125 layout->StartRowWithPadding(0, column_set_id, 0, kPadding);
110 layout->AddView(title); 126 layout->AddView(title);
111 127
112 message_ = CreateLabel(l10n_util::GetStringUTF16( 128 message_ = CreateLabel(l10n_util::GetStringUTF16(
113 (kind_ == CRASHED) ? IDS_SAD_TAB_MESSAGE : IDS_KILLED_TAB_MESSAGE)); 129 (kind_ == CRASHED) ? IDS_SAD_TAB_MESSAGE : IDS_KILLED_TAB_MESSAGE));
114 message_->SetMultiLine(true); 130 message_->SetMultiLine(true);
115 layout->StartRowWithPadding(0, column_set_id, 0, kPadding); 131 layout->StartRowWithPadding(0, column_set_id, 0, kPadding);
116 layout->AddView(message_); 132 layout->AddView(message_);
117 133
118 if (tab_contents_) { 134 if (tab_contents_) {
135 layout->StartRowWithPadding(0, column_set_id, 0, kPadding);
136 reload_button_ = CreateButton(
Peter Kasting 2011/11/21 21:31:06 Nit: Since this function is only called once, inli
kevers 2011/11/22 13:52:02 Done.
137 l10n_util::GetStringUTF16(IDS_SAD_TAB_RELOAD_LABEL));
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 views::TextButton* SadTabView::CreateButton(const string16& text) {
203 views::TextButton* button = new views::TextButton(this, text);
204 button->set_border(new views::TextButtonNativeThemeBorder(button));
205 return button;
206 }
207
OLDNEW
« chrome/browser/ui/views/sad_tab_view.h ('K') | « 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