| 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 |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/sync/profile_sync_service_factory.h" | 13 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 14 #include "chrome/grit/chromium_strings.h" | 14 #include "chrome/grit/chromium_strings.h" |
| 15 #include "chrome/grit/generated_resources.h" | 15 #include "chrome/grit/generated_resources.h" |
| 16 #include "components/autofill/core/common/password_form.h" | 16 #include "components/autofill/core/common/password_form.h" |
| 17 #include "components/browser_sync/browser/profile_sync_service.h" | 17 #include "components/browser_sync/browser/profile_sync_service.h" |
| 18 #include "components/password_manager/core/browser/affiliation_utils.h" | 18 #include "components/password_manager/core/browser/affiliation_utils.h" |
| 19 #include "components/url_formatter/elide_url.h" | 19 #include "components/url_formatter/elide_url.h" |
| 20 #include "grit/components_strings.h" | 20 #include "grit/components_strings.h" |
| 21 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 21 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
| 22 #include "ui/base/l10n/l10n_util.h" | 22 #include "ui/base/l10n/l10n_util.h" |
| 23 #include "ui/gfx/geometry/rect.h" | 23 #include "ui/gfx/geometry/rect.h" |
| 24 #include "ui/gfx/geometry/size.h" | 24 #include "ui/gfx/geometry/size.h" |
| 25 #include "ui/gfx/image/image_skia.h" | 25 #include "ui/gfx/image/image_skia.h" |
| 26 #include "ui/gfx/image/image_skia_operations.h" | 26 #include "ui/gfx/image/image_skia_operations.h" |
| 27 #include "ui/gfx/range/range.h" | 27 #include "ui/gfx/range/range.h" |
| 28 #include "url/gurl.h" | 28 #include "url/gurl.h" |
| 29 #include "url/origin.h" |
| 29 | 30 |
| 30 namespace { | 31 namespace { |
| 31 | 32 |
| 32 // Checks whether two URLs are from the same domain or host. | 33 // Checks whether two URLs are from the same domain or host. |
| 33 bool SameDomainOrHost(const GURL& gurl1, const GURL& gurl2) { | 34 bool SameDomainOrHost(const GURL& gurl1, const GURL& gurl2) { |
| 34 return net::registry_controlled_domains::SameDomainOrHost( | 35 return net::registry_controlled_domains::SameDomainOrHost( |
| 35 gurl1, gurl2, | 36 gurl1, gurl2, |
| 36 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES); | 37 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES); |
| 37 } | 38 } |
| 38 | 39 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 52 skia_image, | 53 skia_image, |
| 53 skia::ImageOperations::RESIZE_BEST, | 54 skia::ImageOperations::RESIZE_BEST, |
| 54 gfx::Size(kAvatarImageSize, kAvatarImageSize)); | 55 gfx::Size(kAvatarImageSize, kAvatarImageSize)); |
| 55 } | 56 } |
| 56 | 57 |
| 57 std::pair<base::string16, base::string16> GetCredentialLabelsForAccountChooser( | 58 std::pair<base::string16, base::string16> GetCredentialLabelsForAccountChooser( |
| 58 const autofill::PasswordForm& form) { | 59 const autofill::PasswordForm& form) { |
| 59 const base::string16& upper_string = | 60 const base::string16& upper_string = |
| 60 form.display_name.empty() ? form.username_value : form.display_name; | 61 form.display_name.empty() ? form.username_value : form.display_name; |
| 61 base::string16 lower_string; | 62 base::string16 lower_string; |
| 62 if (form.federation_url.is_empty()) { | 63 if (form.federation_origin.unique()) { |
| 63 if (!form.display_name.empty()) | 64 if (!form.display_name.empty()) |
| 64 lower_string = form.username_value; | 65 lower_string = form.username_value; |
| 65 } else { | 66 } else { |
| 66 lower_string = l10n_util::GetStringFUTF16( | 67 lower_string = l10n_util::GetStringFUTF16( |
| 67 IDS_PASSWORDS_VIA_FEDERATION, | 68 IDS_PASSWORDS_VIA_FEDERATION, |
| 68 base::UTF8ToUTF16(form.federation_url.host())); | 69 base::UTF8ToUTF16(form.federation_origin.host())); |
| 69 } | 70 } |
| 70 return std::make_pair(upper_string, lower_string); | 71 return std::make_pair(upper_string, lower_string); |
| 71 } | 72 } |
| 72 | 73 |
| 73 void GetSavePasswordDialogTitleTextAndLinkRange( | 74 void GetSavePasswordDialogTitleTextAndLinkRange( |
| 74 const GURL& user_visible_url, | 75 const GURL& user_visible_url, |
| 75 const GURL& form_origin_url, | 76 const GURL& form_origin_url, |
| 76 bool is_smartlock_branding_enabled, | 77 bool is_smartlock_branding_enabled, |
| 77 PasswordTittleType dialog_type, | 78 PasswordTittleType dialog_type, |
| 78 base::string16* title, | 79 base::string16* title, |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 : form.username_value; | 173 : form.username_value; |
| 173 } | 174 } |
| 174 | 175 |
| 175 bool IsSyncingSettings(Profile* profile) { | 176 bool IsSyncingSettings(Profile* profile) { |
| 176 const ProfileSyncService* sync_service = | 177 const ProfileSyncService* sync_service = |
| 177 ProfileSyncServiceFactory::GetForProfile(profile); | 178 ProfileSyncServiceFactory::GetForProfile(profile); |
| 178 return (sync_service && sync_service->IsFirstSetupComplete() && | 179 return (sync_service && sync_service->IsFirstSetupComplete() && |
| 179 sync_service->IsSyncActive() && | 180 sync_service->IsSyncActive() && |
| 180 sync_service->GetActiveDataTypes().Has(syncer::PREFERENCES)); | 181 sync_service->GetActiveDataTypes().Has(syncer::PREFERENCES)); |
| 181 } | 182 } |
| OLD | NEW |