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