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

Side by Side Diff: ios/chrome/browser/passwords/credential_manager.mm

Issue 1723583004: CREDENTIAL: Convert federations from URLs to origins throughout. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: iOS2 Created 4 years, 9 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 #import "ios/chrome/browser/passwords/credential_manager.h" 5 #import "ios/chrome/browser/passwords/credential_manager.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/ios/ios_util.h" 9 #include "base/ios/ios_util.h"
10 #import "base/ios/weak_nsobject.h" 10 #import "base/ios/weak_nsobject.h"
11 #include "base/mac/bind_objc_block.h" 11 #include "base/mac/bind_objc_block.h"
12 #include "base/memory/scoped_vector.h" 12 #include "base/memory/scoped_vector.h"
13 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
14 #include "base/strings/sys_string_conversions.h" 14 #include "base/strings/sys_string_conversions.h"
15 #include "components/password_manager/core/browser/password_store_consumer.h" 15 #include "components/password_manager/core/browser/password_store_consumer.h"
16 #include "components/password_manager/core/common/credential_manager_types.h" 16 #include "components/password_manager/core/common/credential_manager_types.h"
17 #include "components/password_manager/core/common/password_manager_pref_names.h" 17 #include "components/password_manager/core/common/password_manager_pref_names.h"
18 #import "ios/chrome/browser/passwords/js_credential_manager.h" 18 #import "ios/chrome/browser/passwords/js_credential_manager.h"
19 #import "ios/web/public/url_scheme_util.h" 19 #import "ios/web/public/url_scheme_util.h"
20 #include "ios/web/public/web_state/credential.h" 20 #include "ios/web/public/web_state/credential.h"
21 #include "ios/web/public/web_state/url_verification_constants.h" 21 #include "ios/web/public/web_state/url_verification_constants.h"
22 #include "ios/web/public/web_state/web_state.h" 22 #include "ios/web/public/web_state/web_state.h"
23 #include "url/origin.h"
23 24
24 namespace { 25 namespace {
25 26
26 // Converts a password_manager::CredentialInfo to a web::Credential. 27 // Converts a password_manager::CredentialInfo to a web::Credential.
27 web::Credential WebCredentialFromCredentialInfo( 28 web::Credential WebCredentialFromCredentialInfo(
28 const password_manager::CredentialInfo& credential_info) { 29 const password_manager::CredentialInfo& credential_info) {
29 web::Credential credential; 30 web::Credential credential;
30 switch (credential_info.type) { 31 switch (credential_info.type) {
31 case password_manager::CredentialType::CREDENTIAL_TYPE_EMPTY: 32 case password_manager::CredentialType::CREDENTIAL_TYPE_EMPTY:
32 credential.type = web::CredentialType::CREDENTIAL_TYPE_EMPTY; 33 credential.type = web::CredentialType::CREDENTIAL_TYPE_EMPTY;
33 break; 34 break;
34 case password_manager::CredentialType::CREDENTIAL_TYPE_PASSWORD: 35 case password_manager::CredentialType::CREDENTIAL_TYPE_PASSWORD:
35 credential.type = web::CredentialType::CREDENTIAL_TYPE_PASSWORD; 36 credential.type = web::CredentialType::CREDENTIAL_TYPE_PASSWORD;
36 break; 37 break;
37 case password_manager::CredentialType::CREDENTIAL_TYPE_FEDERATED: 38 case password_manager::CredentialType::CREDENTIAL_TYPE_FEDERATED:
38 credential.type = web::CredentialType::CREDENTIAL_TYPE_FEDERATED; 39 credential.type = web::CredentialType::CREDENTIAL_TYPE_FEDERATED;
39 break; 40 break;
40 } 41 }
41 credential.id = credential_info.id; 42 credential.id = credential_info.id;
42 credential.name = credential_info.name; 43 credential.name = credential_info.name;
43 credential.avatar_url = credential_info.icon; 44 credential.avatar_url = credential_info.icon;
44 credential.password = credential_info.password; 45 credential.password = credential_info.password;
45 credential.federation_url = credential_info.federation; 46 credential.federation_origin = credential_info.federation;
46 return credential; 47 return credential;
47 } 48 }
48 49
49 // Converts a web::Credential to a password_manager::CredentialInfo. 50 // Converts a web::Credential to a password_manager::CredentialInfo.
50 password_manager::CredentialInfo CredentialInfoFromWebCredential( 51 password_manager::CredentialInfo CredentialInfoFromWebCredential(
51 const web::Credential& credential) { 52 const web::Credential& credential) {
52 password_manager::CredentialInfo credential_info; 53 password_manager::CredentialInfo credential_info;
53 switch (credential.type) { 54 switch (credential.type) {
54 case web::CredentialType::CREDENTIAL_TYPE_EMPTY: 55 case web::CredentialType::CREDENTIAL_TYPE_EMPTY:
55 credential_info.type = 56 credential_info.type =
56 password_manager::CredentialType::CREDENTIAL_TYPE_EMPTY; 57 password_manager::CredentialType::CREDENTIAL_TYPE_EMPTY;
57 break; 58 break;
58 case web::CredentialType::CREDENTIAL_TYPE_PASSWORD: 59 case web::CredentialType::CREDENTIAL_TYPE_PASSWORD:
59 credential_info.type = 60 credential_info.type =
60 password_manager::CredentialType::CREDENTIAL_TYPE_PASSWORD; 61 password_manager::CredentialType::CREDENTIAL_TYPE_PASSWORD;
61 break; 62 break;
62 case web::CredentialType::CREDENTIAL_TYPE_FEDERATED: 63 case web::CredentialType::CREDENTIAL_TYPE_FEDERATED:
63 credential_info.type = 64 credential_info.type =
64 password_manager::CredentialType::CREDENTIAL_TYPE_FEDERATED; 65 password_manager::CredentialType::CREDENTIAL_TYPE_FEDERATED;
65 break; 66 break;
66 } 67 }
67 credential_info.id = credential.id; 68 credential_info.id = credential.id;
68 credential_info.name = credential.name; 69 credential_info.name = credential.name;
69 credential_info.icon = credential.avatar_url; 70 credential_info.icon = credential.avatar_url;
70 credential_info.password = credential.password; 71 credential_info.password = credential.password;
71 credential_info.federation = credential.federation_url; 72 credential_info.federation = credential.federation_origin;
72 return credential_info; 73 return credential_info;
73 } 74 }
74 75
75 } // namespace 76 } // namespace
76 77
77 CredentialManager::CredentialManager( 78 CredentialManager::CredentialManager(
78 web::WebState* web_state, 79 web::WebState* web_state,
79 password_manager::PasswordManagerClient* client, 80 password_manager::PasswordManagerClient* client,
80 password_manager::PasswordManagerDriver* driver, 81 password_manager::PasswordManagerDriver* driver,
81 JSCredentialManager* js_manager) 82 JSCredentialManager* js_manager)
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 bool CredentialManager::GetUrlWithAbsoluteTrust(GURL* page_url) { 355 bool CredentialManager::GetUrlWithAbsoluteTrust(GURL* page_url) {
355 web::URLVerificationTrustLevel trust_level = 356 web::URLVerificationTrustLevel trust_level =
356 web::URLVerificationTrustLevel::kNone; 357 web::URLVerificationTrustLevel::kNone;
357 const GURL possibly_untrusted_url(web_state()->GetCurrentURL(&trust_level)); 358 const GURL possibly_untrusted_url(web_state()->GetCurrentURL(&trust_level));
358 if (trust_level == web::URLVerificationTrustLevel::kAbsolute) { 359 if (trust_level == web::URLVerificationTrustLevel::kAbsolute) {
359 *page_url = possibly_untrusted_url; 360 *page_url = possibly_untrusted_url;
360 return true; 361 return true;
361 } 362 }
362 return false; 363 return false;
363 } 364 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698