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

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

Issue 2439953004: Remove invalid "suffix" assumption from CreateSortKey (Closed)
Patch Set: Fix typo Created 4 years, 2 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/password_manager_presenter.h" 5 #include "chrome/browser/ui/passwords/password_manager_presenter.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 std::string GetEntryTypeCode(bool is_android_uri, bool is_clickable) { 58 std::string GetEntryTypeCode(bool is_android_uri, bool is_clickable) {
59 if (!is_android_uri) 59 if (!is_android_uri)
60 return "0"; 60 return "0";
61 if (is_clickable) 61 if (is_clickable)
62 return "1"; 62 return "1";
63 return "2"; 63 return "2";
64 } 64 }
65 65
66 // Creates key for sorting password or password exception entries. 66 // Creates key for sorting password or password exception entries.
67 // The key is eTLD+1 followed by subdomains 67 // The key is eTLD+1 followed by subdomains
68 // (e.g. secure.accounts.example.com => example.com.accounts.secure). 68 // (e.g. secure.accounts.example.com => example.com.accounts.secure).
kolos1 2016/10/24 03:35:35 Fix the method description. The key is eTLD+1 fol
vabr (Chromium) 2016/10/24 08:54:02 Done.
69 // If |entry_type == SAVED|, username, password and federation are appended to 69 // If |entry_type == SAVED|, username, password and federation are appended to
70 // the key. The entry type code (non-Android, Android w/ or w/o affiliated web 70 // the key. The entry type code (non-Android, Android w/ or w/o affiliated web
71 // realm) is also appended to the key. 71 // realm) is also appended to the key.
72 std::string CreateSortKey(const autofill::PasswordForm& form, 72 std::string CreateSortKey(const autofill::PasswordForm& form,
73 PasswordEntryType entry_type) { 73 PasswordEntryType entry_type) {
74 bool is_android_uri = false; 74 bool is_android_uri = false;
75 bool is_clickable = false; 75 bool is_clickable = false;
76 GURL link_url; 76 GURL link_url;
77 std::string origin = password_manager::GetShownOriginAndLinkUrl( 77 std::string origin = password_manager::GetShownOriginAndLinkUrl(
78 form, &is_android_uri, &link_url, &is_clickable); 78 form, &is_android_uri, &link_url, &is_clickable);
79 79
80 if (!is_clickable) { // e.g. android://com.example.r => r.example.com. 80 if (!is_clickable) { // e.g. android://com.example.r => r.example.com.
kolos1 2016/10/24 03:35:35 Unnecessary curly brackets
vabr (Chromium) 2016/10/24 08:54:02 Done.
81 origin = password_manager::StripAndroidAndReverse(origin); 81 origin = password_manager::StripAndroidAndReverse(origin);
82 } 82 }
83 83
84 std::string site_name = 84 std::string site_name =
85 net::registry_controlled_domains::GetDomainAndRegistry( 85 net::registry_controlled_domains::GetDomainAndRegistry(
86 origin, net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES); 86 origin, net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES);
87 if (site_name.empty()) // e.g. localhost. 87 if (site_name.empty()) // e.g. localhost.
88 site_name = origin; 88 site_name = origin;
89 std::string key = 89 std::string key = site_name + password_manager::SplitByDotAndReverse(origin);
90 site_name + password_manager::SplitByDotAndReverse(StringPiece(
91 &origin[0], origin.length() - site_name.length()));
92 90
93 if (entry_type == PasswordEntryType::SAVED) { 91 if (entry_type == PasswordEntryType::SAVED) {
94 key = key + kSortKeyPartsSeparator + 92 key = key + kSortKeyPartsSeparator +
95 base::UTF16ToUTF8(form.username_value) + kSortKeyPartsSeparator + 93 base::UTF16ToUTF8(form.username_value) + kSortKeyPartsSeparator +
96 base::UTF16ToUTF8(form.password_value); 94 base::UTF16ToUTF8(form.password_value);
97 if (!form.federation_origin.unique()) 95 if (!form.federation_origin.unique())
98 key = key + kSortKeyPartsSeparator + form.federation_origin.host(); 96 key = key + kSortKeyPartsSeparator + form.federation_origin.host();
99 } 97 }
100 98
101 // Since Android and non-Android entries shouldn't be merged into one entry, 99 // Since Android and non-Android entries shouldn't be merged into one entry,
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 383
386 void PasswordManagerPresenter::PasswordExceptionListPopulater:: 384 void PasswordManagerPresenter::PasswordExceptionListPopulater::
387 OnGetPasswordStoreResults( 385 OnGetPasswordStoreResults(
388 std::vector<std::unique_ptr<autofill::PasswordForm>> results) { 386 std::vector<std::unique_ptr<autofill::PasswordForm>> results) {
389 page_->password_exception_list_ = std::move(results); 387 page_->password_exception_list_ = std::move(results);
390 page_->SortEntriesAndHideDuplicates(&page_->password_exception_list_, 388 page_->SortEntriesAndHideDuplicates(&page_->password_exception_list_,
391 &page_->password_exception_duplicates_, 389 &page_->password_exception_duplicates_,
392 PasswordEntryType::BLACKLISTED); 390 PasswordEntryType::BLACKLISTED);
393 page_->SetPasswordExceptionList(); 391 page_->SetPasswordExceptionList();
394 } 392 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698