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

Side by Side Diff: chrome/browser/ui/passwords/manage_passwords_view_utils.cc

Issue 1723583004: CREDENTIAL: Convert federations from URLs to origins throughout. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months 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 unified diff | Download patch
OLDNEW
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/net_util.h" 21 #include "net/base/net_util.h"
22 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" 22 #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
23 #include "ui/base/l10n/l10n_util.h" 23 #include "ui/base/l10n/l10n_util.h"
24 #include "ui/gfx/geometry/rect.h" 24 #include "ui/gfx/geometry/rect.h"
25 #include "ui/gfx/geometry/size.h" 25 #include "ui/gfx/geometry/size.h"
26 #include "ui/gfx/image/image_skia.h" 26 #include "ui/gfx/image/image_skia.h"
27 #include "ui/gfx/image/image_skia_operations.h" 27 #include "ui/gfx/image/image_skia_operations.h"
28 #include "ui/gfx/range/range.h" 28 #include "ui/gfx/range/range.h"
29 #include "url/gurl.h" 29 #include "url/gurl.h"
30 #include "url/origin.h"
30 31
31 namespace { 32 namespace {
32 33
33 // Checks whether two URLs are from the same domain or host. 34 // Checks whether two URLs are from the same domain or host.
34 bool SameDomainOrHost(const GURL& gurl1, const GURL& gurl2) { 35 bool SameDomainOrHost(const GURL& gurl1, const GURL& gurl2) {
35 return net::registry_controlled_domains::SameDomainOrHost( 36 return net::registry_controlled_domains::SameDomainOrHost(
36 gurl1, gurl2, 37 gurl1, gurl2,
37 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES); 38 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES);
38 } 39 }
39 40
(...skipping 13 matching lines...) Expand all
53 skia_image, 54 skia_image,
54 skia::ImageOperations::RESIZE_BEST, 55 skia::ImageOperations::RESIZE_BEST,
55 gfx::Size(kAvatarImageSize, kAvatarImageSize)); 56 gfx::Size(kAvatarImageSize, kAvatarImageSize));
56 } 57 }
57 58
58 std::pair<base::string16, base::string16> GetCredentialLabelsForAccountChooser( 59 std::pair<base::string16, base::string16> GetCredentialLabelsForAccountChooser(
59 const autofill::PasswordForm& form) { 60 const autofill::PasswordForm& form) {
60 const base::string16& upper_string = 61 const base::string16& upper_string =
61 form.display_name.empty() ? form.username_value : form.display_name; 62 form.display_name.empty() ? form.username_value : form.display_name;
62 base::string16 lower_string; 63 base::string16 lower_string;
63 if (form.federation_url.is_empty()) { 64 if (form.federation_origin.unique()) {
64 if (!form.display_name.empty()) 65 if (!form.display_name.empty())
65 lower_string = form.username_value; 66 lower_string = form.username_value;
66 } else { 67 } else {
67 lower_string = l10n_util::GetStringFUTF16( 68 lower_string = l10n_util::GetStringFUTF16(
68 IDS_PASSWORDS_VIA_FEDERATION, 69 IDS_PASSWORDS_VIA_FEDERATION,
69 base::UTF8ToUTF16(form.federation_url.host())); 70 base::UTF8ToUTF16(form.federation_origin.host()));
70 } 71 }
71 return std::make_pair(upper_string, lower_string); 72 return std::make_pair(upper_string, lower_string);
72 } 73 }
73 74
74 void GetSavePasswordDialogTitleTextAndLinkRange( 75 void GetSavePasswordDialogTitleTextAndLinkRange(
75 const GURL& user_visible_url, 76 const GURL& user_visible_url,
76 const GURL& form_origin_url, 77 const GURL& form_origin_url,
77 bool is_smartlock_branding_enabled, 78 bool is_smartlock_branding_enabled,
78 PasswordTittleType dialog_type, 79 PasswordTittleType dialog_type,
79 base::string16* title, 80 base::string16* title,
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 : form.username_value; 174 : form.username_value;
174 } 175 }
175 176
176 bool IsSyncingSettings(Profile* profile) { 177 bool IsSyncingSettings(Profile* profile) {
177 const ProfileSyncService* sync_service = 178 const ProfileSyncService* sync_service =
178 ProfileSyncServiceFactory::GetForProfile(profile); 179 ProfileSyncServiceFactory::GetForProfile(profile);
179 return (sync_service && sync_service->IsFirstSetupComplete() && 180 return (sync_service && sync_service->IsFirstSetupComplete() &&
180 sync_service->IsSyncActive() && 181 sync_service->IsSyncActive() &&
181 sync_service->GetActiveDataTypes().Has(syncer::PREFERENCES)); 182 sync_service->GetActiveDataTypes().Has(syncer::PREFERENCES));
182 } 183 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698