OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/ui/passwords/manage_passwords_view_utils.h" | 5 #include "chrome/browser/ui/passwords/manage_passwords_view_utils.h" |
6 | 6 |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "chrome/browser/ui/elide_url.h" | 8 #include "chrome/browser/ui/elide_url.h" |
9 #include "chrome/grit/chromium_strings.h" | 9 #include "chrome/grit/chromium_strings.h" |
10 #include "chrome/grit/generated_resources.h" | 10 #include "chrome/grit/generated_resources.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 return gfx::ImageSkiaOperations::CreateResizedImage( | 32 return gfx::ImageSkiaOperations::CreateResizedImage( |
33 skia_image, | 33 skia_image, |
34 skia::ImageOperations::RESIZE_BEST, | 34 skia::ImageOperations::RESIZE_BEST, |
35 gfx::Size(kAvatarImageSize, kAvatarImageSize)); | 35 gfx::Size(kAvatarImageSize, kAvatarImageSize)); |
36 } | 36 } |
37 | 37 |
38 void GetSavePasswordDialogTitleTextAndLinkRange( | 38 void GetSavePasswordDialogTitleTextAndLinkRange( |
39 const GURL& user_visible_url, | 39 const GURL& user_visible_url, |
40 const GURL& form_origin_url, | 40 const GURL& form_origin_url, |
41 bool is_smartlock_branding_enabled, | 41 bool is_smartlock_branding_enabled, |
| 42 bool is_change_password, |
42 base::string16* title, | 43 base::string16* title, |
43 gfx::Range* title_link_range) { | 44 gfx::Range* title_link_range) { |
44 std::vector<size_t> offsets; | 45 std::vector<size_t> offsets; |
45 std::vector<base::string16> replacements; | 46 std::vector<base::string16> replacements; |
46 int title_id = IDS_SAVE_PASSWORD; | 47 int title_id = is_change_password ? IDS_UPDATE_PASSWORD : IDS_SAVE_PASSWORD; |
47 | 48 |
48 // Check whether the registry controlled domains for user-visible URL (i.e. | 49 // Check whether the registry controlled domains for user-visible URL (i.e. |
49 // the one seen in the omnibox) and the password form post-submit navigation | 50 // the one seen in the omnibox) and the password form post-submit navigation |
50 // URL differs or not. | 51 // URL differs or not. |
51 bool target_domain_differs = | 52 bool target_domain_differs = |
52 !net::registry_controlled_domains::SameDomainOrHost( | 53 !net::registry_controlled_domains::SameDomainOrHost( |
53 user_visible_url, form_origin_url, | 54 user_visible_url, form_origin_url, |
54 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES); | 55 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES); |
55 if (target_domain_differs) { | 56 if (target_domain_differs) { |
56 title_id = IDS_SAVE_PASSWORD_TITLE; | 57 title_id = IDS_SAVE_PASSWORD_TITLE; |
57 replacements.push_back( | 58 replacements.push_back( |
58 FormatUrlForSecurityDisplay(form_origin_url, std::string())); | 59 FormatUrlForSecurityDisplay(form_origin_url, std::string())); |
59 } | 60 } |
60 | 61 |
61 if (is_smartlock_branding_enabled) { | 62 if (is_smartlock_branding_enabled) { |
62 // "Google Smart Lock" should be a hyperlink. | 63 // "Google Smart Lock" should be a hyperlink. |
63 base::string16 title_link = | 64 base::string16 title_link = |
64 l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SMART_LOCK); | 65 l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SMART_LOCK); |
65 replacements.insert(replacements.begin(), title_link); | 66 replacements.insert(replacements.begin(), title_link); |
66 *title = l10n_util::GetStringFUTF16(title_id, replacements, &offsets); | 67 *title = l10n_util::GetStringFUTF16(title_id, replacements, &offsets); |
67 *title_link_range = | 68 *title_link_range = |
68 gfx::Range(offsets[0], offsets[0] + title_link.length()); | 69 gfx::Range(offsets[0], offsets[0] + title_link.length()); |
69 } else { | 70 } else { |
70 replacements.insert( | 71 replacements.insert( |
71 replacements.begin(), | 72 replacements.begin(), |
72 l10n_util::GetStringUTF16(IDS_SAVE_PASSWORD_TITLE_BRAND)); | 73 l10n_util::GetStringUTF16(IDS_SAVE_PASSWORD_TITLE_BRAND)); |
73 *title = l10n_util::GetStringFUTF16(title_id, replacements, &offsets); | 74 *title = l10n_util::GetStringFUTF16(title_id, replacements, &offsets); |
74 } | 75 } |
75 } | 76 } |
OLD | NEW |