summaryrefslogtreecommitdiffstats
path: root/webkit/glue/webdatasource_impl.cc
blob: c0ace9bc32a30446a9eb535a3b567db4f2f7b82f (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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
// 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 "FrameLoaderTypes.h"
#include "FrameLoadRequest.h"
#include "KURL.h"
#include "ResourceRequest.h"

#undef LOG
#include "base/histogram.h"
#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"
#include "webkit/glue/webview_delegate.h"

using base::TimeDelta;
using base::Time;

// 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) {
}

WebDataSourceImpl::~WebDataSourceImpl() {
}

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_resource_request(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_resource_request(request());
  return request_;
}

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

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);
}

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

base::Time WebDataSourceImpl::GetRequestTime() const {
  return request_time_;
}

void WebDataSourceImpl::SetRequestTime(base::Time time) {
  request_time_ = time;
}

base::Time WebDataSourceImpl::GetStartLoadTime() const {
  return start_load_time_;
}

base::Time WebDataSourceImpl::GetFinishDocumentLoadTime() const {
  return finish_document_load_time_;
}

base::Time WebDataSourceImpl::GetFinishLoadTime() const {
  return finish_load_time_;
}

base::Time WebDataSourceImpl::GetFirstLayoutTime() const {
  return first_layout_time_;
}

WebNavigationType WebDataSourceImpl::GetNavigationType() const {
  return NavigationTypeToWebNavigationType(triggeringAction().type());
}

WebDataSource::ExtraData* WebDataSourceImpl::GetExtraData() const {
  return extra_data_.get();
}

void WebDataSourceImpl::SetExtraData(ExtraData* extra_data) {
  extra_data_.set(extra_data);
}

WebNavigationType WebDataSourceImpl::NavigationTypeToWebNavigationType(
    WebCore::NavigationType type) {
  switch (type) {
    case WebCore::NavigationTypeLinkClicked:
      return WebNavigationTypeLinkClicked;
    case WebCore::NavigationTypeFormSubmitted:
      return WebNavigationTypeFormSubmitted;
    case WebCore::NavigationTypeBackForward:
      return WebNavigationTypeBackForward;
    case WebCore::NavigationTypeReload:
      return WebNavigationTypeReload;
    case WebCore::NavigationTypeFormResubmitted:
      return WebNavigationTypeFormResubmitted;
    case WebCore::NavigationTypeOther:
    default:
      return WebNavigationTypeOther;
  }
}