| 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/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
| 9 #include "chrome/common/extensions/extension.h" | 10 #include "chrome/common/extensions/extension.h" |
| 10 #include "chrome/common/extensions/extension_set.h" | 11 #include "chrome/common/extensions/extension_set.h" |
| 11 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
| 12 #include "grit/chromium_strings.h" | 13 #include "grit/chromium_strings.h" |
| 13 #include "grit/generated_resources.h" | 14 #include "grit/generated_resources.h" |
| 14 #include "net/base/escape.h" | 15 #include "net/base/escape.h" |
| 15 #include "ui/base/l10n/l10n_util.h" | 16 #include "ui/base/l10n/l10n_util.h" |
| 16 | 17 |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 const std::string& extension_id) { | 151 const std::string& extension_id) { |
| 151 std::vector<std::string> message_parameters; | 152 std::vector<std::string> message_parameters; |
| 152 message_parameters.push_back(l10n_util::GetStringUTF8(IDS_PRODUCT_NAME)); | 153 message_parameters.push_back(l10n_util::GetStringUTF8(IDS_PRODUCT_NAME)); |
| 153 return ExtensionWarning( | 154 return ExtensionWarning( |
| 154 kRepeatedCacheFlushes, | 155 kRepeatedCacheFlushes, |
| 155 extension_id, | 156 extension_id, |
| 156 IDS_EXTENSION_WARNINGS_NETWORK_DELAY, | 157 IDS_EXTENSION_WARNINGS_NETWORK_DELAY, |
| 157 message_parameters); | 158 message_parameters); |
| 158 } | 159 } |
| 159 | 160 |
| 161 // static |
| 162 ExtensionWarning ExtensionWarning::CreateDownloadFilenameConflictWarning( |
| 163 const std::string& losing_extension_id, |
| 164 const std::string& winning_extension_id, |
| 165 const base::FilePath& losing_filename, |
| 166 const base::FilePath& winning_filename) { |
| 167 std::vector<std::string> message_parameters; |
| 168 message_parameters.push_back(UTF16ToUTF8(losing_filename.LossyDisplayName())); |
| 169 message_parameters.push_back(kTranslate + winning_extension_id); |
| 170 message_parameters.push_back(UTF16ToUTF8( |
| 171 winning_filename.LossyDisplayName())); |
| 172 return ExtensionWarning( |
| 173 kDownloadFilenameConflict, |
| 174 losing_extension_id, |
| 175 IDS_EXTENSION_WARNINGS_DOWNLOAD_FILENAME_CONFLICT, |
| 176 message_parameters); |
| 177 } |
| 178 |
| 160 std::string ExtensionWarning::GetLocalizedMessage( | 179 std::string ExtensionWarning::GetLocalizedMessage( |
| 161 const ExtensionSet* extensions) const { | 180 const ExtensionSet* extensions) const { |
| 162 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 181 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 163 | 182 |
| 164 // These parameters may be unsafe (URLs and Extension names) and need | 183 // These parameters may be unsafe (URLs and Extension names) and need |
| 165 // to be HTML-escaped before being embedded in the UI. Also extension IDs | 184 // to be HTML-escaped before being embedded in the UI. Also extension IDs |
| 166 // are translated to full extension names. | 185 // are translated to full extension names. |
| 167 std::vector<string16> final_parameters; | 186 std::vector<string16> final_parameters; |
| 168 for (size_t i = 0; i < message_parameters_.size(); ++i) { | 187 for (size_t i = 0; i < message_parameters_.size(); ++i) { |
| 169 std::string message = message_parameters_[i]; | 188 std::string message = message_parameters_[i]; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 197 } | 216 } |
| 198 } | 217 } |
| 199 | 218 |
| 200 bool operator<(const ExtensionWarning& a, const ExtensionWarning& b) { | 219 bool operator<(const ExtensionWarning& a, const ExtensionWarning& b) { |
| 201 if (a.extension_id() != b.extension_id()) | 220 if (a.extension_id() != b.extension_id()) |
| 202 return a.extension_id() < b.extension_id(); | 221 return a.extension_id() < b.extension_id(); |
| 203 return a.warning_type() < b.warning_type(); | 222 return a.warning_type() < b.warning_type(); |
| 204 } | 223 } |
| 205 | 224 |
| 206 } // namespace extensions | 225 } // namespace extensions |
| OLD | NEW |