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 kNoServiceWorkerFetchHandlerMessage[] = |
68 "a fetch handler is not present in the service worker"; | |
dominickn
2017/03/16 06:21:56
Nit: let's just make this "the page does not work
piotrs
2017/03/17 02:21:37
Like it, thanks. Also it doesn't expose our intern
| |
68 } // namespace | 69 } // namespace |
69 | 70 |
70 void LogErrorToConsole(content::WebContents* web_contents, | 71 void LogErrorToConsole(content::WebContents* web_contents, |
71 InstallableStatusCode code, | 72 InstallableStatusCode code, |
72 const std::string& param) { | 73 const std::string& param) { |
73 if (!web_contents) | 74 if (!web_contents) |
74 return; | 75 return; |
75 | 76 |
76 content::ConsoleMessageLevel severity = content::CONSOLE_MESSAGE_LEVEL_ERROR; | 77 content::ConsoleMessageLevel severity = content::CONSOLE_MESSAGE_LEVEL_ERROR; |
77 const char* pattern = nullptr; | 78 const char* pattern = nullptr; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
144 break; | 145 break; |
145 case IDS_DO_NOT_MATCH: | 146 case IDS_DO_NOT_MATCH: |
146 pattern = kIdsDoNotMatchMessage; | 147 pattern = kIdsDoNotMatchMessage; |
147 break; | 148 break; |
148 case URL_NOT_SUPPORTED_FOR_WEBAPK: | 149 case URL_NOT_SUPPORTED_FOR_WEBAPK: |
149 pattern = kUrlNotSupportedForWebApkMessage; | 150 pattern = kUrlNotSupportedForWebApkMessage; |
150 break; | 151 break; |
151 case IN_INCOGNITO: | 152 case IN_INCOGNITO: |
152 pattern = kInIncognitoMessage; | 153 pattern = kInIncognitoMessage; |
153 break; | 154 break; |
155 case NO_SERVICE_WORKER_FETCH_HANDLER: | |
156 pattern = kNoServiceWorkerFetchHandlerMessage; | |
157 break; | |
154 } | 158 } |
155 | 159 |
156 if (!pattern) | 160 if (!pattern) |
157 return; | 161 return; |
158 std::string message = param.empty() ? | 162 std::string message = param.empty() ? |
159 pattern : base::StringPrintf(pattern, param.c_str()); | 163 pattern : base::StringPrintf(pattern, param.c_str()); |
160 web_contents->GetMainFrame()->AddMessageToConsole( | 164 web_contents->GetMainFrame()->AddMessageToConsole( |
161 severity, GetMessagePrefix() + message); | 165 severity, GetMessagePrefix() + message); |
162 } | 166 } |
OLD | NEW |