summaryrefslogtreecommitdiffstats
path: root/webkit/glue/webdatasource_impl.cc
blob: d3517d8a3b79836cc5f87d2af423d0518e90912b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "config.h"
#include "webkit/glue/webdatasource_impl.h"

#include "KURL.h"
#include "FrameLoadRequest.h"
#include "ResourceRequest.h"

#undef LOG
#include "base/string_util.h"
#include "webkit/glue/glue_util.h"
#include "webkit/glue/password_form.h"
#include "webkit/glue/webdatasource_impl.h"
#include "webkit/glue/webframe_impl.h"
#include "webkit/glue/weburlrequest_impl.h"

// static
PassRefPtr<WebDataSourceImpl> WebDataSourceImpl::Create(
    const WebCore::ResourceRequest& request,
    const WebCore::SubstituteData& data) {
  return adoptRef(new WebDataSourceImpl(request, data));
}

WebDataSourceImpl::WebDataSourceImpl(const WebCore::ResourceRequest& request,
                                     const WebCore::SubstituteData& data)
    : WebCore::DocumentLoader(request, data),
      form_submit_(false) {
}

WebDataSourceImpl::~WebDataSourceImpl() {
}

WebFrame* WebDataSourceImpl::GetWebFrame() {
  return WebFrameImpl::FromFrame(frame());
}

const WebRequest& WebDataSourceImpl::GetInitialRequest() const {
  // WebKit may change the frame load request as it sees fit, so we must sync
  // our request object.
  initial_request_.set_frame_load_request(
      WebCore::FrameLoadRequest(originalRequest()));
  return initial_request_;
}

const WebRequest& WebDataSourceImpl::GetRequest() const {
  // WebKit may change the frame load request as it sees fit, so we must sync
  // our request object.
  request_.set_frame_load_request(
      WebCore::FrameLoadRequest(request()));
  return request_;
}

const WebResponse& WebDataSourceImpl::GetResponse() const {
  response_.set_resource_response(response());
  return response_;
}

void WebDataSourceImpl::SetExtraData(WebRequest::ExtraData* extra) {
  initial_request_.SetExtraData(extra);
  request_.SetExtraData(extra);
}

GURL WebDataSourceImpl::GetUnreachableURL() const {
  const WebCore::KURL& url = unreachableURL();
  return url.isEmpty() ? GURL() : webkit_glue::KURLToGURL(url);
}

bool WebDataSourceImpl::HasUnreachableURL() const {
  return !unreachableURL().isEmpty();
}

const std::vector<GURL>& WebDataSourceImpl::GetRedirectChain() const {
  return redirect_chain_;
}

void WebDataSourceImpl::ClearRedirectChain() {
  redirect_chain_.clear();
}

void WebDataSourceImpl::AppendRedirect(const GURL& url) {
  redirect_chain_.push_back(url);
}

const SearchableFormData* WebDataSourceImpl::GetSearchableFormData() const {
  return searchable_form_data();
}

const PasswordForm* WebDataSourceImpl::GetPasswordFormData() const {
  return password_form_data();
}

bool WebDataSourceImpl::IsFormSubmit() const {
  return is_form_submit();
}

string16 WebDataSourceImpl::GetPageTitle() const {
  return webkit_glue::StringToString16(title());
}