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

Side by Side Diff: third_party/WebKit/Source/platform/exported/WebCredential.cpp

Issue 1976943002: Avoid object slicing in WebCredential::create (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
Patch Set: Created 4 years, 7 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "public/platform/WebCredential.h" 5 #include "public/platform/WebCredential.h"
6 6
7 #include "platform/credentialmanager/PlatformCredential.h" 7 #include "platform/credentialmanager/PlatformCredential.h"
8 #include "public/platform/WebFederatedCredential.h" 8 #include "public/platform/WebFederatedCredential.h"
9 #include "public/platform/WebPasswordCredential.h" 9 #include "public/platform/WebPasswordCredential.h"
10 #include "wtf/PtrUtil.h"
10 11
11 namespace blink { 12 namespace blink {
12 13
13 WebCredential WebCredential::create(PlatformCredential* credential) 14 std::unique_ptr<WebCredential> WebCredential::create(PlatformCredential* credent ial)
14 { 15 {
15 if (credential->isPassword()) { 16 if (credential->isPassword()) {
16 WebPasswordCredential password(credential); 17 return WTF::wrapUnique(new WebPasswordCredential(credential));
17 return password;
18 } 18 }
19 19
20 if (credential->isFederated()) { 20 if (credential->isFederated()) {
21 WebFederatedCredential federated(credential); 21 return WTF::wrapUnique(new WebFederatedCredential(credential));
22 return federated;
23 } 22 }
24 23
25 ASSERT_NOT_REACHED(); 24 ASSERT_NOT_REACHED();
26 return WebCredential(credential); 25 return nullptr;
27 } 26 }
28 27
29 WebCredential::WebCredential(const WebString& id, const WebString& name, const W ebURL& iconURL) 28 WebCredential::WebCredential(const WebString& id, const WebString& name, const W ebURL& iconURL)
30 : m_platformCredential(PlatformCredential::create(id, name, iconURL)) 29 : m_platformCredential(PlatformCredential::create(id, name, iconURL))
31 { 30 {
32 } 31 }
33 32
34 WebCredential::WebCredential(const WebCredential& other) 33 WebCredential::WebCredential(const WebCredential& other)
35 { 34 {
36 assign(other); 35 assign(other);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 { 80 {
82 return m_platformCredential->isPassword(); 81 return m_platformCredential->isPassword();
83 } 82 }
84 83
85 bool WebCredential::isFederatedCredential() const 84 bool WebCredential::isFederatedCredential() const
86 { 85 {
87 return m_platformCredential->isFederated(); 86 return m_platformCredential->isFederated();
88 } 87 }
89 88
90 } // namespace blink 89 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698