| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 "no icon available to display"; | 54 "no icon available to display"; |
| 55 static const char kPlatformNotSupportedOnAndroidMessage[] = | 55 static const char kPlatformNotSupportedOnAndroidMessage[] = |
| 56 "the specified application platform is not supported on Android"; | 56 "the specified application platform is not supported on Android"; |
| 57 static const char kNoIdSpecifiedMessage[] = | 57 static const char kNoIdSpecifiedMessage[] = |
| 58 "no Play store ID provided"; | 58 "no Play store ID provided"; |
| 59 static const char kIdsDoNotMatchMessage[] = | 59 static const char kIdsDoNotMatchMessage[] = |
| 60 "a Play Store app URL and Play Store ID were specified in the manifest, " | 60 "a Play Store app URL and Play Store ID were specified in the manifest, " |
| 61 "but they do not match"; | 61 "but they do not match"; |
| 62 static const char kUrlNotSupportedForWebApkMessage[] = | 62 static const char kUrlNotSupportedForWebApkMessage[] = |
| 63 "a URL in the web manifest contains a username, password, or port"; | 63 "a URL in the web manifest contains a username, password, or port"; |
| 64 static const char kInIncognitoMessage[] = |
| 65 "the page is loaded in an incognito window"; |
| 64 | 66 |
| 65 } // namespace | 67 } // namespace |
| 66 | 68 |
| 67 void LogErrorToConsole(content::WebContents* web_contents, | 69 void LogErrorToConsole(content::WebContents* web_contents, |
| 68 InstallableStatusCode code, | 70 InstallableStatusCode code, |
| 69 const std::string& param) { | 71 const std::string& param) { |
| 70 if (!web_contents) | 72 if (!web_contents) |
| 71 return; | 73 return; |
| 72 | 74 |
| 73 content::ConsoleMessageLevel severity = content::CONSOLE_MESSAGE_LEVEL_ERROR; | 75 content::ConsoleMessageLevel severity = content::CONSOLE_MESSAGE_LEVEL_ERROR; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 break; | 140 break; |
| 139 case NO_ID_SPECIFIED: | 141 case NO_ID_SPECIFIED: |
| 140 pattern = kNoIdSpecifiedMessage; | 142 pattern = kNoIdSpecifiedMessage; |
| 141 break; | 143 break; |
| 142 case IDS_DO_NOT_MATCH: | 144 case IDS_DO_NOT_MATCH: |
| 143 pattern = kIdsDoNotMatchMessage; | 145 pattern = kIdsDoNotMatchMessage; |
| 144 break; | 146 break; |
| 145 case URL_NOT_SUPPORTED_FOR_WEBAPK: | 147 case URL_NOT_SUPPORTED_FOR_WEBAPK: |
| 146 pattern = kUrlNotSupportedForWebApkMessage; | 148 pattern = kUrlNotSupportedForWebApkMessage; |
| 147 break; | 149 break; |
| 150 case IN_INCOGNITO: |
| 151 pattern = kInIncognitoMessage; |
| 152 break; |
| 148 } | 153 } |
| 149 | 154 |
| 150 if (!pattern) | 155 if (!pattern) |
| 151 return; | 156 return; |
| 152 std::string message = param.empty() ? | 157 std::string message = param.empty() ? |
| 153 pattern : base::StringPrintf(pattern, param.c_str()); | 158 pattern : base::StringPrintf(pattern, param.c_str()); |
| 154 web_contents->GetMainFrame()->AddMessageToConsole( | 159 web_contents->GetMainFrame()->AddMessageToConsole( |
| 155 severity, GetMessagePrefix() + message); | 160 severity, GetMessagePrefix() + message); |
| 156 } | 161 } |
| OLD | NEW |