OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/installable/installable_logging.h" | 5 #include "chrome/browser/installable/installable_logging.h" |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "content/public/browser/render_frame_host.h" | 9 #include "content/public/browser/render_frame_host.h" |
10 #include "content/public/browser/web_contents.h" | 10 #include "content/public/browser/web_contents.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 "the specified application platform is not supported on Android"; | 57 "the specified application platform is not supported on Android"; |
58 static const char kNoIdSpecifiedMessage[] = | 58 static const char kNoIdSpecifiedMessage[] = |
59 "no Play store ID provided"; | 59 "no Play store ID provided"; |
60 static const char kIdsDoNotMatchMessage[] = | 60 static const char kIdsDoNotMatchMessage[] = |
61 "a Play Store app URL and Play Store ID were specified in the manifest, " | 61 "a Play Store app URL and Play Store ID were specified in the manifest, " |
62 "but they do not match"; | 62 "but they do not match"; |
63 static const char kUrlNotSupportedForWebApkMessage[] = | 63 static const char kUrlNotSupportedForWebApkMessage[] = |
64 "a URL in the web manifest contains a username, password, or port"; | 64 "a URL in the web manifest contains a username, password, or port"; |
65 static const char kInIncognitoMessage[] = | 65 static const char kInIncognitoMessage[] = |
66 "the page is loaded in an incognito window"; | 66 "the page is loaded in an incognito window"; |
67 | 67 static const char kNotOfflineCapable[] = "the page does not work offline"; |
68 } // namespace | 68 } // namespace |
69 | 69 |
70 void LogErrorToConsole(content::WebContents* web_contents, | 70 void LogErrorToConsole(content::WebContents* web_contents, |
71 InstallableStatusCode code, | 71 InstallableStatusCode code, |
72 const std::string& param) { | 72 const std::string& param) { |
73 if (!web_contents) | 73 if (!web_contents) |
74 return; | 74 return; |
75 | 75 |
76 content::ConsoleMessageLevel severity = content::CONSOLE_MESSAGE_LEVEL_ERROR; | 76 content::ConsoleMessageLevel severity = content::CONSOLE_MESSAGE_LEVEL_ERROR; |
77 const char* pattern = nullptr; | 77 const char* pattern = nullptr; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 break; | 144 break; |
145 case IDS_DO_NOT_MATCH: | 145 case IDS_DO_NOT_MATCH: |
146 pattern = kIdsDoNotMatchMessage; | 146 pattern = kIdsDoNotMatchMessage; |
147 break; | 147 break; |
148 case URL_NOT_SUPPORTED_FOR_WEBAPK: | 148 case URL_NOT_SUPPORTED_FOR_WEBAPK: |
149 pattern = kUrlNotSupportedForWebApkMessage; | 149 pattern = kUrlNotSupportedForWebApkMessage; |
150 break; | 150 break; |
151 case IN_INCOGNITO: | 151 case IN_INCOGNITO: |
152 pattern = kInIncognitoMessage; | 152 pattern = kInIncognitoMessage; |
153 break; | 153 break; |
| 154 case NOT_OFFLINE_CAPABLE: |
| 155 pattern = kNotOfflineCapable; |
| 156 break; |
154 } | 157 } |
155 | 158 |
156 if (!pattern) | 159 if (!pattern) |
157 return; | 160 return; |
158 std::string message = param.empty() ? | 161 std::string message = param.empty() ? |
159 pattern : base::StringPrintf(pattern, param.c_str()); | 162 pattern : base::StringPrintf(pattern, param.c_str()); |
160 web_contents->GetMainFrame()->AddMessageToConsole( | 163 web_contents->GetMainFrame()->AddMessageToConsole( |
161 severity, GetMessagePrefix() + message); | 164 severity, GetMessagePrefix() + message); |
162 } | 165 } |
OLD | NEW |