Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef APIKey_h | |
| 6 #define APIKey_h | |
| 7 | |
| 8 #include "core/CoreExport.h" | |
| 9 #include "core/dom/DOMException.h" | |
| 10 #include "platform/heap/Handle.h" | |
| 11 #include "platform/weborigin/KURL.h" | |
| 12 #include "wtf/text/WTFString.h" | |
| 13 | |
| 14 namespace blink { | |
| 15 | |
| 16 // The Experimental Framework (EF) provides limited access to experimental APIs, | |
| 17 // on a per-origin basis. This class defines the API key data structure, used | |
| 18 // to securely provide access to an experimental API. | |
| 19 // | |
| 20 // Experimental APIs are defined by string names, provided by the implementers. | |
| 21 // The EF code does not maintain an enum or constant list for experiment names. | |
| 22 // Instead, the EF validates the name provided by the API implementation against | |
| 23 // any provided API keys. | |
| 24 // | |
| 25 // In the renderer, the EF is concerned with checking whether an API key claims | |
| 26 // to be valid for the current origin. It does not attempt to actually validate | |
| 27 // the signature on the key. | |
| 28 // | |
| 29 // TODO(chasej): Link to documentation, or provide more detail on keys, .etc | |
|
Rick Byers
2015/12/18 21:52:42
Is this the doc you want (at least for now): https
iclelland
2015/12/21 19:17:17
Actually, more info on the key format itself is be
| |
| 30 class CORE_EXPORT APIKey : public RefCountedWillBeGarbageCollected<APIKey> { | |
|
Marijn Kruisselbrink
2015/12/18 22:03:01
Why RefCountedWillBeGarbageCollected? New code sho
iclelland
2015/12/21 19:17:17
[Class removed in subsequent CLs]
| |
| 31 public: | |
| 32 // Returns an APIKey object if the string can be parsed correctly. (This | |
| 33 // does not mean that the key is valid for the current origin, just that it | |
| 34 // is well-formed.) If the string is not a well-formed key, then a null | |
| 35 // pointer is returned. | |
| 36 static PassRefPtrWillBeRawPtr<APIKey> parse(const String&); | |
| 37 | |
| 38 // Returns true if this API key was issued for the given origin and API | |
| 39 // combination, and contains an expiry timestamp which is still in the | |
| 40 // future. Returning true does not mean that the key is valid nor | |
| 41 // is it a sufficient check to allow access to the API. | |
| 42 bool isValid(const String& origin, const String& apiName, uint64_t now) cons t; | |
| 43 | |
| 44 protected: | |
| 45 friend class APIKeyTest; | |
| 46 | |
| 47 bool validateOrigin(const String& originText) const; | |
| 48 bool validateApiName(const String& apiName) const; | |
| 49 bool validateDate(uint64_t now) const; | |
| 50 | |
| 51 private: | |
| 52 APIKey(); | |
| 53 explicit APIKey(const String& m_signature, const KURL& origin, const String& apiName, uint64_t m_expiry); | |
| 54 | |
| 55 String m_signature; | |
| 56 KURL m_origin; | |
| 57 String m_apiName; | |
| 58 uint64_t m_expiry; | |
| 59 }; | |
| 60 | |
| 61 } // namespace blink | |
| 62 | |
| 63 #endif // APIKey_h | |
| OLD | NEW |