OLD | NEW |
| (Empty) |
1 // Copyright 2013 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 #include "webkit/base/origin_url_conversions.h" | |
6 | |
7 #include "base/strings/utf_string_conversions.h" | |
8 #include "googleurl/src/gurl.h" | |
9 #include "third_party/WebKit/public/platform/WebCString.h" | |
10 #include "third_party/WebKit/public/platform/WebString.h" | |
11 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" | |
12 | |
13 namespace webkit_base { | |
14 | |
15 GURL GetOriginURLFromIdentifier(const std::string& identifier) { | |
16 WebKit::WebSecurityOrigin web_security_origin = | |
17 WebKit::WebSecurityOrigin::createFromDatabaseIdentifier( | |
18 WebKit::WebString::fromUTF8(identifier)); | |
19 | |
20 // We need this work-around for file:/// URIs as | |
21 // createFromDatabaseIdentifier returns null origin_url for them. | |
22 if (web_security_origin.isUnique()) { | |
23 if (identifier.find("file__") == 0) | |
24 return GURL("file:///"); | |
25 return GURL(); | |
26 } | |
27 | |
28 return GURL(web_security_origin.toString()); | |
29 } | |
30 | |
31 std::string GetOriginIdentifierFromURL(const GURL& url) { | |
32 return WebKit::WebSecurityOrigin::createFromString( | |
33 UTF8ToUTF16(url.spec())).databaseIdentifier().utf8(); | |
34 } | |
35 | |
36 } // namespace webkit_base | |
OLD | NEW |