Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4215)

Unified Diff: chrome/browser/ui/passwords/manage_passwords_view_utils.cc

Issue 2534113002: Handle empty string in GetSavePasswordDialogTitleTextAndLinkRange gracefully (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/passwords/manage_passwords_view_utils_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/passwords/manage_passwords_view_utils.cc
diff --git a/chrome/browser/ui/passwords/manage_passwords_view_utils.cc b/chrome/browser/ui/passwords/manage_passwords_view_utils.cc
index f7314779c4ad26d8654c9cc34f8e96eee5f0f328..945088530e0947dce865a65ff2fd177149977842 100644
--- a/chrome/browser/ui/passwords/manage_passwords_view_utils.cc
+++ b/chrome/browser/ui/passwords/manage_passwords_view_utils.cc
@@ -116,8 +116,13 @@ void GetSavePasswordDialogTitleTextAndLinkRange(
l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SMART_LOCK);
replacements.insert(replacements.begin(), title_link);
*title = l10n_util::GetStringFUTF16(title_id, replacements, &offsets);
- *title_link_range =
- gfx::Range(offsets[0], offsets[0] + title_link.length());
+ if (!offsets.empty()) {
+ // |offsets| can be empty when the localised string associated with
+ // |title_id| could not be found. While this situation is an error, it
+ // needs to be handled gracefully, see http://crbug.com/658902#c18.
+ *title_link_range =
+ gfx::Range(offsets[0], offsets[0] + title_link.length());
+ }
} else {
replacements.insert(
replacements.begin(),
« no previous file with comments | « no previous file | chrome/browser/ui/passwords/manage_passwords_view_utils_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698