Commit ae03e237 authored by Ahmed Fakhry's avatar Ahmed Fakhry Committed by Commit Bot

Feedback: Show a different landing page for Pixelbook googlers

BUG=b/72832726

Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: I727d4b23cfc35fba05d14e380f3807672687c581
Reviewed-on: https://chromium-review.googlesource.com/966973Reviewed-by: default avatarDevlin <rdevlin.cronin@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Ahmed Fakhry <afakhry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#544223}
parent 1c5acb45
......@@ -8,8 +8,8 @@
var FEEDBACK_LANDING_PAGE =
'https://support.google.com/chrome/go/feedback_confirmation';
/**
* The status of sending the feedback report as defined in feedback_private.idl.
* @enum {string}
/** @type {string}
* @const
*/
var ReportStatus = {SUCCESS: 'success', DELAYED: 'delayed'};
var FEEDBACK_LANDING_PAGE_TECHSTOP =
'https://support.google.com/pixelbook/answer/7659411';
......@@ -178,17 +178,23 @@ class FeedbackRequest {
/** @const */ var ID = this.id_;
/** @const */ var FLOW = this.feedbackInfo_.flow;
chrome.feedbackPrivate.sendFeedback(this.feedbackInfo_, function(result) {
if (result == ReportStatus.SUCCESS) {
console.log('Feedback: Report sent for request with ID ' + ID);
if (FLOW != chrome.feedbackPrivate.FeedbackFlow.LOGIN)
window.open(FEEDBACK_LANDING_PAGE, '_blank');
} else {
console.log(
'Feedback: Report for request with ID ' + ID +
' will be sent later.');
}
});
chrome.feedbackPrivate.sendFeedback(
this.feedbackInfo_, function(result, landingPageType) {
if (result == chrome.feedbackPrivate.Status.SUCCESS) {
console.log('Feedback: Report sent for request with ID ' + ID);
if (FLOW != chrome.feedbackPrivate.FeedbackFlow.LOGIN) {
var landingPage = landingPageType ==
chrome.feedbackPrivate.LandingPageType.NORMAL ?
FEEDBACK_LANDING_PAGE :
FEEDBACK_LANDING_PAGE_TECHSTOP;
window.open(landingPage, '_blank');
}
} else {
console.log(
'Feedback: Report for request with ID ' + ID +
' will be sent later.');
}
});
}
/**
......
......@@ -19,6 +19,7 @@
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/sys_info.h"
#include "base/values.h"
#include "build/build_config.h"
#include "components/feedback/system_logs/system_logs_fetcher.h"
......@@ -38,20 +39,6 @@
using extensions::api::feedback_private::SystemInformation;
using feedback::FeedbackData;
namespace {
// Getting the filename of a blob prepends a "C:\fakepath" to the filename.
// This is undesirable, strip it if it exists.
std::string StripFakepath(const std::string& path) {
const char kFakePathStr[] = "C:\\fakepath\\";
if (base::StartsWith(path, kFakePathStr,
base::CompareCase::INSENSITIVE_ASCII))
return path.substr(arraysize(kFakePathStr) - 1);
return path;
}
} // namespace
namespace extensions {
namespace feedback_private = api::feedback_private;
......@@ -67,6 +54,40 @@ using SystemInformationList =
static base::LazyInstance<BrowserContextKeyedAPIFactory<FeedbackPrivateAPI>>::
DestructorAtExit g_factory = LAZY_INSTANCE_INITIALIZER;
namespace {
// Getting the filename of a blob prepends a "C:\fakepath" to the filename.
// This is undesirable, strip it if it exists.
std::string StripFakepath(const std::string& path) {
constexpr char kFakePathStr[] = "C:\\fakepath\\";
if (base::StartsWith(path, kFakePathStr,
base::CompareCase::INSENSITIVE_ASCII))
return path.substr(arraysize(kFakePathStr) - 1);
return path;
}
// Returns the type of the landing page which is shown to the user when the
// report is successfully sent.
feedback_private::LandingPageType GetLandingPageType(const std::string& email) {
#if defined(OS_CHROMEOS)
const std::string board =
base::ToLowerASCII(base::SysInfo::GetLsbReleaseBoard());
if (board.find("eve") == std::string::npos)
return feedback_private::LANDING_PAGE_TYPE_NORMAL;
if (!base::EndsWith(email, "@google.com",
base::CompareCase::INSENSITIVE_ASCII)) {
return feedback_private::LANDING_PAGE_TYPE_NORMAL;
}
return feedback_private::LANDING_PAGE_TYPE_TECHSTOP;
#else
return feedback_private::LANDING_PAGE_TYPE_NORMAL;
#endif // defined(OS_CHROMEOS)
}
} // namespace
// static
BrowserContextKeyedAPIFactory<FeedbackPrivateAPI>*
FeedbackPrivateAPI::GetFactoryInstance() {
......@@ -306,15 +327,20 @@ ExtensionFunction::ResponseAction FeedbackPrivateSendFeedbackFunction::Run() {
service->SendFeedback(
feedback_data,
base::Bind(&FeedbackPrivateSendFeedbackFunction::OnCompleted, this));
base::Bind(&FeedbackPrivateSendFeedbackFunction::OnCompleted, this,
GetLandingPageType(feedback_data->user_email())));
return RespondLater();
}
void FeedbackPrivateSendFeedbackFunction::OnCompleted(bool success) {
Respond(OneArgument(std::make_unique<base::Value>(
feedback_private::ToString(success ? feedback_private::STATUS_SUCCESS
: feedback_private::STATUS_DELAYED))));
void FeedbackPrivateSendFeedbackFunction::OnCompleted(
api::feedback_private::LandingPageType type,
bool success) {
Respond(TwoArguments(
std::make_unique<base::Value>(feedback_private::ToString(
success ? feedback_private::STATUS_SUCCESS
: feedback_private::STATUS_DELAYED)),
std::make_unique<base::Value>(feedback_private::ToString(type))));
if (!success) {
ExtensionsAPIClient::Get()
->GetFeedbackPrivateDelegate()
......
......@@ -133,7 +133,7 @@ class FeedbackPrivateSendFeedbackFunction : public UIThreadExtensionFunction {
ResponseAction Run() override;
private:
void OnCompleted(bool success);
void OnCompleted(api::feedback_private::LandingPageType type, bool success);
};
class FeedbackPrivateLogSrtPromptResultFunction
......
......@@ -87,6 +87,10 @@ namespace feedbackPrivate {
// Status of the sending of a feedback report.
enum Status {success, delayed};
// The type of the landing page shown to the user when the feedback report is
// successfully sent.
enum LandingPageType {normal, techstop};
// Result of presenting the user with a prompt to download SRT.
enum SrtPromptResult {
// User clicked the "Learn More" button.
......@@ -179,7 +183,7 @@ namespace feedbackPrivate {
callback GetUserEmailCallback = void(DOMString email);
callback GetSystemInformationCallback =
void(SystemInformation[] systemInformation);
callback SendFeedbackCallback = void(Status status);
callback SendFeedbackCallback = void(Status status, LandingPageType type);
callback GetStringsCallback = void(object result);
callback ReadLogSourceCallback = void (ReadLogSourceResult result);
......
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