| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/extensions/extension_warning_set.h" | 5 #include "chrome/browser/extensions/extension_warning_set.h" |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
| 10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 winning_filename.LossyDisplayName())); | 172 winning_filename.LossyDisplayName())); |
| 173 return ExtensionWarning( | 173 return ExtensionWarning( |
| 174 kDownloadFilenameConflict, | 174 kDownloadFilenameConflict, |
| 175 losing_extension_id, | 175 losing_extension_id, |
| 176 IDS_EXTENSION_WARNINGS_DOWNLOAD_FILENAME_CONFLICT, | 176 IDS_EXTENSION_WARNINGS_DOWNLOAD_FILENAME_CONFLICT, |
| 177 message_parameters); | 177 message_parameters); |
| 178 } | 178 } |
| 179 | 179 |
| 180 std::string ExtensionWarning::GetLocalizedMessage( | 180 std::string ExtensionWarning::GetLocalizedMessage( |
| 181 const ExtensionSet* extensions) const { | 181 const ExtensionSet* extensions) const { |
| 182 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 182 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 183 | 183 |
| 184 // These parameters may be unsafe (URLs and Extension names) and need | 184 // These parameters may be unsafe (URLs and Extension names) and need |
| 185 // to be HTML-escaped before being embedded in the UI. Also extension IDs | 185 // to be HTML-escaped before being embedded in the UI. Also extension IDs |
| 186 // are translated to full extension names. | 186 // are translated to full extension names. |
| 187 std::vector<base::string16> final_parameters; | 187 std::vector<base::string16> final_parameters; |
| 188 for (size_t i = 0; i < message_parameters_.size(); ++i) { | 188 for (size_t i = 0; i < message_parameters_.size(); ++i) { |
| 189 std::string message = message_parameters_[i]; | 189 std::string message = message_parameters_[i]; |
| 190 if (StartsWithASCII(message, kTranslate, true)) { | 190 if (StartsWithASCII(message, kTranslate, true)) { |
| 191 std::string extension_id = message.substr(sizeof(kTranslate) - 1); | 191 std::string extension_id = message.substr(sizeof(kTranslate) - 1); |
| 192 const extensions::Extension* extension = | 192 const extensions::Extension* extension = |
| (...skipping 24 matching lines...) Expand all Loading... |
| 217 } | 217 } |
| 218 } | 218 } |
| 219 | 219 |
| 220 bool operator<(const ExtensionWarning& a, const ExtensionWarning& b) { | 220 bool operator<(const ExtensionWarning& a, const ExtensionWarning& b) { |
| 221 if (a.extension_id() != b.extension_id()) | 221 if (a.extension_id() != b.extension_id()) |
| 222 return a.extension_id() < b.extension_id(); | 222 return a.extension_id() < b.extension_id(); |
| 223 return a.warning_type() < b.warning_type(); | 223 return a.warning_type() < b.warning_type(); |
| 224 } | 224 } |
| 225 | 225 |
| 226 } // namespace extensions | 226 } // namespace extensions |
| OLD | NEW |