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

Side by Side Diff: Source/platform/weborigin/SecurityOriginHash.h

Issue 1180923003: Add window access checks for Suborigins (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix tests on Windows Created 5 years, 6 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 /* 1 /*
2 * Copyright (C) 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2008 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 20 matching lines...) Expand all
31 31
32 #include "platform/weborigin/KURL.h" 32 #include "platform/weborigin/KURL.h"
33 #include "platform/weborigin/SecurityOrigin.h" 33 #include "platform/weborigin/SecurityOrigin.h"
34 #include "wtf/RefPtr.h" 34 #include "wtf/RefPtr.h"
35 35
36 namespace blink { 36 namespace blink {
37 37
38 struct SecurityOriginHash { 38 struct SecurityOriginHash {
39 static unsigned hash(SecurityOrigin* origin) 39 static unsigned hash(SecurityOrigin* origin)
40 { 40 {
41 unsigned hashCodes[3] = { 41 unsigned hashCodes[4] = {
42 origin->protocol().impl() ? origin->protocol().impl()->hash() : 0, 42 origin->protocol().impl() ? origin->protocol().impl()->hash() : 0,
43 origin->host().impl() ? origin->host().impl()->hash() : 0, 43 origin->host().impl() ? origin->host().impl()->hash() : 0,
44 origin->port() 44 origin->port(),
45 origin->suboriginName().impl() ? origin->suboriginName().impl()->has h() : 0
45 }; 46 };
46 return StringHasher::hashMemory<sizeof(hashCodes)>(hashCodes); 47 return StringHasher::hashMemory<sizeof(hashCodes)>(hashCodes);
47 } 48 }
48 static unsigned hash(const RefPtr<SecurityOrigin>& origin) 49 static unsigned hash(const RefPtr<SecurityOrigin>& origin)
49 { 50 {
50 return hash(origin.get()); 51 return hash(origin.get());
51 } 52 }
52 53
53 static bool equal(SecurityOrigin* a, SecurityOrigin* b) 54 static bool equal(SecurityOrigin* a, SecurityOrigin* b)
54 { 55 {
55 if (!a || !b) 56 if (!a || !b)
56 return a == b; 57 return a == b;
57 58
58 if (a == b) 59 if (a == b)
59 return true; 60 return true;
60 61
61 if (!a->isSameSchemeHostPort(b)) 62 if (!a->isSameSchemeHostPortAndSuborigin(b))
62 return false; 63 return false;
63 64
64 if (a->domainWasSetInDOM() != b->domainWasSetInDOM()) 65 if (a->domainWasSetInDOM() != b->domainWasSetInDOM())
65 return false; 66 return false;
66 67
67 if (a->domainWasSetInDOM() && a->domain() != b->domain()) 68 if (a->domainWasSetInDOM() && a->domain() != b->domain())
68 return false; 69 return false;
69 70
70 return true; 71 return true;
71 } 72 }
(...skipping 17 matching lines...) Expand all
89 90
90 namespace WTF { 91 namespace WTF {
91 92
92 template<> struct DefaultHash<RefPtr<blink::SecurityOrigin>> { 93 template<> struct DefaultHash<RefPtr<blink::SecurityOrigin>> {
93 typedef blink::SecurityOriginHash Hash; 94 typedef blink::SecurityOriginHash Hash;
94 }; 95 };
95 96
96 } // namespace WTF 97 } // namespace WTF
97 98
98 #endif // SecurityOriginHash_h 99 #endif // SecurityOriginHash_h
OLDNEW
« no previous file with comments | « Source/platform/weborigin/SecurityOrigin.cpp ('k') | Source/platform/weborigin/SecurityOriginTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698