Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4335)

Unified Diff: chrome/browser/banners/app_banner_debug_log.cc

Issue 1835063002: DevTools: make app banner debug messages report with different severity (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: win fixed Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/banners/app_banner_debug_log.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/banners/app_banner_debug_log.cc
diff --git a/chrome/browser/banners/app_banner_debug_log.cc b/chrome/browser/banners/app_banner_debug_log.cc
index d58a2172479bcedce718009584502cabc20714dd..bff2cdf87d53a0f936ccfd553030077557456dca 100644
--- a/chrome/browser/banners/app_banner_debug_log.cc
+++ b/chrome/browser/banners/app_banner_debug_log.cc
@@ -4,58 +4,127 @@
#include "chrome/browser/banners/app_banner_debug_log.h"
+#include "base/strings/stringprintf.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
namespace banners {
-const char kRendererRequestCancel[] =
- "renderer has requested the banner prompt be cancelled";
-const char kManifestEmpty[] =
+static const char kRendererRequestCancelMessage[] =
+ "page has requested the banner prompt be cancelled";
+static const char kManifestEmptyMessage[] =
"manifest could not be fetched, is empty, or could not be parsed";
-const char kNoManifest[] = "site has no manifest <link> URL";
-// The required size is prepended.
-const char kNoIconMatchingRequirements[] =
- "px square icon is required, but no supplied icon is at least this size";
-const char kCannotDownloadIcon[] = "could not download the specified icon";
-const char kNoMatchingServiceWorker[] =
+static const char kNoManifestMessage[] =
+ "site has no manifest <link> URL";
+static const char kNoIconMatchingRequirementsMessage[] =
+ "%spx square icon is required, but no supplied icon is at least this size";
+static const char kCannotDownloadIconMessage[] =
+ "could not download the specified icon";
+static const char kNoMatchingServiceWorkerMessage[] =
"no matching service worker detected. You may need to reload the page, or "
"check that the service worker for the current page also controls the "
"start URL from the manifest";
-const char kNoIconAvailable[] = "no icon available to display";
-const char kUserNavigatedBeforeBannerShown[] =
+static const char kNoIconAvailableMessage[] =
+ "no icon available to display";
+static const char kUserNavigatedBeforeBannerShownMessage[] =
"the user navigated before the banner could be shown";
-const char kStartURLNotValid[] = "start URL in manifest is not valid";
-const char kManifestMissingNameOrShortName[] =
+static const char kStartURLNotValidMessage[] =
+ "start URL in manifest is not valid";
+static const char kManifestMissingNameOrShortNameMessage[] =
"one of manifest name or short name must be specified";
-const char kManifestMissingSuitableIcon[] =
+static const char kManifestMissingSuitableIconMessage[] =
"manifest does not contain a suitable icon - PNG format of at least "
"144x144px is required, and the sizes attribute must be set";
-const char kNotLoadedInMainFrame[] = "page not loaded in the main frame";
-const char kNotServedFromSecureOrigin[] =
+static const char kNotLoadedInMainFrameMessage[] =
+ "page not loaded in the main frame";
+static const char kNotServedFromSecureOriginMessage[] =
"page not served from a secure origin";
// The leading space is intentional as another string is prepended.
-const char kIgnoredNotSupportedOnAndroid[] =
- " application ignored: not supported on Android";
-const char kIgnoredNoId[] = "play application ignored: no id provided";
-const char kIgnoredIdsDoNotMatch[] =
- "play application ignored: app URL and id fields were specified in the "
- "manifest, but they do not match";
+static const char kIgnoredNotSupportedOnAndroidMessage[] =
+ "%s application is not supported on Android";
+static const char kIgnoredNoIdMessage[] =
+ "no Play store ID provided";
+static const char kIgnoredIdsDoNotMatchMessage[] =
+ "a Play app URL and Play store ID were specified in the manifest, but they"
+ " do not match";
void OutputDeveloperNotShownMessage(content::WebContents* web_contents,
- const std::string& message,
+ OutputDeveloperMessageCode code,
bool is_debug_mode) {
- OutputDeveloperDebugMessage(web_contents, "not shown: " + message,
- is_debug_mode);
+ OutputDeveloperNotShownMessage(web_contents, code, std::string(),
+ is_debug_mode);
}
-void OutputDeveloperDebugMessage(content::WebContents* web_contents,
- const std::string& message,
- bool is_debug_mode) {
+void OutputDeveloperNotShownMessage(content::WebContents* web_contents,
+ OutputDeveloperMessageCode code,
+ const std::string& param,
+ bool is_debug_mode) {
if (!is_debug_mode || !web_contents)
return;
+
+ const char* pattern;
+ content::ConsoleMessageLevel severity = content::CONSOLE_MESSAGE_LEVEL_ERROR;
+ switch (code) {
+ case kRendererRequestCancel:
+ pattern = kRendererRequestCancelMessage;
+ severity = content::CONSOLE_MESSAGE_LEVEL_LOG;
+ break;
+ case kManifestEmpty:
+ pattern = kManifestEmptyMessage;
+ break;
+ case kNoManifest:
+ pattern = kNoManifestMessage;
+ break;
+ case kNoIconMatchingRequirements:
+ pattern = kNoIconMatchingRequirementsMessage;
+ break;
+ case kCannotDownloadIcon:
+ pattern = kCannotDownloadIconMessage;
+ break;
+ case kNoMatchingServiceWorker:
+ pattern = kNoMatchingServiceWorkerMessage;
+ break;
+ case kNoIconAvailable:
+ pattern = kNoIconAvailableMessage;
+ break;
+ case kUserNavigatedBeforeBannerShown:
+ pattern = kUserNavigatedBeforeBannerShownMessage;
+ severity = content::CONSOLE_MESSAGE_LEVEL_WARNING;
+ break;
+ case kStartURLNotValid:
+ pattern = kStartURLNotValidMessage;
+ break;
+ case kManifestMissingNameOrShortName:
+ pattern = kManifestMissingNameOrShortNameMessage;
+ break;
+ case kManifestMissingSuitableIcon:
+ pattern = kManifestMissingSuitableIconMessage;
+ break;
+ case kNotLoadedInMainFrame:
+ pattern = kNotLoadedInMainFrameMessage;
+ break;
+ case kNotServedFromSecureOrigin:
+ pattern = kNotServedFromSecureOriginMessage;
+ break;
+ case kIgnoredNotSupportedOnAndroid:
+ pattern = kIgnoredNotSupportedOnAndroidMessage;
+ severity = content::CONSOLE_MESSAGE_LEVEL_WARNING;
+ break;
+ case kIgnoredNoId:
+ pattern = kIgnoredNoIdMessage;
+ break;
+ case kIgnoredIdsDoNotMatch:
+ pattern = kIgnoredIdsDoNotMatchMessage;
+ break;
+ default:
+ NOTREACHED();
+ return;
+ }
+ std::string message = param.empty() ?
+ pattern : base::StringPrintf(pattern, param.c_str());
web_contents->GetMainFrame()->AddMessageToConsole(
- content::CONSOLE_MESSAGE_LEVEL_DEBUG, "App banner " + message);
+ severity, "App banner not shown: " + message);
+
}
} // namespace banners
« no previous file with comments | « chrome/browser/banners/app_banner_debug_log.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698