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

Unified Diff: components/sad_tab/views/sad_tab_view.cc

Issue 543663002: Componentize sad_tab (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix url_constants.cc Created 6 years, 3 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/sad_tab/views/sad_tab_view.h ('k') | components/sad_tab_strings.grdp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/sad_tab/views/sad_tab_view.cc
diff --git a/chrome/browser/ui/views/sad_tab_view.cc b/components/sad_tab/views/sad_tab_view.cc
similarity index 87%
rename from chrome/browser/ui/views/sad_tab_view.cc
rename to components/sad_tab/views/sad_tab_view.cc
index 173455ecb87ba8aed454c7f4ceb5db9b65843fd6..fa84a7104d648a327655ee8ed0ddbb2a148a66d7 100644
--- a/chrome/browser/ui/views/sad_tab_view.cc
+++ b/components/sad_tab/views/sad_tab_view.cc
@@ -2,23 +2,19 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/ui/views/sad_tab_view.h"
+#include "components/sad_tab/views/sad_tab_view.h"
#include <string>
#include "base/metrics/field_trial.h"
#include "base/metrics/histogram.h"
#include "base/strings/utf_string_conversions.h"
-#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/browser_finder.h"
-#include "chrome/browser/ui/chrome_pages.h"
-#include "chrome/common/url_constants.h"
-#include "chrome/grit/generated_resources.h"
-#include "components/feedback/feedback_util.h"
+#include "components/sad_tab/sad_tab_client.h"
+#include "components/sad_tab/url_constants.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/web_contents.h"
+#include "grit/components_scaled_resources.h"
#include "grit/components_strings.h"
-#include "grit/theme_resources.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/views/background.h"
@@ -33,6 +29,8 @@
using content::OpenURLParams;
using content::WebContents;
+namespace sad_tab {
+
namespace {
const int kPadding = 20;
@@ -45,9 +43,12 @@ const char kCategoryTagCrash[] = "Crash";
} // namespace
-SadTabView::SadTabView(WebContents* web_contents, chrome::SadTabKind kind)
+SadTabView::SadTabView(WebContents* web_contents,
+ SadTabKind kind,
+ SadTabClient* client)
: web_contents_(web_contents),
kind_(kind),
+ client_(client),
painted_(false),
message_(NULL),
help_link_(NULL),
@@ -66,14 +67,14 @@ SadTabView::SadTabView(WebContents* web_contents, chrome::SadTabKind kind)
// directly compared.
// TODO(jamescook): Maybe track time between sad tabs?
switch (kind_) {
- case chrome::SAD_TAB_KIND_CRASHED: {
+ case SAD_TAB_KIND_CRASHED: {
static int crashed = 0;
crashed++;
UMA_HISTOGRAM_CUSTOM_COUNTS(
"Tabs.SadTab.CrashCreated", crashed, 1, 1000, 50);
break;
}
- case chrome::SAD_TAB_KIND_KILLED: {
+ case SAD_TAB_KIND_KILLED: {
static int killed = 0;
killed++;
UMA_HISTOGRAM_CUSTOM_COUNTS(
@@ -86,7 +87,7 @@ SadTabView::SadTabView(WebContents* web_contents, chrome::SadTabKind kind)
// Set the background color.
set_background(views::Background::CreateSolidBackground(
- (kind_ == chrome::SAD_TAB_KIND_CRASHED) ? kCrashColor : kKillColor));
+ (kind_ == SAD_TAB_KIND_CRASHED) ? kCrashColor : kKillColor));
views::GridLayout* layout = new views::GridLayout(this);
SetLayoutManager(layout);
@@ -100,12 +101,12 @@ SadTabView::SadTabView(WebContents* web_contents, chrome::SadTabKind kind)
views::ImageView* image = new views::ImageView();
image->SetImage(ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
- (kind_ == chrome::SAD_TAB_KIND_CRASHED) ? IDR_SAD_TAB : IDR_KILLED_TAB));
+ (kind_ == SAD_TAB_KIND_CRASHED) ? IDR_SAD_TAB : IDR_KILLED_TAB));
layout->StartRowWithPadding(0, column_set_id, 1, kPadding);
layout->AddView(image);
views::Label* title = CreateLabel(l10n_util::GetStringUTF16(
- (kind_ == chrome::SAD_TAB_KIND_CRASHED) ?
+ (kind_ == SAD_TAB_KIND_CRASHED) ?
IDS_SAD_TAB_TITLE : IDS_KILLED_TAB_TITLE));
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
title->SetFontList(rb.GetFontList(ui::ResourceBundle::MediumFont));
@@ -113,7 +114,7 @@ SadTabView::SadTabView(WebContents* web_contents, chrome::SadTabKind kind)
layout->AddView(title);
message_ = CreateLabel(l10n_util::GetStringUTF16(
- (kind_ == chrome::SAD_TAB_KIND_CRASHED) ?
+ (kind_ == SAD_TAB_KIND_CRASHED) ?
IDS_SAD_TAB_MESSAGE : IDS_KILLED_TAB_MESSAGE));
message_->SetMultiLine(true);
layout->StartRowWithPadding(0, column_set_id, 0, kPadding);
@@ -132,10 +133,10 @@ SadTabView::SadTabView(WebContents* web_contents, chrome::SadTabKind kind)
layout->AddView(reload_button_);
help_link_ = CreateLink(l10n_util::GetStringUTF16(
- (kind_ == chrome::SAD_TAB_KIND_CRASHED) ?
+ (kind_ == SAD_TAB_KIND_CRASHED) ?
IDS_SAD_TAB_HELP_LINK : IDS_LEARN_MORE));
- if (kind_ == chrome::SAD_TAB_KIND_CRASHED) {
+ if (kind_ == SAD_TAB_KIND_CRASHED) {
size_t offset = 0;
base::string16 help_text(
l10n_util::GetStringFUTF16(IDS_SAD_TAB_HELP_MESSAGE,
@@ -174,15 +175,15 @@ SadTabView::~SadTabView() {}
void SadTabView::LinkClicked(views::Link* source, int event_flags) {
DCHECK(web_contents_);
if (source == help_link_) {
- GURL help_url((kind_ == chrome::SAD_TAB_KIND_CRASHED) ?
- chrome::kCrashReasonURL : chrome::kKillReasonURL);
+ GURL help_url((kind_ == SAD_TAB_KIND_CRASHED) ?
+ kCrashReasonURL : kKillReasonURL);
OpenURLParams params(
help_url, content::Referrer(), CURRENT_TAB,
ui::PAGE_TRANSITION_LINK, false);
web_contents_->OpenURL(params);
} else if (source == feedback_link_) {
- chrome::ShowFeedbackPage(
- chrome::FindBrowserWithWebContents(web_contents_),
+ client_->ShowFeedbackPage(
+ web_contents_,
l10n_util::GetStringUTF8(IDS_KILLED_TAB_FEEDBACK_MESSAGE),
std::string(kCategoryTagCrash));
}
@@ -212,13 +213,13 @@ void SadTabView::OnPaint(gfx::Canvas* canvas) {
// for tab discard events in chromeos::OomPriorityManager so they
// can be directly compared.
switch (kind_) {
- case chrome::SAD_TAB_KIND_CRASHED: {
+ case SAD_TAB_KIND_CRASHED: {
static int crashed = 0;
UMA_HISTOGRAM_CUSTOM_COUNTS(
"Tabs.SadTab.CrashDisplayed", ++crashed, 1, 1000, 50);
break;
}
- case chrome::SAD_TAB_KIND_KILLED: {
+ case SAD_TAB_KIND_KILLED: {
static int killed = 0;
UMA_HISTOGRAM_CUSTOM_COUNTS(
"Tabs.SadTab.KillDisplayed", ++killed, 1, 1000, 50);
@@ -273,11 +274,10 @@ views::Link* SadTabView::CreateLink(const base::string16& text) {
return link;
}
-namespace chrome {
-
SadTab* SadTab::Create(content::WebContents* web_contents,
- SadTabKind kind) {
- return new SadTabView(web_contents, kind);
+ SadTabKind kind,
+ SadTabClient* client) {
+ return new SadTabView(web_contents, kind, client);
}
-} // namespace chrome
+} // namespace sad_tab
« no previous file with comments | « components/sad_tab/views/sad_tab_view.h ('k') | components/sad_tab_strings.grdp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698