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 @@ ...@@ -8,8 +8,8 @@
var FEEDBACK_LANDING_PAGE = var FEEDBACK_LANDING_PAGE =
'https://support.google.com/chrome/go/feedback_confirmation'; 'https://support.google.com/chrome/go/feedback_confirmation';
/** /** @type {string}
* The status of sending the feedback report as defined in feedback_private.idl. * @const
* @enum {string}
*/ */
var ReportStatus = {SUCCESS: 'success', DELAYED: 'delayed'}; var FEEDBACK_LANDING_PAGE_TECHSTOP =
'https://support.google.com/pixelbook/answer/7659411';
...@@ -178,17 +178,23 @@ class FeedbackRequest { ...@@ -178,17 +178,23 @@ class FeedbackRequest {
/** @const */ var ID = this.id_; /** @const */ var ID = this.id_;
/** @const */ var FLOW = this.feedbackInfo_.flow; /** @const */ var FLOW = this.feedbackInfo_.flow;
chrome.feedbackPrivate.sendFeedback(this.feedbackInfo_, function(result) { chrome.feedbackPrivate.sendFeedback(
if (result == ReportStatus.SUCCESS) { this.feedbackInfo_, function(result, landingPageType) {
console.log('Feedback: Report sent for request with ID ' + ID); if (result == chrome.feedbackPrivate.Status.SUCCESS) {
if (FLOW != chrome.feedbackPrivate.FeedbackFlow.LOGIN) console.log('Feedback: Report sent for request with ID ' + ID);
window.open(FEEDBACK_LANDING_PAGE, '_blank'); if (FLOW != chrome.feedbackPrivate.FeedbackFlow.LOGIN) {
} else { var landingPage = landingPageType ==
console.log( chrome.feedbackPrivate.LandingPageType.NORMAL ?
'Feedback: Report for request with ID ' + ID + FEEDBACK_LANDING_PAGE :
' will be sent later.'); 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 @@ ...@@ -19,6 +19,7 @@
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/sys_info.h"
#include "base/values.h" #include "base/values.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "components/feedback/system_logs/system_logs_fetcher.h" #include "components/feedback/system_logs/system_logs_fetcher.h"
...@@ -38,20 +39,6 @@ ...@@ -38,20 +39,6 @@
using extensions::api::feedback_private::SystemInformation; using extensions::api::feedback_private::SystemInformation;
using feedback::FeedbackData; 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 extensions {
namespace feedback_private = api::feedback_private; namespace feedback_private = api::feedback_private;
...@@ -67,6 +54,40 @@ using SystemInformationList = ...@@ -67,6 +54,40 @@ using SystemInformationList =
static base::LazyInstance<BrowserContextKeyedAPIFactory<FeedbackPrivateAPI>>:: static base::LazyInstance<BrowserContextKeyedAPIFactory<FeedbackPrivateAPI>>::
DestructorAtExit g_factory = LAZY_INSTANCE_INITIALIZER; 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 // static
BrowserContextKeyedAPIFactory<FeedbackPrivateAPI>* BrowserContextKeyedAPIFactory<FeedbackPrivateAPI>*
FeedbackPrivateAPI::GetFactoryInstance() { FeedbackPrivateAPI::GetFactoryInstance() {
...@@ -306,15 +327,20 @@ ExtensionFunction::ResponseAction FeedbackPrivateSendFeedbackFunction::Run() { ...@@ -306,15 +327,20 @@ ExtensionFunction::ResponseAction FeedbackPrivateSendFeedbackFunction::Run() {
service->SendFeedback( service->SendFeedback(
feedback_data, feedback_data,
base::Bind(&FeedbackPrivateSendFeedbackFunction::OnCompleted, this)); base::Bind(&FeedbackPrivateSendFeedbackFunction::OnCompleted, this,
GetLandingPageType(feedback_data->user_email())));
return RespondLater(); return RespondLater();
} }
void FeedbackPrivateSendFeedbackFunction::OnCompleted(bool success) { void FeedbackPrivateSendFeedbackFunction::OnCompleted(
Respond(OneArgument(std::make_unique<base::Value>( api::feedback_private::LandingPageType type,
feedback_private::ToString(success ? feedback_private::STATUS_SUCCESS bool success) {
: feedback_private::STATUS_DELAYED)))); 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) { if (!success) {
ExtensionsAPIClient::Get() ExtensionsAPIClient::Get()
->GetFeedbackPrivateDelegate() ->GetFeedbackPrivateDelegate()
......
...@@ -133,7 +133,7 @@ class FeedbackPrivateSendFeedbackFunction : public UIThreadExtensionFunction { ...@@ -133,7 +133,7 @@ class FeedbackPrivateSendFeedbackFunction : public UIThreadExtensionFunction {
ResponseAction Run() override; ResponseAction Run() override;
private: private:
void OnCompleted(bool success); void OnCompleted(api::feedback_private::LandingPageType type, bool success);
}; };
class FeedbackPrivateLogSrtPromptResultFunction class FeedbackPrivateLogSrtPromptResultFunction
......
...@@ -87,6 +87,10 @@ namespace feedbackPrivate { ...@@ -87,6 +87,10 @@ namespace feedbackPrivate {
// Status of the sending of a feedback report. // Status of the sending of a feedback report.
enum Status {success, delayed}; 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. // Result of presenting the user with a prompt to download SRT.
enum SrtPromptResult { enum SrtPromptResult {
// User clicked the "Learn More" button. // User clicked the "Learn More" button.
...@@ -179,7 +183,7 @@ namespace feedbackPrivate { ...@@ -179,7 +183,7 @@ namespace feedbackPrivate {
callback GetUserEmailCallback = void(DOMString email); callback GetUserEmailCallback = void(DOMString email);
callback GetSystemInformationCallback = callback GetSystemInformationCallback =
void(SystemInformation[] systemInformation); void(SystemInformation[] systemInformation);
callback SendFeedbackCallback = void(Status status); callback SendFeedbackCallback = void(Status status, LandingPageType type);
callback GetStringsCallback = void(object result); callback GetStringsCallback = void(object result);
callback ReadLogSourceCallback = void (ReadLogSourceResult 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