1db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block/* 2db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block * Copyright (C) 2010 Apple Inc. All rights reserved. 3db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block * 4db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block * Redistribution and use in source and binary forms, with or without 5db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block * modification, are permitted provided that the following conditions 6db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block * are met: 7db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block * 1. Redistributions of source code must retain the above copyright 8db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block * notice, this list of conditions and the following disclaimer. 9db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block * 2. Redistributions in binary form must reproduce the above copyright 10db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block * notice, this list of conditions and the following disclaimer in the 11db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block * documentation and/or other materials provided with the distribution. 12db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block * 13db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' 14db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 15db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS 17db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 18db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 19db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 20db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 21db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 22db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 23db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block * THE POSSIBILITY OF SUCH DAMAGE. 24db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block */ 25db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block 262fc2651226baac27029e38c9d6ef883fa32084dbSteve Block#include "config.h" 2765f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch#include "WKURLResponseCF.h" 28dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch 2965f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch#include "WKAPICast.h" 3065f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch#include "WebURLResponse.h" 3165f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch 3265f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdochusing namespace WebKit; 3365f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch 3465f03d4f644ce73618e5f4f50dd694b26f55ae12Ben MurdochWKURLResponseRef WKURLResponseCreateWithCFURLResponse(CFURLResponseRef urlResponse) 3565f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch{ 362bde8e466a4451c7319e3a072d118917957d6554Steve Block if (!urlResponse) 372bde8e466a4451c7319e3a072d118917957d6554Steve Block return 0; 382bde8e466a4451c7319e3a072d118917957d6554Steve Block 3965f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch CFURLResponseRef copiedURLResponse = CFURLResponseCreateCopy(kCFAllocatorDefault, urlResponse); 4065f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch RefPtr<WebURLResponse> response = WebURLResponse::create(copiedURLResponse); 4165f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch return toAPI(response.release().releaseRef()); 42dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch} 43db14019a23d96bc8a444b6576a5da8bd1cfbc8b0Steve Block 4465f03d4f644ce73618e5f4f50dd694b26f55ae12Ben MurdochCFURLResponseRef WKURLResponseCopyCFURLResponse(CFAllocatorRef alloc, WKURLResponseRef urlResponse) 4565f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch{ 462bde8e466a4451c7319e3a072d118917957d6554Steve Block if (!urlResponse) 472bde8e466a4451c7319e3a072d118917957d6554Steve Block return 0; 482bde8e466a4451c7319e3a072d118917957d6554Steve Block 492bde8e466a4451c7319e3a072d118917957d6554Steve Block PlatformResponse platformURLResponse = toImpl(urlResponse)->platformResponse(); 502bde8e466a4451c7319e3a072d118917957d6554Steve Block if (!platformURLResponse) 512bde8e466a4451c7319e3a072d118917957d6554Steve Block return 0; 522bde8e466a4451c7319e3a072d118917957d6554Steve Block 5365f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch return CFURLResponseCreateCopy(alloc, toImpl(urlResponse)->platformResponse()); 5465f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch} 55