chromium/components/webapps/browser/installable/installable_logging.h

// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_WEBAPPS_BROWSER_INSTALLABLE_INSTALLABLE_LOGGING_H_
#define COMPONENTS_WEBAPPS_BROWSER_INSTALLABLE_INSTALLABLE_LOGGING_H_

#include <string>

#include "third_party/blink/public/mojom/devtools/console_message.mojom-forward.h"

namespace content {
struct InstallabilityError;
class WebContents;
}  // namespace content

namespace webapps {

// These values are a central reference for installability errors. The
// InstallableManager will specify an InstallableStatusCode (or
// NO_ERROR_DETECTED) in its result. Clients may also add their own error codes,
// and utilise LogToConsole to write a message to the devtools console. This
// enum backs an UMA histogram, so it must be treated as append-only.
enum class InstallableStatusCode {};

// Returns a user-readable description for |code|, or an empty string if |code|
// should not be exposed.
std::string GetErrorMessage(InstallableStatusCode code);
content::InstallabilityError GetInstallabilityError(InstallableStatusCode code);

// Logs a message associated with |code| to the devtools console attached to
// |web_contents|. Does nothing if |web_contents| is nullptr.
void LogToConsole(content::WebContents* web_contents,
                  InstallableStatusCode code,
                  blink::mojom::ConsoleMessageLevel level);

}  // namespace webapps

#endif  // COMPONENTS_WEBAPPS_BROWSER_INSTALLABLE_INSTALLABLE_LOGGING_H_