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

Side by Side Diff: chrome/browser/banners/app_banner_debug_log.cc

Issue 2156113002: Replace AppBannerDataFetcher with InstallableManager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@banner-refactor
Patch Set: Naming, includes Created 4 years, 4 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/banners/app_banner_debug_log.h"
6
7 #include "base/strings/stringprintf.h"
8 #include "content/public/browser/render_frame_host.h"
9 #include "content/public/browser/web_contents.h"
10
11 namespace banners {
12
13 static const char kRendererRequestCancelMessage[] =
14 "page has requested the banner prompt be cancelled";
15 static const char kManifestEmptyMessage[] =
16 "manifest could not be fetched, is empty, or could not be parsed";
17 static const char kNoManifestMessage[] =
18 "site has no manifest <link> URL";
19 static const char kNoIconMatchingRequirementsMessage[] =
20 "%spx square icon is required, but no supplied icon is at least this size";
21 static const char kCannotDownloadIconMessage[] =
22 "could not download the specified icon";
23 static const char kNoMatchingServiceWorkerMessage[] =
24 "no matching service worker detected. You may need to reload the page, or "
25 "check that the service worker for the current page also controls the "
26 "start URL from the manifest";
27 static const char kNoIconAvailableMessage[] =
28 "no icon available to display";
29 static const char kUserNavigatedBeforeBannerShownMessage[] =
30 "the user navigated before the banner could be shown";
31 static const char kStartURLNotValidMessage[] =
32 "start URL in manifest is not valid";
33 static const char kManifestDisplayStandaloneFullscreenMessage[] =
34 "manifest display property must be set to 'standalone' or 'fullscreen'";
35 static const char kManifestMissingNameOrShortNameMessage[] =
36 "one of manifest name or short name must be specified";
37 static const char kManifestMissingSuitableIconMessage[] =
38 "manifest does not contain a suitable icon - PNG format of at least "
39 "144x144px is required, and the sizes attribute must be set";
40 static const char kNotLoadedInMainFrameMessage[] =
41 "page not loaded in the main frame";
42 static const char kNotServedFromSecureOriginMessage[] =
43 "page not served from a secure origin";
44 // The leading space is intentional as another string is prepended.
45 static const char kIgnoredNotSupportedOnAndroidMessage[] =
46 "%s application is not supported on Android";
47 static const char kIgnoredNoIdMessage[] =
48 "no Play store ID provided";
49 static const char kIgnoredIdsDoNotMatchMessage[] =
50 "a Play app URL and Play store ID were specified in the manifest, but they"
51 " do not match";
52
53 void OutputDeveloperNotShownMessage(content::WebContents* web_contents,
54 OutputDeveloperMessageCode code,
55 bool is_debug_mode) {
56 OutputDeveloperNotShownMessage(web_contents, code, std::string(),
57 is_debug_mode);
58 }
59
60 void OutputDeveloperNotShownMessage(content::WebContents* web_contents,
61 OutputDeveloperMessageCode code,
62 const std::string& param,
63 bool is_debug_mode) {
64 if (!is_debug_mode || !web_contents)
65 return;
66
67 const char* pattern;
68 content::ConsoleMessageLevel severity = content::CONSOLE_MESSAGE_LEVEL_ERROR;
69 switch (code) {
70 case kRendererRequestCancel:
71 pattern = kRendererRequestCancelMessage;
72 severity = content::CONSOLE_MESSAGE_LEVEL_LOG;
73 break;
74 case kManifestEmpty:
75 pattern = kManifestEmptyMessage;
76 break;
77 case kNoManifest:
78 pattern = kNoManifestMessage;
79 break;
80 case kNoIconMatchingRequirements:
81 pattern = kNoIconMatchingRequirementsMessage;
82 break;
83 case kCannotDownloadIcon:
84 pattern = kCannotDownloadIconMessage;
85 break;
86 case kNoMatchingServiceWorker:
87 pattern = kNoMatchingServiceWorkerMessage;
88 break;
89 case kNoIconAvailable:
90 pattern = kNoIconAvailableMessage;
91 break;
92 case kUserNavigatedBeforeBannerShown:
93 pattern = kUserNavigatedBeforeBannerShownMessage;
94 severity = content::CONSOLE_MESSAGE_LEVEL_WARNING;
95 break;
96 case kStartURLNotValid:
97 pattern = kStartURLNotValidMessage;
98 break;
99 case kManifestDisplayStandaloneFullscreen:
100 pattern = kManifestDisplayStandaloneFullscreenMessage;
101 break;
102 case kManifestMissingNameOrShortName:
103 pattern = kManifestMissingNameOrShortNameMessage;
104 break;
105 case kManifestMissingSuitableIcon:
106 pattern = kManifestMissingSuitableIconMessage;
107 break;
108 case kNotLoadedInMainFrame:
109 pattern = kNotLoadedInMainFrameMessage;
110 break;
111 case kNotServedFromSecureOrigin:
112 pattern = kNotServedFromSecureOriginMessage;
113 break;
114 case kIgnoredNotSupportedOnAndroid:
115 pattern = kIgnoredNotSupportedOnAndroidMessage;
116 severity = content::CONSOLE_MESSAGE_LEVEL_WARNING;
117 break;
118 case kIgnoredNoId:
119 pattern = kIgnoredNoIdMessage;
120 break;
121 case kIgnoredIdsDoNotMatch:
122 pattern = kIgnoredIdsDoNotMatchMessage;
123 break;
124 default:
125 NOTREACHED();
126 return;
127 }
128 std::string message = param.empty() ?
129 pattern : base::StringPrintf(pattern, param.c_str());
130 web_contents->GetMainFrame()->AddMessageToConsole(
131 severity, "App banner not shown: " + message);
132
133 }
134
135 } // namespace banners
OLDNEW
« no previous file with comments | « chrome/browser/banners/app_banner_debug_log.h ('k') | chrome/browser/banners/app_banner_infobar_delegate_desktop.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698