OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/banners/app_banner_debug_log.h" | 5 #include "chrome/browser/banners/app_banner_debug_log.h" |
6 | 6 |
7 #include "base/command_line.h" | |
8 #include "chrome/common/chrome_switches.h" | |
9 #include "content/public/browser/render_frame_host.h" | 7 #include "content/public/browser/render_frame_host.h" |
10 #include "content/public/browser/web_contents.h" | 8 #include "content/public/browser/web_contents.h" |
11 | 9 |
12 namespace banners { | 10 namespace banners { |
13 | 11 |
14 const char kRendererRequestCancel[] = | 12 const char kRendererRequestCancel[] = |
15 "renderer has requested the banner prompt be cancelled"; | 13 "renderer has requested the banner prompt be cancelled"; |
16 const char kManifestEmpty[] = | 14 const char kManifestEmpty[] = |
17 "manifest could not be fetched, is empty, or could not be parsed"; | 15 "manifest could not be fetched, is empty, or could not be parsed"; |
18 const char kNoManifest[] = "site has no manifest <link> URL"; | 16 const char kNoManifest[] = "site has no manifest <link> URL"; |
19 const char kCannotDetermineBestIcon[] = | 17 const char kCannotDetermineBestIcon[] = |
20 "could not determine the best icon to use"; | 18 "could not determine the best icon to use"; |
21 const char kNoMatchingServiceWorker[] = | 19 const char kNoMatchingServiceWorker[] = |
22 "no matching service worker detected. You may need to reload the page, or " | 20 "no matching service worker detected. You may need to reload the page, or " |
23 "check that the service worker for the current page also controls the " | 21 "check that the service worker for the current page also controls the " |
24 "start URL from the manifest"; | 22 "start URL from the manifest"; |
25 const char kNoIconAvailable[] = "no icon available to display"; | 23 const char kNoIconAvailable[] = "no icon available to display"; |
26 const char kBannerAlreadyAdded[] = | 24 const char kBannerAlreadyAdded[] = |
27 "site requesting the banner has already been added"; | 25 "site requesting the banner has already been added"; |
28 const char kUserNavigatedBeforeBannerShown[] = | 26 const char kUserNavigatedBeforeBannerShown[] = |
29 "the user navigated before the banner could be shown"; | 27 "the user navigated before the banner could be shown"; |
30 const char kStartURLNotValid[] = "start URL in manifest is not valid"; | 28 const char kStartURLNotValid[] = "start URL in manifest is not valid"; |
31 const char kManifestMissingNameOrShortName[] = | 29 const char kManifestMissingNameOrShortName[] = |
32 "one of manifest name or short name must be specified"; | 30 "one of manifest name or short name must be specified"; |
33 const char kManifestMissingSuitableIcon[] = | 31 const char kManifestMissingSuitableIcon[] = |
34 "manifest does not contain a suitable icon - PNG format of at least " | 32 "manifest does not contain a suitable icon - PNG format of at least " |
35 "144x144px is required, and the sizes attribute must be set"; | 33 "144x144px is required, and the sizes attribute must be set"; |
34 const char kNotLoadedInMainFrame[] = "page not loaded in the main frame"; | |
36 const char kNotServedFromSecureOrigin[] = | 35 const char kNotServedFromSecureOrigin[] = |
37 "page not served from a secure origin"; | 36 "page not served from a secure origin"; |
38 // The leading space is intentional as another string is prepended. | 37 // The leading space is intentional as another string is prepended. |
39 const char kIgnoredNotSupportedOnAndroid[] = | 38 const char kIgnoredNotSupportedOnAndroid[] = |
40 " application ignored: not supported on Android"; | 39 " application ignored: not supported on Android"; |
41 const char kIgnoredNoId[] = "play application ignored: no id provided"; | 40 const char kIgnoredNoId[] = "play application ignored: no id provided"; |
42 const char kIgnoredIdsDoNotMatch[] = | 41 const char kIgnoredIdsDoNotMatch[] = |
43 "play application ignored: app URL and id fields were specified in the " | 42 "play application ignored: app URL and id fields were specified in the " |
44 "manifest, but they do not match"; | 43 "manifest, but they do not match"; |
45 | 44 |
46 void OutputDeveloperNotShownMessage(content::WebContents* web_contents, | 45 void OutputDeveloperNotShownMessage(content::WebContents* web_contents, |
47 const std::string& message) { | 46 const std::string& message, |
48 OutputDeveloperDebugMessage(web_contents, "not shown: " + message); | 47 bool is_debug_mode) { |
48 OutputDeveloperDebugMessage(web_contents, "not shown: " + message, | |
49 is_debug_mode); | |
49 } | 50 } |
50 | 51 |
51 void OutputDeveloperDebugMessage(content::WebContents* web_contents, | 52 void OutputDeveloperDebugMessage(content::WebContents* web_contents, |
52 const std::string& message) { | 53 const std::string& message, |
53 std::string log_message = "App banner " + message; | 54 bool is_debug_mode) { |
54 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 55 if (!is_debug_mode || !web_contents) |
pfeldman
2016/01/20 04:30:17
Why do we need to plumb is_debug_mode all the way
dominickn
2016/01/20 05:37:25
Currently, the logging functions are *always* call
| |
55 switches::kBypassAppBannerEngagementChecks) && | 56 return; |
56 web_contents) { | 57 web_contents->GetMainFrame()->AddMessageToConsole( |
57 web_contents->GetMainFrame()->AddMessageToConsole( | 58 content::CONSOLE_MESSAGE_LEVEL_DEBUG, "App banner " + message); |
58 content::CONSOLE_MESSAGE_LEVEL_DEBUG, log_message); | |
59 } | |
60 } | 59 } |
61 | 60 |
62 } // namespace banners | 61 } // namespace banners |
OLD | NEW |