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

Side by Side Diff: url/origin.cc

Issue 2391383003: Add Origin::CreateFromNormalizedTuple and call from WebSecurityOrigin (Closed)
Patch Set: git cl format 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
« no previous file with comments | « url/origin.h ('k') | url/scheme_host_port.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "url/origin.h" 5 #include "url/origin.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 21 matching lines...) Expand all
32 // the "path", which boils down to everything after the scheme. GURL's 32 // the "path", which boils down to everything after the scheme. GURL's
33 // 'GetContent()' gives us exactly that. 33 // 'GetContent()' gives us exactly that.
34 tuple_ = SchemeHostPort(GURL(url.GetContent())); 34 tuple_ = SchemeHostPort(GURL(url.GetContent()));
35 } else { 35 } else {
36 tuple_ = SchemeHostPort(url); 36 tuple_ = SchemeHostPort(url);
37 } 37 }
38 38
39 unique_ = tuple_.IsInvalid(); 39 unique_ = tuple_.IsInvalid();
40 } 40 }
41 41
42 Origin::Origin(base::StringPiece scheme, base::StringPiece host, uint16_t port) 42 Origin::Origin(base::StringPiece scheme,
43 : tuple_(scheme, host, port) { 43 base::StringPiece host,
44 uint16_t port,
45 SchemeHostPort::ConstructPolicy policy)
46 : tuple_(scheme, host, port, policy) {
44 unique_ = tuple_.IsInvalid(); 47 unique_ = tuple_.IsInvalid();
45 } 48 }
46 49
47 Origin::~Origin() { 50 Origin::~Origin() {
48 } 51 }
49 52
50 // static 53 // static
51 Origin Origin::UnsafelyCreateOriginWithoutNormalization( 54 Origin Origin::UnsafelyCreateOriginWithoutNormalization(
52 base::StringPiece scheme, 55 base::StringPiece scheme,
53 base::StringPiece host, 56 base::StringPiece host,
54 uint16_t port) { 57 uint16_t port) {
55 return Origin(scheme, host, port); 58 return Origin(scheme, host, port, SchemeHostPort::CHECK_CANONICALIZATION);
59 }
60
61 Origin Origin::CreateFromNormalizedTuple(base::StringPiece scheme,
62 base::StringPiece host,
63 uint16_t port) {
64 return Origin(scheme, host, port, SchemeHostPort::ALREADY_CANONICALIZED);
56 } 65 }
57 66
58 std::string Origin::Serialize() const { 67 std::string Origin::Serialize() const {
59 if (unique()) 68 if (unique())
60 return "null"; 69 return "null";
61 70
62 if (scheme() == kFileScheme) 71 if (scheme() == kFileScheme)
63 return "file://"; 72 return "file://";
64 73
65 return tuple_.Serialize(); 74 return tuple_.Serialize();
(...skipping 26 matching lines...) Expand all
92 101
93 std::ostream& operator<<(std::ostream& out, const url::Origin& origin) { 102 std::ostream& operator<<(std::ostream& out, const url::Origin& origin) {
94 return out << origin.Serialize(); 103 return out << origin.Serialize();
95 } 104 }
96 105
97 bool IsSameOriginWith(const GURL& a, const GURL& b) { 106 bool IsSameOriginWith(const GURL& a, const GURL& b) {
98 return Origin(a).IsSameOriginWith(Origin(b)); 107 return Origin(a).IsSameOriginWith(Origin(b));
99 } 108 }
100 109
101 } // namespace url 110 } // namespace url
OLDNEW
« no previous file with comments | « url/origin.h ('k') | url/scheme_host_port.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698