diff --git a/build/ios/grit_whitelist.txt b/build/ios/grit_whitelist.txt
index 00e5107d077982..d9169e4de0baa1 100644
--- a/build/ios/grit_whitelist.txt
+++ b/build/ios/grit_whitelist.txt
@@ -57,7 +57,6 @@ IDR_POLICY_HTML
IDR_POLICY_JS
IDR_PREF_HASH_SEED_BIN
IDR_PRINTER_FAVICON
-IDR_SAD_FAVICON
IDR_SAD_TAB
IDR_SIGNIN_INTERNALS_INDEX_HTML
IDR_SIGNIN_INTERNALS_INDEX_JS
diff --git a/chrome/app/theme/theme_resources.grd b/chrome/app/theme/theme_resources.grd
index 17e91d6d44392c..6eca5e53a17f39 100644
--- a/chrome/app/theme/theme_resources.grd
+++ b/chrome/app/theme/theme_resources.grd
@@ -802,7 +802,6 @@
-
diff --git a/chrome/browser/ui/BUILD.gn b/chrome/browser/ui/BUILD.gn
index 42718b9ae72446..8811af527ade69 100644
--- a/chrome/browser/ui/BUILD.gn
+++ b/chrome/browser/ui/BUILD.gn
@@ -94,6 +94,7 @@ source_set("ui") {
"//chrome/installer/util",
"//components/autofill/content/browser:risk_proto",
"//components/bubble:bubble",
+ "//components/crash/core/browser",
"//components/net_log",
"//components/page_load_metrics/browser",
"//components/power",
diff --git a/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm b/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm
index 9fe0804d70d90e..4ba29c186a6be3 100644
--- a/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm
+++ b/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm
@@ -56,6 +56,7 @@
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/user_metrics.h"
#include "content/public/browser/web_contents.h"
+#include "grit/components_scaled_resources.h"
#include "grit/theme_resources.h"
#include "skia/ext/skia_utils_mac.h"
#import "third_party/google_toolbox_for_mac/src/AppKit/GTMNSAnimation+Duration.h"
@@ -1578,8 +1579,9 @@ - (void)updateIconsForContents:(content::WebContents*)contents
ResourceBundle::GetSharedInstance().GetNativeImageNamed(
IDR_THROBBER).CopyNSImage();
static NSImage* sadFaviconImage =
- ResourceBundle::GetSharedInstance().GetNativeImageNamed(
- IDR_SAD_FAVICON).CopyNSImage();
+ ResourceBundle::GetSharedInstance()
+ .GetNativeImageNamed(IDR_CRASH_SAD_FAVICON)
+ .CopyNSImage();
// Take closing tabs into account.
NSInteger index = [self indexFromModelIndex:modelIndex];
diff --git a/chrome/browser/ui/views/tabs/tab.cc b/chrome/browser/ui/views/tabs/tab.cc
index 6d0d78ae342129..d2734b3db8773e 100644
--- a/chrome/browser/ui/views/tabs/tab.cc
+++ b/chrome/browser/ui/views/tabs/tab.cc
@@ -23,6 +23,7 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/grit/generated_resources.h"
#include "content/public/browser/user_metrics.h"
+#include "grit/components_scaled_resources.h"
#include "grit/theme_resources.h"
#include "third_party/skia/include/effects/SkGradientShader.h"
#include "ui/accessibility/ax_view_state.h"
@@ -1372,7 +1373,8 @@ void Tab::PaintIcon(gfx::Canvas* canvas) {
} else if (should_display_crashed_favicon_) {
// Paint crash favicon.
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
- gfx::ImageSkia crashed_favicon(*rb.GetImageSkiaNamed(IDR_SAD_FAVICON));
+ gfx::ImageSkia crashed_favicon(
+ *rb.GetImageSkiaNamed(IDR_CRASH_SAD_FAVICON));
bounds.set_y(bounds.y() + favicon_hiding_offset_);
DrawIconCenter(canvas, crashed_favicon, 0,
crashed_favicon.width(),
diff --git a/chrome/browser/ui/webui/crashes_ui.cc b/chrome/browser/ui/webui/crashes_ui.cc
index 14dd72938227de..5961b224c8f5f4 100644
--- a/chrome/browser/ui/webui/crashes_ui.cc
+++ b/chrome/browser/ui/webui/crashes_ui.cc
@@ -4,11 +4,8 @@
#include "chrome/browser/ui/webui/crashes_ui.h"
-#include
-
#include "base/bind.h"
#include "base/bind_helpers.h"
-#include "base/i18n/time_formatting.h"
#include "base/memory/ref_counted_memory.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
@@ -19,6 +16,7 @@
#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/grit/google_chrome_strings.h"
+#include "components/crash/core/browser/crashes_ui_util.h"
#include "components/version_info/version_info.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
@@ -28,8 +26,8 @@
#include "grit/components_chromium_strings.h"
#include "grit/components_google_chrome_strings.h"
#include "grit/components_resources.h"
+#include "grit/components_scaled_resources.h"
#include "grit/components_strings.h"
-#include "grit/theme_resources.h"
#include "ui/base/resource/resource_bundle.h"
#if defined(OS_CHROMEOS)
@@ -46,22 +44,16 @@ content::WebUIDataSource* CreateCrashesUIHTMLSource() {
content::WebUIDataSource* source =
content::WebUIDataSource::Create(chrome::kChromeUICrashesHost);
- source->AddLocalizedString("shortProductName", IDS_SHORT_PRODUCT_NAME);
- source->AddLocalizedString("crashesTitle", IDS_CRASH_TITLE);
- source->AddLocalizedString("crashCountFormat",
- IDS_CRASH_CRASH_COUNT_BANNER_FORMAT);
- source->AddLocalizedString("crashHeaderFormat",
- IDS_CRASH_CRASH_HEADER_FORMAT);
- source->AddLocalizedString("crashTimeFormat", IDS_CRASH_CRASH_TIME_FORMAT);
- source->AddLocalizedString("bugLinkText", IDS_CRASH_BUG_LINK_LABEL);
- source->AddLocalizedString("noCrashesMessage",
- IDS_CRASH_NO_CRASHES_MESSAGE);
- source->AddLocalizedString("disabledHeader", IDS_CRASH_DISABLED_HEADER);
- source->AddLocalizedString("disabledMessage", IDS_CRASH_DISABLED_MESSAGE);
- source->AddLocalizedString("uploadCrashesLinkText",
- IDS_CRASH_UPLOAD_MESSAGE);
+ for (size_t i = 0; i < crash::kCrashesUILocalizedStringsCount; ++i) {
+ source->AddLocalizedString(
+ crash::kCrashesUILocalizedStrings[i].name,
+ crash::kCrashesUILocalizedStrings[i].resource_id);
+ }
+
+ source->AddLocalizedString(crash::kCrashesUIShortProductName,
+ IDS_SHORT_PRODUCT_NAME);
source->SetJsonPath("strings.js");
- source->AddResourcePath("crashes.js", IDR_CRASH_CRASHES_JS);
+ source->AddResourcePath(crash::kCrashesUICrashesJS, IDR_CRASH_CRASHES_JS);
source->SetDefaultResource(IDR_CRASH_CRASHES_HTML);
return source;
}
@@ -115,12 +107,14 @@ CrashesDOMHandler::~CrashesDOMHandler() {
void CrashesDOMHandler::RegisterMessages() {
upload_list_->LoadUploadListAsynchronously();
- web_ui()->RegisterMessageCallback("requestCrashList",
+ web_ui()->RegisterMessageCallback(
+ crash::kCrashesUIRequestCrashList,
base::Bind(&CrashesDOMHandler::HandleRequestCrashes,
base::Unretained(this)));
#if defined(OS_CHROMEOS)
- web_ui()->RegisterMessageCallback("requestCrashUpload",
+ web_ui()->RegisterMessageCallback(
+ crash::kCrashesUIRequestCrashUpload,
base::Bind(&CrashesDOMHandler::HandleRequestUploads,
base::Unretained(this)));
#endif
@@ -156,35 +150,22 @@ void CrashesDOMHandler::OnUploadListAvailable() {
void CrashesDOMHandler::UpdateUI() {
bool crash_reporting_enabled =
ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled();
- base::ListValue crash_list;
- bool system_crash_reporter = false;
+ bool system_crash_reporter = false;
#if defined(OS_CHROMEOS)
// Chrome OS has a system crash reporter.
system_crash_reporter = true;
#endif
- if (crash_reporting_enabled) {
- std::vector crashes;
- upload_list_->GetUploads(50, &crashes);
-
- for (std::vector::iterator i = crashes.begin();
- i != crashes.end(); ++i) {
- base::DictionaryValue* crash = new base::DictionaryValue();
- crash->SetString("id", i->id);
- crash->SetString("time", base::TimeFormatFriendlyDateAndTime(i->time));
- crash->SetString("local_id", i->local_id);
- crash_list.Append(crash);
- }
- }
+ base::ListValue crash_list;
+ if (crash_reporting_enabled)
+ crash::UploadListToValue(upload_list_.get(), &crash_list);
base::FundamentalValue enabled(crash_reporting_enabled);
base::FundamentalValue dynamic_backend(system_crash_reporter);
-
base::StringValue version(version_info::GetVersionNumber());
-
- web_ui()->CallJavascriptFunction("updateCrashList", enabled, dynamic_backend,
- crash_list, version);
+ web_ui()->CallJavascriptFunction(crash::kCrashesUIUpdateCrashList, enabled,
+ dynamic_backend, crash_list, version);
}
} // namespace
@@ -206,6 +187,6 @@ CrashesUI::CrashesUI(content::WebUI* web_ui) : WebUIController(web_ui) {
// static
base::RefCountedMemory* CrashesUI::GetFaviconResourceBytes(
ui::ScaleFactor scale_factor) {
- return ResourceBundle::GetSharedInstance().
- LoadDataResourceBytesForScale(IDR_SAD_FAVICON, scale_factor);
+ return ResourceBundle::GetSharedInstance().LoadDataResourceBytesForScale(
+ IDR_CRASH_SAD_FAVICON, scale_factor);
}
diff --git a/chrome/chrome_browser_ui.gypi b/chrome/chrome_browser_ui.gypi
index ce1ee3ab08e336..1c49769866ef77 100644
--- a/chrome/chrome_browser_ui.gypi
+++ b/chrome/chrome_browser_ui.gypi
@@ -2816,6 +2816,7 @@
'installer_util',
'../components/components.gyp:app_modal',
'../components/components.gyp:autofill_content_risk_proto',
+ '../components/components.gyp:crash_core_browser',
'../components/components.gyp:flags_ui',
'../components/components.gyp:net_log',
'../components/components.gyp:page_load_metrics_browser',
diff --git a/components/crash.gypi b/components/crash.gypi
index 6acfdfc4dd4b22..8ad506d283479c 100644
--- a/components/crash.gypi
+++ b/components/crash.gypi
@@ -4,6 +4,23 @@
{
'targets': [
+ {
+ # GN version: //components/crash/core/browser
+ 'target_name': 'crash_core_browser',
+ 'type': 'static_library',
+ 'include_dirs': [
+ '..',
+ ],
+ 'dependencies': [
+ 'upload_list',
+ '../base/base.gyp:base',
+ '../components/components_strings.gyp:components_strings',
+ ],
+ 'sources': [
+ 'crash/core/browser/crashes_ui_util.cc',
+ 'crash/core/browser/crashes_ui_util.h',
+ ],
+ },
{
# GN version: //components/crash/core/common
'target_name': 'crash_core_common',
diff --git a/components/crash/core/browser/BUILD.gn b/components/crash/core/browser/BUILD.gn
new file mode 100644
index 00000000000000..0ba13063b5d2d9
--- /dev/null
+++ b/components/crash/core/browser/BUILD.gn
@@ -0,0 +1,15 @@
+# Copyright 2015 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+source_set("browser") {
+ sources = [
+ "crashes_ui_util.cc",
+ "crashes_ui_util.h",
+ ]
+ deps = [
+ "//base",
+ "//components/strings",
+ "//components/upload_list",
+ ]
+}
diff --git a/components/crash/core/browser/DEPS b/components/crash/core/browser/DEPS
new file mode 100644
index 00000000000000..00f4fc386aa816
--- /dev/null
+++ b/components/crash/core/browser/DEPS
@@ -0,0 +1,6 @@
+include_rules = [
+ "+components/upload_list",
+ "+grit/components_chromium_strings.h",
+ "+grit/components_google_chrome_strings.h",
+ "+grit/components_strings.h",
+]
diff --git a/components/crash/core/browser/crashes_ui_util.cc b/components/crash/core/browser/crashes_ui_util.cc
new file mode 100644
index 00000000000000..bd74af6056f18b
--- /dev/null
+++ b/components/crash/core/browser/crashes_ui_util.cc
@@ -0,0 +1,53 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/crash/core/browser/crashes_ui_util.h"
+
+#include
+
+#include "base/i18n/time_formatting.h"
+#include "base/macros.h"
+#include "base/values.h"
+#include "components/upload_list/upload_list.h"
+#include "grit/components_chromium_strings.h"
+#include "grit/components_google_chrome_strings.h"
+#include "grit/components_strings.h"
+
+namespace crash {
+
+const CrashesUILocalizedString kCrashesUILocalizedStrings[] = {
+ {"bugLinkText", IDS_CRASH_BUG_LINK_LABEL},
+ {"crashCountFormat", IDS_CRASH_CRASH_COUNT_BANNER_FORMAT},
+ {"crashHeaderFormat", IDS_CRASH_CRASH_HEADER_FORMAT},
+ {"crashTimeFormat", IDS_CRASH_CRASH_TIME_FORMAT},
+ {"crashesTitle", IDS_CRASH_TITLE},
+ {"disabledHeader", IDS_CRASH_DISABLED_HEADER},
+ {"disabledMessage", IDS_CRASH_DISABLED_MESSAGE},
+ {"noCrashesMessage", IDS_CRASH_NO_CRASHES_MESSAGE},
+ {"uploadCrashesLinkText", IDS_CRASH_UPLOAD_MESSAGE},
+};
+
+const size_t kCrashesUILocalizedStringsCount =
+ arraysize(kCrashesUILocalizedStrings);
+
+const char kCrashesUICrashesJS[] = "crashes.js";
+const char kCrashesUIRequestCrashList[] = "requestCrashList";
+const char kCrashesUIRequestCrashUpload[] = "requestCrashUpload";
+const char kCrashesUIShortProductName[] = "shortProductName";
+const char kCrashesUIUpdateCrashList[] = "updateCrashList";
+
+void UploadListToValue(UploadList* upload_list, base::ListValue* out_value) {
+ std::vector crashes;
+ upload_list->GetUploads(50, &crashes);
+
+ for (const auto& info : crashes) {
+ base::DictionaryValue* crash = new base::DictionaryValue();
+ crash->SetString("id", info.id);
+ crash->SetString("time", base::TimeFormatFriendlyDateAndTime(info.time));
+ crash->SetString("local_id", info.local_id);
+ out_value->Append(crash);
+ }
+}
+
+} // namespace crash
diff --git a/components/crash/core/browser/crashes_ui_util.h b/components/crash/core/browser/crashes_ui_util.h
new file mode 100644
index 00000000000000..d24f0096fb8f5f
--- /dev/null
+++ b/components/crash/core/browser/crashes_ui_util.h
@@ -0,0 +1,42 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_CRASH_CORE_BROWSER_CRASHES_UI_UTIL_H_
+#define COMPONENTS_CRASH_CORE_BROWSER_CRASHES_UI_UTIL_H_
+
+#include
+
+namespace base {
+class ListValue;
+}
+
+class UploadList;
+
+namespace crash {
+
+// Mapping between a WebUI resource (identified by |name|) and a GRIT resource
+// (identified by |resource_id|).
+struct CrashesUILocalizedString {
+ const char* name;
+ int resource_id;
+};
+
+// List of localized strings that must be added to the WebUI.
+extern const CrashesUILocalizedString kCrashesUILocalizedStrings[];
+extern const size_t kCrashesUILocalizedStringsCount;
+
+// Strings used by the WebUI resources.
+// Must match the constants used in the resource files.
+extern const char kCrashesUICrashesJS[];
+extern const char kCrashesUIRequestCrashList[];
+extern const char kCrashesUIRequestCrashUpload[];
+extern const char kCrashesUIShortProductName[];
+extern const char kCrashesUIUpdateCrashList[];
+
+// Converts and appends the most recent uploads to |out_value|.
+void UploadListToValue(UploadList* upload_list, base::ListValue* out_value);
+
+} // namespace crash
+
+#endif // COMPONENTS_CRASH_CORE_BROWSER_CRASHES_UI_UTIL_H_
diff --git a/components/resources/OWNERS b/components/resources/OWNERS
index 7d73d577aa5e8d..3b3d0757bb0ed3 100644
--- a/components/resources/OWNERS
+++ b/components/resources/OWNERS
@@ -1,10 +1,10 @@
per-file autofill_scaled_resources.grdp=estade@chromium.org
-per-file crash_resources.grdp=cpu@chromium.org
-per-file crash_resources.grdp=jochen@chromium.org
-per-file crash_resources.grdp=mark@chromium.org
-per-file crash_resources.grdp=rsesek@chromium.org
-per-file crash_resources.grdp=scottmg@chromium.org
-per-file crash_resources.grdp=thestig@chromium.org
+per-file crash_*=cpu@chromium.org
+per-file crash_*=jochen@chromium.org
+per-file crash_*=mark@chromium.org
+per-file crash_*=rsesek@chromium.org
+per-file crash_*=scottmg@chromium.org
+per-file crash_*=thestig@chromium.org
per-file data_reduction_proxy*=bengr@chromium.org
per-file data_reduction_proxy*=sclittle@chromium.org
per-file data_reduction_proxy*=megjablon@chromium.org
diff --git a/components/resources/components_scaled_resources.grd b/components/resources/components_scaled_resources.grd
index fcb9a367f2ca90..f92a349cf416e7 100644
--- a/components/resources/components_scaled_resources.grd
+++ b/components/resources/components_scaled_resources.grd
@@ -13,6 +13,7 @@
+
diff --git a/components/resources/crash_scaled_resources.grdp b/components/resources/crash_scaled_resources.grdp
new file mode 100644
index 00000000000000..25ddde1b66f936
--- /dev/null
+++ b/components/resources/crash_scaled_resources.grdp
@@ -0,0 +1,4 @@
+
+
+
+
diff --git a/chrome/app/theme/default_100_percent/common/favicon_sad_tab.png b/components/resources/default_100_percent/crash/favicon_sad_tab.png
similarity index 100%
rename from chrome/app/theme/default_100_percent/common/favicon_sad_tab.png
rename to components/resources/default_100_percent/crash/favicon_sad_tab.png
diff --git a/chrome/app/theme/default_200_percent/common/favicon_sad_tab.png b/components/resources/default_200_percent/crash/favicon_sad_tab.png
similarity index 100%
rename from chrome/app/theme/default_200_percent/common/favicon_sad_tab.png
rename to components/resources/default_200_percent/crash/favicon_sad_tab.png
diff --git a/chrome/app/theme/default_300_percent/common/favicon_sad_tab.png b/components/resources/default_300_percent/crash/favicon_sad_tab.png
similarity index 100%
rename from chrome/app/theme/default_300_percent/common/favicon_sad_tab.png
rename to components/resources/default_300_percent/crash/favicon_sad_tab.png