Commit f5590fbf authored by Joon Ahn's avatar Joon Ahn Committed by Commit Bot

Link to crashes/ for internal accounts

Make the crash ID clickable for Googlers and redirect to http://crash/crash_id


Fixed: 1009148
Change-Id: Icf26d9c7ac2bf78beb00a17d5a85d50c29c94ecb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1888534
Commit-Queue: Joon Ahn <joonbug@chromium.org>
Reviewed-by: default avatarBoris Sazonov <bsazonov@chromium.org>
Reviewed-by: default avatarcalamity <calamity@chromium.org>
Reviewed-by: default avatarIan Barkley-Yeung <iby@chromium.org>
Cr-Commit-Position: refs/heads/master@{#714031}
parent 1b92767a
...@@ -20,16 +20,19 @@ ...@@ -20,16 +20,19 @@
#include "chrome/browser/metrics/chrome_metrics_service_accessor.h" #include "chrome/browser/metrics/chrome_metrics_service_accessor.h"
#include "chrome/browser/metrics/metrics_reporting_state.h" #include "chrome/browser/metrics/metrics_reporting_state.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/common/url_constants.h" #include "chrome/common/url_constants.h"
#include "chrome/grit/chromium_strings.h" #include "chrome/grit/chromium_strings.h"
#include "components/crash/core/browser/crashes_ui_util.h" #include "components/crash/core/browser/crashes_ui_util.h"
#include "components/grit/components_resources.h" #include "components/grit/components_resources.h"
#include "components/grit/components_scaled_resources.h" #include "components/grit/components_scaled_resources.h"
#include "components/signin/public/identity_manager/identity_manager.h"
#include "components/version_info/version_info.h" #include "components/version_info/version_info.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h" #include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h" #include "content/public/browser/web_ui_data_source.h"
#include "content/public/browser/web_ui_message_handler.h" #include "content/public/browser/web_ui_message_handler.h"
#include "google_apis/gaia/gaia_auth_util.h"
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
...@@ -181,6 +184,14 @@ void CrashesDOMHandler::UpdateUI() { ...@@ -181,6 +184,14 @@ void CrashesDOMHandler::UpdateUI() {
using_crashpad = crash_reporter::IsCrashpadEnabled(); using_crashpad = crash_reporter::IsCrashpadEnabled();
#endif #endif
bool is_internal = false;
auto* identity_manager =
IdentityManagerFactory::GetForProfile(Profile::FromWebUI(web_ui()));
if (identity_manager) {
is_internal = gaia::IsGoogleInternalAccountEmail(
identity_manager->GetPrimaryAccountInfo().email);
}
// Manual uploads currently are supported only for Crashpad-using platforms // Manual uploads currently are supported only for Crashpad-using platforms
// and only if crash uploads are not disabled by policy. // and only if crash uploads are not disabled by policy.
bool support_manual_uploads = bool support_manual_uploads =
...@@ -201,6 +212,7 @@ void CrashesDOMHandler::UpdateUI() { ...@@ -201,6 +212,7 @@ void CrashesDOMHandler::UpdateUI() {
base::Value version(version_info::GetVersionNumber()); base::Value version(version_info::GetVersionNumber());
base::Value os_string(base::SysInfo::OperatingSystemName() + " " + base::Value os_string(base::SysInfo::OperatingSystemName() + " " +
base::SysInfo::OperatingSystemVersion()); base::SysInfo::OperatingSystemVersion());
base::Value is_google_account(is_internal);
std::vector<const base::Value*> args; std::vector<const base::Value*> args;
args.push_back(&enabled); args.push_back(&enabled);
...@@ -209,6 +221,7 @@ void CrashesDOMHandler::UpdateUI() { ...@@ -209,6 +221,7 @@ void CrashesDOMHandler::UpdateUI() {
args.push_back(&crash_list); args.push_back(&crash_list);
args.push_back(&version); args.push_back(&version);
args.push_back(&os_string); args.push_back(&os_string);
args.push_back(&is_google_account);
web_ui()->CallJavascriptFunctionUnsafe( web_ui()->CallJavascriptFunctionUnsafe(
crash_reporter::kCrashesUIUpdateCrashList, args); crash_reporter::kCrashesUIUpdateCrashList, args);
} }
......
...@@ -20,10 +20,11 @@ function requestCrashes() { ...@@ -20,10 +20,11 @@ function requestCrashes() {
* @param {array} crashes The list of crashes. * @param {array} crashes The list of crashes.
* @param {string} version The browser version. * @param {string} version The browser version.
* @param {string} os The OS name and version. * @param {string} os The OS name and version.
* @param {boolean} isGoogleAccount whether primary account is internal.
*/ */
function updateCrashList( function updateCrashList(
enabled, dynamicBackend, manualUploads, enabled, dynamicBackend, manualUploads,
crashes, version, os) { crashes, version, os, isGoogleAccount) {
$('countBanner').textContent = $('countBanner').textContent =
loadTimeData.getStringF('crashCountFormat', loadTimeData.getStringF('crashCountFormat',
crashes.length.toLocaleString()); crashes.length.toLocaleString());
...@@ -55,9 +56,23 @@ function updateCrashList( ...@@ -55,9 +56,23 @@ function updateCrashList(
var title = document.createElement('h3'); var title = document.createElement('h3');
var uploaded = crash.state == 'uploaded'; var uploaded = crash.state == 'uploaded';
if (uploaded) { if (uploaded) {
title.textContent = loadTimeData.getStringF('crashHeaderFormat', const crashHeaderText = loadTimeData.getString('crashHeaderFormat');
crash.id, const pieces = loadTimeData
crash.local_id); .getSubstitutedStringPieces(
crashHeaderText, crash.id, crash.local_id)
.map(piece => {
// Create crash/ link for Googler Accounts.
if (isGoogleAccount && piece.value === crash.id) {
const crashLink = document.createElement('a');
crashLink.href = `http://crash/${crash.id}`;
crashLink.target = '_blank';
crashLink.textContent = crash.id;
return crashLink;
} else {
return piece.value;
}
});
title.append.apply(title, pieces);
} else { } else {
title.textContent = loadTimeData.getStringF('crashHeaderFormatLocalOnly', title.textContent = loadTimeData.getStringF('crashHeaderFormatLocalOnly',
crash.local_id); crash.local_id);
......
...@@ -24,6 +24,7 @@ namespace gaia { ...@@ -24,6 +24,7 @@ namespace gaia {
namespace { namespace {
const char kGmailDomain[] = "gmail.com"; const char kGmailDomain[] = "gmail.com";
const char kGoogleDomain[] = "google.com";
const char kGooglemailDomain[] = "googlemail.com"; const char kGooglemailDomain[] = "googlemail.com";
const void* const kURLRequestUserDataKey = &kURLRequestUserDataKey; const void* const kURLRequestUserDataKey = &kURLRequestUserDataKey;
...@@ -105,6 +106,10 @@ std::string ExtractDomainName(const std::string& email_address) { ...@@ -105,6 +106,10 @@ std::string ExtractDomainName(const std::string& email_address) {
return std::string(); return std::string();
} }
bool IsGoogleInternalAccountEmail(const std::string& email) {
return ExtractDomainName(email) == kGoogleDomain;
}
bool IsGaiaSignonRealm(const GURL& url) { bool IsGaiaSignonRealm(const GURL& url) {
if (!url.SchemeIsCryptographic()) if (!url.SchemeIsCryptographic())
return false; return false;
......
...@@ -52,6 +52,10 @@ bool AreEmailsSame(const std::string& email1, const std::string& email2); ...@@ -52,6 +52,10 @@ bool AreEmailsSame(const std::string& email1, const std::string& email2);
// Extract the domain part from the canonical form of the given email. // Extract the domain part from the canonical form of the given email.
std::string ExtractDomainName(const std::string& email); std::string ExtractDomainName(const std::string& email);
// Returns whether the user's email is Google internal. This check is meant
// to be used sparingly since it ship Googler-only code to all users.
bool IsGoogleInternalAccountEmail(const std::string& email);
bool IsGaiaSignonRealm(const GURL& url); bool IsGaiaSignonRealm(const GURL& url);
// Parses JSON data returned by /ListAccounts call, returning a vector of // Parses JSON data returned by /ListAccounts call, returning a vector of
......
...@@ -84,6 +84,11 @@ TEST(GaiaAuthUtilTest, ExtractDomainName) { ...@@ -84,6 +84,11 @@ TEST(GaiaAuthUtilTest, ExtractDomainName) {
EXPECT_EQ(domain, ExtractDomainName("who@EXAMPLE.cOm")); EXPECT_EQ(domain, ExtractDomainName("who@EXAMPLE.cOm"));
} }
TEST(GaiaAuthUtilTest, IsGoogleInternalAccountEmail) {
EXPECT_TRUE(IsGoogleInternalAccountEmail("hello@google.com"));
EXPECT_FALSE(IsGoogleInternalAccountEmail("internal@gmail.com"));
}
TEST(GaiaAuthUtilTest, SanitizeMissingDomain) { TEST(GaiaAuthUtilTest, SanitizeMissingDomain) {
EXPECT_EQ("nodomain@gmail.com", SanitizeEmail("nodomain")); EXPECT_EQ("nodomain@gmail.com", SanitizeEmail("nodomain"));
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment