| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 return std::make_pair(upper_string, lower_string); | 71 return std::make_pair(upper_string, lower_string); |
| 72 } | 72 } |
| 73 | 73 |
| 74 void GetSavePasswordDialogTitleTextAndLinkRange( | 74 void GetSavePasswordDialogTitleTextAndLinkRange( |
| 75 const GURL& user_visible_url, | 75 const GURL& user_visible_url, |
| 76 const GURL& form_origin_url, | 76 const GURL& form_origin_url, |
| 77 bool is_smartlock_branding_enabled, | 77 bool is_smartlock_branding_enabled, |
| 78 PasswordTittleType dialog_type, | 78 PasswordTittleType dialog_type, |
| 79 base::string16* title, | 79 base::string16* title, |
| 80 gfx::Range* title_link_range) { | 80 gfx::Range* title_link_range) { |
| 81 DCHECK(!password_manager::IsValidAndroidFacetURI(form_origin_url.spec())); |
| 81 std::vector<size_t> offsets; | 82 std::vector<size_t> offsets; |
| 82 std::vector<base::string16> replacements; | 83 std::vector<base::string16> replacements; |
| 83 int title_id = 0; | 84 int title_id = 0; |
| 84 switch (dialog_type) { | 85 switch (dialog_type) { |
| 85 case PasswordTittleType::SAVE_PASSWORD: | 86 case PasswordTittleType::SAVE_PASSWORD: |
| 86 title_id = IDS_SAVE_PASSWORD; | 87 title_id = IDS_SAVE_PASSWORD; |
| 87 break; | 88 break; |
| 88 case PasswordTittleType::SAVE_ACCOUNT: | 89 case PasswordTittleType::SAVE_ACCOUNT: |
| 89 title_id = IDS_SAVE_ACCOUNT; | 90 title_id = IDS_SAVE_ACCOUNT; |
| 90 break; | 91 break; |
| 91 case PasswordTittleType::UPDATE_PASSWORD: | 92 case PasswordTittleType::UPDATE_PASSWORD: |
| 92 title_id = IDS_UPDATE_PASSWORD; | 93 title_id = IDS_UPDATE_PASSWORD; |
| 93 break; | 94 break; |
| 94 } | 95 } |
| 95 | 96 |
| 96 // Check whether the registry controlled domains for user-visible URL (i.e. | 97 // Check whether the registry controlled domains for user-visible URL (i.e. |
| 97 // the one seen in the omnibox) and the password form post-submit navigation | 98 // the one seen in the omnibox) and the password form post-submit navigation |
| 98 // URL differs or not. | 99 // URL differs or not. |
| 99 password_manager::FacetURI facet_uri = | 100 if (!SameDomainOrHost(user_visible_url, form_origin_url)) { |
| 100 password_manager::FacetURI::FromPotentiallyInvalidSpec( | |
| 101 form_origin_url.spec()); | |
| 102 if (facet_uri.IsValidAndroidFacetURI()) { | |
| 103 title_id = IDS_SAVE_PASSWORD_TITLE; | |
| 104 replacements.push_back( | |
| 105 base::ASCIIToUTF16(GetHumanReadableOriginForAndroidUri(facet_uri))); | |
| 106 } else if (!SameDomainOrHost(user_visible_url, form_origin_url)) { | |
| 107 title_id = IDS_SAVE_PASSWORD_TITLE; | 101 title_id = IDS_SAVE_PASSWORD_TITLE; |
| 108 // TODO(palmer): Look into passing real language prefs here, not "". | 102 // TODO(palmer): Look into passing real language prefs here, not "". |
| 109 // crbug.com/498069. | 103 // crbug.com/498069. |
| 110 replacements.push_back(url_formatter::FormatUrlForSecurityDisplay( | 104 replacements.push_back(url_formatter::FormatUrlForSecurityDisplay( |
| 111 form_origin_url, std::string())); | 105 form_origin_url, std::string())); |
| 112 } | 106 } |
| 113 | 107 |
| 114 if (is_smartlock_branding_enabled) { | 108 if (is_smartlock_branding_enabled) { |
| 115 // "Google Smart Lock" should be a hyperlink. | 109 // "Google Smart Lock" should be a hyperlink. |
| 116 base::string16 title_link = | 110 base::string16 title_link = |
| 117 l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SMART_LOCK); | 111 l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SMART_LOCK); |
| 118 replacements.insert(replacements.begin(), title_link); | 112 replacements.insert(replacements.begin(), title_link); |
| 119 *title = l10n_util::GetStringFUTF16(title_id, replacements, &offsets); | 113 *title = l10n_util::GetStringFUTF16(title_id, replacements, &offsets); |
| 120 *title_link_range = | 114 *title_link_range = |
| 121 gfx::Range(offsets[0], offsets[0] + title_link.length()); | 115 gfx::Range(offsets[0], offsets[0] + title_link.length()); |
| 122 } else { | 116 } else { |
| 123 replacements.insert( | 117 replacements.insert( |
| 124 replacements.begin(), | 118 replacements.begin(), |
| 125 l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_TITLE_BRAND)); | 119 l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_TITLE_BRAND)); |
| 126 *title = l10n_util::GetStringFUTF16(title_id, replacements, &offsets); | 120 *title = l10n_util::GetStringFUTF16(title_id, replacements, &offsets); |
| 127 } | 121 } |
| 128 } | 122 } |
| 129 | 123 |
| 130 void GetManagePasswordsDialogTitleText(const GURL& user_visible_url, | 124 void GetManagePasswordsDialogTitleText(const GURL& user_visible_url, |
| 131 const GURL& password_origin_url, | 125 const GURL& password_origin_url, |
| 132 base::string16* title) { | 126 base::string16* title) { |
| 127 DCHECK(!password_manager::IsValidAndroidFacetURI(password_origin_url.spec())); |
| 133 // Check whether the registry controlled domains for user-visible URL | 128 // Check whether the registry controlled domains for user-visible URL |
| 134 // (i.e. the one seen in the omnibox) and the managed password origin URL | 129 // (i.e. the one seen in the omnibox) and the managed password origin URL |
| 135 // differ or not. | 130 // differ or not. |
| 136 password_manager::FacetURI facet_uri = | 131 if (!SameDomainOrHost(user_visible_url, password_origin_url)) { |
| 137 password_manager::FacetURI::FromPotentiallyInvalidSpec( | |
| 138 password_origin_url.spec()); | |
| 139 if (facet_uri.IsValidAndroidFacetURI()) { | |
| 140 *title = l10n_util::GetStringFUTF16( | |
| 141 IDS_MANAGE_PASSWORDS_TITLE_DIFFERENT_DOMAIN, | |
| 142 base::ASCIIToUTF16(GetHumanReadableOriginForAndroidUri(facet_uri))); | |
| 143 } else if (!SameDomainOrHost(user_visible_url, password_origin_url)) { | |
| 144 // TODO(palmer): Look into passing real language prefs here, not "". | 132 // TODO(palmer): Look into passing real language prefs here, not "". |
| 145 base::string16 formatted_url = url_formatter::FormatUrlForSecurityDisplay( | 133 base::string16 formatted_url = url_formatter::FormatUrlForSecurityDisplay( |
| 146 password_origin_url, std::string()); | 134 password_origin_url, std::string()); |
| 147 *title = l10n_util::GetStringFUTF16( | 135 *title = l10n_util::GetStringFUTF16( |
| 148 IDS_MANAGE_PASSWORDS_TITLE_DIFFERENT_DOMAIN, formatted_url); | 136 IDS_MANAGE_PASSWORDS_TITLE_DIFFERENT_DOMAIN, formatted_url); |
| 149 } else { | 137 } else { |
| 150 *title = l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_TITLE); | 138 *title = l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_TITLE); |
| 151 } | 139 } |
| 152 } | 140 } |
| 153 | 141 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 : form.username_value; | 175 : form.username_value; |
| 188 } | 176 } |
| 189 | 177 |
| 190 bool IsSyncingAutosignSetting(Profile* profile) { | 178 bool IsSyncingAutosignSetting(Profile* profile) { |
| 191 const ProfileSyncService* sync_service = | 179 const ProfileSyncService* sync_service = |
| 192 ProfileSyncServiceFactory::GetForProfile(profile); | 180 ProfileSyncServiceFactory::GetForProfile(profile); |
| 193 return (sync_service && sync_service->IsFirstSetupComplete() && | 181 return (sync_service && sync_service->IsFirstSetupComplete() && |
| 194 sync_service->IsSyncActive() && | 182 sync_service->IsSyncActive() && |
| 195 sync_service->GetActiveDataTypes().Has(syncer::PRIORITY_PREFERENCES)); | 183 sync_service->GetActiveDataTypes().Has(syncer::PRIORITY_PREFERENCES)); |
| 196 } | 184 } |
| OLD | NEW |